GIT v1.5.0-rc2
[git/mingw/4msysgit/wingit-dll.git] / t / t6022-merge-rename.sh
blobb608e202c18fd545868898fcd0528c3501459b6f
1 #!/bin/sh
3 test_description='Merge-recursive merging renames'
4 . ./test-lib.sh
6 test_expect_success setup \
8 cat >A <<\EOF &&
9 a aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
10 b bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb
11 c cccccccccccccccccccccccccccccccccccccccccccccccc
12 d dddddddddddddddddddddddddddddddddddddddddddddddd
13 e eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee
14 f ffffffffffffffffffffffffffffffffffffffffffffffff
15 g gggggggggggggggggggggggggggggggggggggggggggggggg
16 h hhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh
17 i iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii
18 j jjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjj
19 k kkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk
20 l llllllllllllllllllllllllllllllllllllllllllllllll
21 m mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm
22 n nnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnn
23 o oooooooooooooooooooooooooooooooooooooooooooooooo
24 EOF
26 cat >M <<\EOF &&
27 A AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
28 B BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB
29 C CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
30 D DDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDD
31 E EEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE
32 F FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
33 G GGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGG
34 H HHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHH
35 I IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII
36 J JJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJ
37 K KKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKK
38 L LLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLL
39 M MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM
40 N NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN
41 O OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO
42 EOF
44 git add A M &&
45 git commit -m "initial has A and M" &&
46 git branch white &&
47 git branch red &&
48 git branch blue &&
49 git branch yellow &&
51 sed -e "/^g /s/.*/g : master changes a line/" <A >A+ &&
52 mv A+ A &&
53 git commit -a -m "master updates A" &&
55 git checkout yellow &&
56 rm -f M &&
57 git commit -a -m "yellow removes M" &&
59 git checkout white &&
60 sed -e "/^g /s/.*/g : white changes a line/" <A >B &&
61 sed -e "/^G /s/.*/G : colored branch changes a line/" <M >N &&
62 rm -f A M &&
63 git update-index --add --remove A B M N &&
64 git commit -m "white renames A->B, M->N" &&
66 git checkout red &&
67 sed -e "/^g /s/.*/g : red changes a line/" <A >B &&
68 sed -e "/^G /s/.*/G : colored branch changes a line/" <M >N &&
69 rm -f A M &&
70 git update-index --add --remove A B M N &&
71 git commit -m "red renames A->B, M->N" &&
73 git checkout blue &&
74 sed -e "/^g /s/.*/g : blue changes a line/" <A >C &&
75 sed -e "/^G /s/.*/G : colored branch changes a line/" <M >N &&
76 rm -f A M &&
77 git update-index --add --remove A C M N &&
78 git commit -m "blue renames A->C, M->N" &&
80 git checkout master'
82 test_expect_success 'pull renaming branch into unrenaming one' \
84 git show-branch
85 git pull . white && {
86 echo "BAD: should have conflicted"
87 return 1
89 git ls-files -s
90 test "$(git ls-files -u B | wc -l)" -eq 3 || {
91 echo "BAD: should have left stages for B"
92 return 1
94 test "$(git ls-files -s N | wc -l)" -eq 1 || {
95 echo "BAD: should have merged N"
96 return 1
98 sed -ne "/^g/{
101 }" B | grep master || {
102 echo "BAD: should have listed our change first"
103 return 1
105 test "$(git diff white N | wc -l)" -eq 0 || {
106 echo "BAD: should have taken colored branch"
107 return 1
111 test_expect_success 'pull renaming branch into another renaming one' \
113 rm -f B
114 git reset --hard
115 git checkout red
116 git pull . white && {
117 echo "BAD: should have conflicted"
118 return 1
120 test "$(git ls-files -u B | wc -l)" -eq 3 || {
121 echo "BAD: should have left stages"
122 return 1
124 test "$(git ls-files -s N | wc -l)" -eq 1 || {
125 echo "BAD: should have merged N"
126 return 1
128 sed -ne "/^g/{
131 }" B | grep red || {
132 echo "BAD: should have listed our change first"
133 return 1
135 test "$(git diff white N | wc -l)" -eq 0 || {
136 echo "BAD: should have taken colored branch"
137 return 1
141 test_expect_success 'pull unrenaming branch into renaming one' \
143 git reset --hard
144 git show-branch
145 git pull . master && {
146 echo "BAD: should have conflicted"
147 return 1
149 test "$(git ls-files -u B | wc -l)" -eq 3 || {
150 echo "BAD: should have left stages"
151 return 1
153 test "$(git ls-files -s N | wc -l)" -eq 1 || {
154 echo "BAD: should have merged N"
155 return 1
157 sed -ne "/^g/{
160 }" B | grep red || {
161 echo "BAD: should have listed our change first"
162 return 1
164 test "$(git diff white N | wc -l)" -eq 0 || {
165 echo "BAD: should have taken colored branch"
166 return 1
170 test_expect_success 'pull conflicting renames' \
172 git reset --hard
173 git show-branch
174 git pull . blue && {
175 echo "BAD: should have conflicted"
176 return 1
178 test "$(git ls-files -u A | wc -l)" -eq 1 || {
179 echo "BAD: should have left a stage"
180 return 1
182 test "$(git ls-files -u B | wc -l)" -eq 1 || {
183 echo "BAD: should have left a stage"
184 return 1
186 test "$(git ls-files -u C | wc -l)" -eq 1 || {
187 echo "BAD: should have left a stage"
188 return 1
190 test "$(git ls-files -s N | wc -l)" -eq 1 || {
191 echo "BAD: should have merged N"
192 return 1
194 sed -ne "/^g/{
197 }" B | grep red || {
198 echo "BAD: should have listed our change first"
199 return 1
201 test "$(git diff white N | wc -l)" -eq 0 || {
202 echo "BAD: should have taken colored branch"
203 return 1
207 test_expect_success 'interference with untracked working tree file' '
209 git reset --hard
210 git show-branch
211 echo >A this file should not matter
212 git pull . white && {
213 echo "BAD: should have conflicted"
214 return 1
216 test -f A || {
217 echo "BAD: should have left A intact"
218 return 1
222 test_expect_success 'interference with untracked working tree file' '
224 git reset --hard
225 git checkout white
226 git show-branch
227 rm -f A
228 echo >A this file should not matter
229 git pull . red && {
230 echo "BAD: should have conflicted"
231 return 1
233 test -f A || {
234 echo "BAD: should have left A intact"
235 return 1
239 test_expect_success 'interference with untracked working tree file' '
241 git reset --hard
242 rm -f A M
243 git checkout -f master
244 git tag -f anchor
245 git show-branch
246 git pull . yellow || {
247 echo "BAD: should have cleanly merged"
248 return 1
250 test -f M && {
251 echo "BAD: should have removed M"
252 return 1
254 git reset --hard anchor
257 test_expect_success 'updated working tree file should prevent the merge' '
259 git reset --hard
260 rm -f A M
261 git checkout -f master
262 git tag -f anchor
263 git show-branch
264 echo >>M one line addition
265 cat M >M.saved
266 git pull . yellow && {
267 echo "BAD: should have complained"
268 return 1
270 diff M M.saved || {
271 echo "BAD: should have left M intact"
272 return 1
274 rm -f M.saved
277 test_expect_success 'updated working tree file should prevent the merge' '
279 git reset --hard
280 rm -f A M
281 git checkout -f master
282 git tag -f anchor
283 git show-branch
284 echo >>M one line addition
285 cat M >M.saved
286 git update-index M
287 git pull . yellow && {
288 echo "BAD: should have complained"
289 return 1
291 diff M M.saved || {
292 echo "BAD: should have left M intact"
293 return 1
295 rm -f M.saved
298 test_expect_success 'interference with untracked working tree file' '
300 git reset --hard
301 rm -f A M
302 git checkout -f yellow
303 git tag -f anchor
304 git show-branch
305 echo >M this file should not matter
306 git pull . master || {
307 echo "BAD: should have cleanly merged"
308 return 1
310 test -f M || {
311 echo "BAD: should have left M intact"
312 return 1
314 git ls-files -s | grep M && {
315 echo "BAD: M must be untracked in the result"
316 return 1
318 git reset --hard anchor
321 test_done