t/t0211-trace2-perf.sh: fix typo patern -> pattern
[alt-git.git] / t / t2201-add-update-typechange.sh
blobdba62d69c6c5c18172bdbc62c5138643cf284b00
1 #!/bin/sh
3 test_description='more git add -u'
5 TEST_PASSES_SANITIZE_LEAK=true
6 . ./test-lib.sh
8 test_expect_success setup '
9 >xyzzy &&
10 _empty=$(git hash-object --stdin <xyzzy) &&
11 >yomin &&
12 >caskly &&
13 if test_have_prereq SYMLINKS; then
14 ln -s frotz nitfol &&
15 T_letter=T
16 else
17 printf %s frotz > nitfol &&
18 T_letter=M
19 fi &&
20 mkdir rezrov &&
21 >rezrov/bozbar &&
22 git add caskly xyzzy yomin nitfol rezrov/bozbar &&
24 test_tick &&
25 git commit -m initial
29 test_expect_success modify '
30 rm -f xyzzy yomin nitfol caskly &&
31 # caskly disappears (not a submodule)
32 mkdir caskly &&
33 # nitfol changes from symlink to regular
34 >nitfol &&
35 # rezrov/bozbar disappears
36 rm -fr rezrov &&
37 if test_have_prereq SYMLINKS; then
38 ln -s xyzzy rezrov
39 else
40 printf %s xyzzy > rezrov
41 fi &&
42 # xyzzy disappears (not a submodule)
43 mkdir xyzzy &&
44 echo gnusto >xyzzy/bozbar &&
45 # yomin gets replaced with a submodule
46 mkdir yomin &&
47 >yomin/yomin &&
49 cd yomin &&
50 git init &&
51 git add yomin &&
52 git commit -m "sub initial"
53 ) &&
54 yomin=$(GIT_DIR=yomin/.git git rev-parse HEAD) &&
55 # yonk is added and then turned into a submodule
56 # this should appear as T in diff-files and as A in diff-index
57 >yonk &&
58 git add yonk &&
59 rm -f yonk &&
60 mkdir yonk &&
61 >yonk/yonk &&
63 cd yonk &&
64 git init &&
65 git add yonk &&
66 git commit -m "sub initial"
67 ) &&
68 yonk=$(GIT_DIR=yonk/.git git rev-parse HEAD) &&
69 # zifmia is added and then removed
70 # this should appear in diff-files but not in diff-index.
71 >zifmia &&
72 git add zifmia &&
73 rm -f zifmia &&
74 mkdir zifmia &&
76 git ls-tree -r HEAD |
77 sed -e "s/^/:/" -e "
78 / caskly/{
79 s/ caskly/ $ZERO_OID D&/
80 s/blob/000000/
82 / nitfol/{
83 s/ nitfol/ $ZERO_OID $T_letter&/
84 s/blob/100644/
86 / rezrov.bozbar/{
87 s/ rezrov.bozbar/ $ZERO_OID D&/
88 s/blob/000000/
90 / xyzzy/{
91 s/ xyzzy/ $ZERO_OID D&/
92 s/blob/000000/
94 / yomin/{
95 s/ yomin/ $ZERO_OID T&/
96 s/blob/160000/
99 } >expect &&
101 cat expect &&
102 echo ":100644 160000 $_empty $ZERO_OID T yonk" &&
103 echo ":100644 000000 $_empty $ZERO_OID D zifmia"
104 } >expect-files &&
106 cat expect &&
107 echo ":000000 160000 $ZERO_OID $ZERO_OID A yonk"
108 } >expect-index &&
110 echo "100644 $_empty 0 nitfol" &&
111 echo "160000 $yomin 0 yomin" &&
112 echo "160000 $yonk 0 yonk"
113 } >expect-final
116 test_expect_success diff-files '
117 git diff-files --raw >actual &&
118 test_cmp expect-files actual
121 test_expect_success diff-index '
122 git diff-index --raw HEAD -- >actual &&
123 test_cmp expect-index actual
126 test_expect_success 'add -u' '
127 rm -f ".git/saved-index" &&
128 cp -p ".git/index" ".git/saved-index" &&
129 git add -u &&
130 git ls-files -s >actual &&
131 test_cmp expect-final actual
134 test_expect_success 'commit -a' '
135 if test -f ".git/saved-index"
136 then
137 rm -f ".git/index" &&
138 mv ".git/saved-index" ".git/index"
139 fi &&
140 git commit -m "second" -a &&
141 git ls-files -s >actual &&
142 test_cmp expect-final actual &&
143 rm -f .git/index &&
144 git read-tree HEAD &&
145 git ls-files -s >actual &&
146 test_cmp expect-final actual
149 test_done