Code

t1010: add mktree test
[git.git] / t / t1010-mktree.sh
1 #!/bin/sh
3 test_description='git mktree'
5 . ./test-lib.sh
7 test_expect_success setup '
8         for d in a a. a0
9         do
10                 mkdir "$d" && echo "$d/one" >"$d/one" &&
11                 git add "$d"
12         done &&
13         echo one >one &&
14         git add one &&
15         git write-tree >tree &&
16         git ls-tree $(cat tree) >top &&
17         git ls-tree -r $(cat tree) >all &&
18         test_tick &&
19         git commit -q -m one &&
20         H=$(git rev-parse HEAD) &&
21         git update-index --add --cacheinfo 160000 $H sub &&
22         test_tick &&
23         git commit -q -m two &&
24         git rev-parse HEAD^{tree} >tree.withsub &&
25         git ls-tree HEAD >top.withsub &&
26         git ls-tree -r HEAD >all.withsub
27 '
29 test_expect_success 'ls-tree piped to mktree (1)' '
30         git mktree <top >actual &&
31         test_cmp tree actual
32 '
34 test_expect_success 'ls-tree piped to mktree (2)' '
35         git mktree <top.withsub >actual &&
36         test_cmp tree.withsub actual
37 '
39 test_expect_success 'ls-tree output in wrong order given to mktree (1)' '
40         perl -e "print reverse <>" <top |
41         git mktree >actual &&
42         test_cmp tree actual
43 '
45 test_expect_success 'ls-tree output in wrong order given to mktree (2)' '
46         perl -e "print reverse <>" <top.withsub |
47         git mktree >actual &&
48         test_cmp tree.withsub actual
49 '
51 test_expect_failure 'mktree reads ls-tree -r output (1)' '
52         git mktree <all >actual &&
53         test_cmp tree actual
54 '
56 test_expect_failure 'mktree reads ls-tree -r output (2)' '
57         git mktree <all.withsub >actual &&
58         test_cmp tree.withsub actual
59 '
61 test_done