3 test_description
='git mktree'
5 TEST_PASSES_SANITIZE_LEAK
=true
8 test_expect_success setup
'
11 mkdir "$d" && echo "$d/one" >"$d/one" &&
12 git add "$d" || return 1
15 git update-index --add --info-only one &&
16 git write-tree --missing-ok >tree.missing &&
17 git ls-tree $(cat tree.missing) >top.missing &&
18 git ls-tree -r $(cat tree.missing) >all.missing &&
21 git write-tree >tree &&
22 git ls-tree $(cat tree) >top &&
23 git ls-tree -r $(cat tree) >all &&
25 git commit -q -m one &&
26 H=$(git rev-parse HEAD) &&
27 git update-index --add --cacheinfo 160000 $H sub &&
29 git commit -q -m two &&
30 git rev-parse HEAD^{tree} >tree.withsub &&
31 git ls-tree HEAD >top.withsub &&
32 git ls-tree -r HEAD >all.withsub
35 test_expect_success
'ls-tree piped to mktree (1)' '
36 git mktree <top >actual &&
40 test_expect_success
'ls-tree piped to mktree (2)' '
41 git mktree <top.withsub >actual &&
42 test_cmp tree.withsub actual
45 test_expect_success
'ls-tree output in wrong order given to mktree (1)' '
46 perl -e "print reverse <>" <top |
51 test_expect_success
'ls-tree output in wrong order given to mktree (2)' '
52 perl -e "print reverse <>" <top.withsub |
54 test_cmp tree.withsub actual
57 test_expect_success
'allow missing object with --missing' '
58 git mktree --missing <top.missing >actual &&
59 test_cmp tree.missing actual
62 test_expect_success
'mktree refuses to read ls-tree -r output (1)' '
63 test_must_fail git mktree <all >actual
66 test_expect_success
'mktree refuses to read ls-tree -r output (2)' '
67 test_must_fail git mktree <all.withsub >actual