]>
Commit | Line | Data |
---|---|---|
801cfae8 JH |
1 | #!/bin/sh |
2 | ||
3 | test_description='git mktree' | |
4 | ||
7ff24785 | 5 | TEST_PASSES_SANITIZE_LEAK=true |
801cfae8 JH |
6 | . ./test-lib.sh |
7 | ||
8 | test_expect_success setup ' | |
afb31ad9 | 9 | for d in a a- a0 |
801cfae8 JH |
10 | do |
11 | mkdir "$d" && echo "$d/one" >"$d/one" && | |
afb31ad9 | 12 | git add "$d" || return 1 |
801cfae8 | 13 | done && |
1c64e79a JH |
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 && | |
801cfae8 JH |
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 | |
33 | ' | |
34 | ||
35 | test_expect_success 'ls-tree piped to mktree (1)' ' | |
36 | git mktree <top >actual && | |
37 | test_cmp tree actual | |
38 | ' | |
39 | ||
40 | test_expect_success 'ls-tree piped to mktree (2)' ' | |
41 | git mktree <top.withsub >actual && | |
42 | test_cmp tree.withsub actual | |
43 | ' | |
44 | ||
45 | test_expect_success 'ls-tree output in wrong order given to mktree (1)' ' | |
94221d22 | 46 | perl -e "print reverse <>" <top | |
801cfae8 JH |
47 | git mktree >actual && |
48 | test_cmp tree actual | |
49 | ' | |
50 | ||
51 | test_expect_success 'ls-tree output in wrong order given to mktree (2)' ' | |
94221d22 | 52 | perl -e "print reverse <>" <top.withsub | |
801cfae8 JH |
53 | git mktree >actual && |
54 | test_cmp tree.withsub actual | |
55 | ' | |
56 | ||
1c64e79a JH |
57 | test_expect_success 'allow missing object with --missing' ' |
58 | git mktree --missing <top.missing >actual && | |
59 | test_cmp tree.missing actual | |
60 | ' | |
61 | ||
53b3c47d | 62 | test_expect_success 'mktree refuses to read ls-tree -r output (1)' ' |
f4b98e17 | 63 | test_must_fail git mktree <all |
801cfae8 JH |
64 | ' |
65 | ||
53b3c47d | 66 | test_expect_success 'mktree refuses to read ls-tree -r output (2)' ' |
f4b98e17 | 67 | test_must_fail git mktree <all.withsub |
801cfae8 JH |
68 | ' |
69 | ||
70 | test_done |