Merge branch 'maint'
[git/mingw/4msysgit/kblees.git] / t / t1010-mktree.sh
blobb946f8768649dd76d8a175877c63d49244e00ffb
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 zero >one &&
14 git update-index --add --info-only one &&
15 git write-tree --missing-ok >tree.missing &&
16 git ls-tree $(cat tree.missing) >top.missing &&
17 git ls-tree -r $(cat tree.missing) >all.missing &&
18 echo one >one &&
19 git add one &&
20 git write-tree >tree &&
21 git ls-tree $(cat tree) >top &&
22 git ls-tree -r $(cat tree) >all &&
23 test_tick &&
24 git commit -q -m one &&
25 H=$(git rev-parse HEAD) &&
26 git update-index --add --cacheinfo 160000 $H sub &&
27 test_tick &&
28 git commit -q -m two &&
29 git rev-parse HEAD^{tree} >tree.withsub &&
30 git ls-tree HEAD >top.withsub &&
31 git ls-tree -r HEAD >all.withsub
34 test_expect_success 'ls-tree piped to mktree (1)' '
35 git mktree <top >actual &&
36 test_cmp tree actual
39 test_expect_success 'ls-tree piped to mktree (2)' '
40 git mktree <top.withsub >actual &&
41 test_cmp tree.withsub actual
44 test_expect_success 'ls-tree output in wrong order given to mktree (1)' '
45 perl -e "print reverse <>" <top |
46 git mktree >actual &&
47 test_cmp tree actual
50 test_expect_success 'ls-tree output in wrong order given to mktree (2)' '
51 perl -e "print reverse <>" <top.withsub |
52 git mktree >actual &&
53 test_cmp tree.withsub actual
56 test_expect_success 'allow missing object with --missing' '
57 git mktree --missing <top.missing >actual &&
58 test_cmp tree.missing actual
61 test_expect_success 'mktree refuses to read ls-tree -r output (1)' '
62 test_must_fail git mktree <all >actual
65 test_expect_success 'mktree refuses to read ls-tree -r output (2)' '
66 test_must_fail git mktree <all.withsub >actual
69 test_done