3 test_description='git mktree'
7 test_expect_success setup '
10 mkdir "$d" && echo "$d/one" >"$d/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 &&
20 git write-tree >tree &&
21 git ls-tree $(cat tree) >top &&
22 git ls-tree -r $(cat tree) >all &&
24 git commit -q -m one &&
25 H=$(git rev-parse HEAD) &&
26 git update-index --add --cacheinfo 160000 $H sub &&
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 &&
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_PATH" -e "print reverse <>" <top |
50 test_expect_success 'ls-tree output in wrong order given to mktree (2)' '
51 "$PERL_PATH" -e "print reverse <>" <top.withsub |
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