1#!/bin/sh
2
3test_description='git mktree'
4
5. ./test-lib.sh
6
7test_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 one >one &&
14 git add one &&
15 git write-tree >tree &&
16 git ls-tree $(cat tree) >top &&
17 git ls-tree -r $(cat tree) >all &&
18 test_tick &&
19 git commit -q -m one &&
20 H=$(git rev-parse HEAD) &&
21 git update-index --add --cacheinfo 160000 $H sub &&
22 test_tick &&
23 git commit -q -m two &&
24 git rev-parse HEAD^{tree} >tree.withsub &&
25 git ls-tree HEAD >top.withsub &&
26 git ls-tree -r HEAD >all.withsub
27'
28
29test_expect_success 'ls-tree piped to mktree (1)' '
30 git mktree <top >actual &&
31 test_cmp tree actual
32'
33
34test_expect_success 'ls-tree piped to mktree (2)' '
35 git mktree <top.withsub >actual &&
36 test_cmp tree.withsub actual
37'
38
39test_expect_success 'ls-tree output in wrong order given to mktree (1)' '
40 perl -e "print reverse <>" <top |
41 git mktree >actual &&
42 test_cmp tree actual
43'
44
45test_expect_success 'ls-tree output in wrong order given to mktree (2)' '
46 perl -e "print reverse <>" <top.withsub |
47 git mktree >actual &&
48 test_cmp tree.withsub actual
49'
50
51test_expect_failure 'mktree reads ls-tree -r output (1)' '
52 git mktree <all >actual &&
53 test_cmp tree actual
54'
55
56test_expect_failure 'mktree reads ls-tree -r output (2)' '
57 git mktree <all.withsub >actual &&
58 test_cmp tree.withsub actual
59'
60
61test_done