Merge branch 'cp/git-flush-is-an-env-bool'
[alt-git.git] / t / t1010-mktree.sh
blob22875ba598c2a82bba6c7504c420c690441f7167
1 #!/bin/sh
3 test_description='git mktree'
5 TEST_PASSES_SANITIZE_LEAK=true
6 . ./test-lib.sh
8 test_expect_success setup '
9 for d in a a- a0
11 mkdir "$d" && echo "$d/one" >"$d/one" &&
12 git add "$d" || return 1
13 done &&
14 echo zero >one &&
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 &&
19 echo one >one &&
20 git add one &&
21 git write-tree >tree &&
22 git ls-tree $(cat tree) >top &&
23 git ls-tree -r $(cat tree) >all &&
24 test_tick &&
25 git commit -q -m one &&
26 H=$(git rev-parse HEAD) &&
27 git update-index --add --cacheinfo 160000 $H sub &&
28 test_tick &&
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 &&
37 test_cmp tree 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 |
47 git mktree >actual &&
48 test_cmp tree actual
51 test_expect_success 'ls-tree output in wrong order given to mktree (2)' '
52 perl -e "print reverse <>" <top.withsub |
53 git mktree >actual &&
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
66 test_expect_success 'mktree refuses to read ls-tree -r output (2)' '
67 test_must_fail git mktree <all.withsub
70 test_done