]> git.ipfire.org Git - thirdparty/git.git/blame - t/t2201-add-update-typechange.sh
The third batch
[thirdparty/git.git] / t / t2201-add-update-typechange.sh
CommitLineData
6301f303
JH
1#!/bin/sh
2
3test_description='more git add -u'
4
aecb85bd 5TEST_PASSES_SANITIZE_LEAK=true
6301f303
JH
6. ./test-lib.sh
7
6301f303
JH
8test_expect_success setup '
9 >xyzzy &&
10 _empty=$(git hash-object --stdin <xyzzy) &&
11 >yomin &&
12 >caskly &&
704a3143
JS
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 &&
6301f303
JH
20 mkdir rezrov &&
21 >rezrov/bozbar &&
22 git add caskly xyzzy yomin nitfol rezrov/bozbar &&
23
24 test_tick &&
25 git commit -m initial
26
27'
28
29test_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 &&
704a3143
JS
37 if test_have_prereq SYMLINKS; then
38 ln -s xyzzy rezrov
39 else
40 printf %s xyzzy > rezrov
41 fi &&
6301f303
JH
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 &&
48 (
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 &&
62 (
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 &&
75 {
76 git ls-tree -r HEAD |
77 sed -e "s/^/:/" -e "
78 / caskly/{
8125a58b 79 s/ caskly/ $ZERO_OID D&/
6301f303
JH
80 s/blob/000000/
81 }
82 / nitfol/{
8125a58b 83 s/ nitfol/ $ZERO_OID $T_letter&/
6301f303
JH
84 s/blob/100644/
85 }
86 / rezrov.bozbar/{
8125a58b 87 s/ rezrov.bozbar/ $ZERO_OID D&/
6301f303
JH
88 s/blob/000000/
89 }
90 / xyzzy/{
8125a58b 91 s/ xyzzy/ $ZERO_OID D&/
6301f303
JH
92 s/blob/000000/
93 }
94 / yomin/{
8125a58b 95 s/ yomin/ $ZERO_OID T&/
6301f303
JH
96 s/blob/160000/
97 }
98 "
99 } >expect &&
100 {
7abcbcb7
ES
101 cat expect &&
102 echo ":100644 160000 $_empty $ZERO_OID T yonk" &&
8125a58b 103 echo ":100644 000000 $_empty $ZERO_OID D zifmia"
6301f303
JH
104 } >expect-files &&
105 {
7abcbcb7 106 cat expect &&
8125a58b 107 echo ":000000 160000 $ZERO_OID $ZERO_OID A yonk"
6301f303
JH
108 } >expect-index &&
109 {
7abcbcb7
ES
110 echo "100644 $_empty 0 nitfol" &&
111 echo "160000 $yomin 0 yomin" &&
6301f303
JH
112 echo "160000 $yonk 0 yonk"
113 } >expect-final
114'
115
f58dbf23 116test_expect_success diff-files '
6301f303 117 git diff-files --raw >actual &&
2b14d072 118 test_cmp expect-files actual
6301f303
JH
119'
120
948dd346 121test_expect_success diff-index '
6301f303 122 git diff-index --raw HEAD -- >actual &&
2b14d072 123 test_cmp expect-index actual
6301f303
JH
124'
125
f58dbf23 126test_expect_success 'add -u' '
6301f303
JH
127 rm -f ".git/saved-index" &&
128 cp -p ".git/index" ".git/saved-index" &&
129 git add -u &&
130 git ls-files -s >actual &&
2b14d072 131 test_cmp expect-final actual
6301f303
JH
132'
133
f58dbf23 134test_expect_success 'commit -a' '
6301f303
JH
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 &&
2b14d072 142 test_cmp expect-final actual &&
6301f303
JH
143 rm -f .git/index &&
144 git read-tree HEAD &&
145 git ls-files -s >actual &&
2b14d072 146 test_cmp expect-final actual
6301f303
JH
147'
148
149test_done