config --get --path: check for unset $HOME
[git/mingw/4msysgit/kblees.git] / t / t3030-merge-recursive.sh
blob9929f82021deeb20358016b487400b80e27b596f
1 #!/bin/sh
3 test_description='merge-recursive backend test'
5 . ./test-lib.sh
7 test_expect_success 'setup 1' '
9 echo hello >a &&
10 o0=$(git hash-object a) &&
11 cp a b &&
12 cp a c &&
13 mkdir d &&
14 cp a d/e &&
16 test_tick &&
17 git add a b c d/e &&
18 git commit -m initial &&
19 c0=$(git rev-parse --verify HEAD) &&
20 git branch side &&
21 git branch df-1 &&
22 git branch df-2 &&
23 git branch df-3 &&
24 git branch remove &&
26 echo hello >>a &&
27 cp a d/e &&
28 o1=$(git hash-object a) &&
30 git add a d/e &&
32 test_tick &&
33 git commit -m "master modifies a and d/e" &&
34 c1=$(git rev-parse --verify HEAD) &&
35 ( git ls-tree -r HEAD ; git ls-files -s ) >actual &&
37 echo "100644 blob $o1 a"
38 echo "100644 blob $o0 b"
39 echo "100644 blob $o0 c"
40 echo "100644 blob $o1 d/e"
41 echo "100644 $o1 0 a"
42 echo "100644 $o0 0 b"
43 echo "100644 $o0 0 c"
44 echo "100644 $o1 0 d/e"
45 ) >expected &&
46 test_cmp expected actual
49 test_expect_success 'setup 2' '
51 rm -rf [abcd] &&
52 git checkout side &&
53 ( git ls-tree -r HEAD ; git ls-files -s ) >actual &&
55 echo "100644 blob $o0 a"
56 echo "100644 blob $o0 b"
57 echo "100644 blob $o0 c"
58 echo "100644 blob $o0 d/e"
59 echo "100644 $o0 0 a"
60 echo "100644 $o0 0 b"
61 echo "100644 $o0 0 c"
62 echo "100644 $o0 0 d/e"
63 ) >expected &&
64 test_cmp expected actual &&
66 echo goodbye >>a &&
67 o2=$(git hash-object a) &&
69 git add a &&
71 test_tick &&
72 git commit -m "side modifies a" &&
73 c2=$(git rev-parse --verify HEAD) &&
74 ( git ls-tree -r HEAD ; git ls-files -s ) >actual &&
76 echo "100644 blob $o2 a"
77 echo "100644 blob $o0 b"
78 echo "100644 blob $o0 c"
79 echo "100644 blob $o0 d/e"
80 echo "100644 $o2 0 a"
81 echo "100644 $o0 0 b"
82 echo "100644 $o0 0 c"
83 echo "100644 $o0 0 d/e"
84 ) >expected &&
85 test_cmp expected actual
88 test_expect_success 'setup 3' '
90 rm -rf [abcd] &&
91 git checkout df-1 &&
92 ( git ls-tree -r HEAD ; git ls-files -s ) >actual &&
94 echo "100644 blob $o0 a"
95 echo "100644 blob $o0 b"
96 echo "100644 blob $o0 c"
97 echo "100644 blob $o0 d/e"
98 echo "100644 $o0 0 a"
99 echo "100644 $o0 0 b"
100 echo "100644 $o0 0 c"
101 echo "100644 $o0 0 d/e"
102 ) >expected &&
103 test_cmp expected actual &&
105 rm -f b && mkdir b && echo df-1 >b/c && git add b/c &&
106 o3=$(git hash-object b/c) &&
108 test_tick &&
109 git commit -m "df-1 makes b/c" &&
110 c3=$(git rev-parse --verify HEAD) &&
111 ( git ls-tree -r HEAD ; git ls-files -s ) >actual &&
113 echo "100644 blob $o0 a"
114 echo "100644 blob $o3 b/c"
115 echo "100644 blob $o0 c"
116 echo "100644 blob $o0 d/e"
117 echo "100644 $o0 0 a"
118 echo "100644 $o3 0 b/c"
119 echo "100644 $o0 0 c"
120 echo "100644 $o0 0 d/e"
121 ) >expected &&
122 test_cmp expected actual
125 test_expect_success 'setup 4' '
127 rm -rf [abcd] &&
128 git checkout df-2 &&
129 ( git ls-tree -r HEAD ; git ls-files -s ) >actual &&
131 echo "100644 blob $o0 a"
132 echo "100644 blob $o0 b"
133 echo "100644 blob $o0 c"
134 echo "100644 blob $o0 d/e"
135 echo "100644 $o0 0 a"
136 echo "100644 $o0 0 b"
137 echo "100644 $o0 0 c"
138 echo "100644 $o0 0 d/e"
139 ) >expected &&
140 test_cmp expected actual &&
142 rm -f a && mkdir a && echo df-2 >a/c && git add a/c &&
143 o4=$(git hash-object a/c) &&
145 test_tick &&
146 git commit -m "df-2 makes a/c" &&
147 c4=$(git rev-parse --verify HEAD) &&
148 ( git ls-tree -r HEAD ; git ls-files -s ) >actual &&
150 echo "100644 blob $o4 a/c"
151 echo "100644 blob $o0 b"
152 echo "100644 blob $o0 c"
153 echo "100644 blob $o0 d/e"
154 echo "100644 $o4 0 a/c"
155 echo "100644 $o0 0 b"
156 echo "100644 $o0 0 c"
157 echo "100644 $o0 0 d/e"
158 ) >expected &&
159 test_cmp expected actual
162 test_expect_success 'setup 5' '
164 rm -rf [abcd] &&
165 git checkout remove &&
166 ( git ls-tree -r HEAD ; git ls-files -s ) >actual &&
168 echo "100644 blob $o0 a"
169 echo "100644 blob $o0 b"
170 echo "100644 blob $o0 c"
171 echo "100644 blob $o0 d/e"
172 echo "100644 $o0 0 a"
173 echo "100644 $o0 0 b"
174 echo "100644 $o0 0 c"
175 echo "100644 $o0 0 d/e"
176 ) >expected &&
177 test_cmp expected actual &&
179 rm -f b &&
180 echo remove-conflict >a &&
182 git add a &&
183 git rm b &&
184 o5=$(git hash-object a) &&
186 test_tick &&
187 git commit -m "remove removes b and modifies a" &&
188 c5=$(git rev-parse --verify HEAD) &&
189 ( git ls-tree -r HEAD ; git ls-files -s ) >actual &&
191 echo "100644 blob $o5 a"
192 echo "100644 blob $o0 c"
193 echo "100644 blob $o0 d/e"
194 echo "100644 $o5 0 a"
195 echo "100644 $o0 0 c"
196 echo "100644 $o0 0 d/e"
197 ) >expected &&
198 test_cmp expected actual
202 test_expect_success 'setup 6' '
204 rm -rf [abcd] &&
205 git checkout df-3 &&
206 ( git ls-tree -r HEAD ; git ls-files -s ) >actual &&
208 echo "100644 blob $o0 a"
209 echo "100644 blob $o0 b"
210 echo "100644 blob $o0 c"
211 echo "100644 blob $o0 d/e"
212 echo "100644 $o0 0 a"
213 echo "100644 $o0 0 b"
214 echo "100644 $o0 0 c"
215 echo "100644 $o0 0 d/e"
216 ) >expected &&
217 test_cmp expected actual &&
219 rm -fr d && echo df-3 >d && git add d &&
220 o6=$(git hash-object d) &&
222 test_tick &&
223 git commit -m "df-3 makes d" &&
224 c6=$(git rev-parse --verify HEAD) &&
225 ( git ls-tree -r HEAD ; git ls-files -s ) >actual &&
227 echo "100644 blob $o0 a"
228 echo "100644 blob $o0 b"
229 echo "100644 blob $o0 c"
230 echo "100644 blob $o6 d"
231 echo "100644 $o0 0 a"
232 echo "100644 $o0 0 b"
233 echo "100644 $o0 0 c"
234 echo "100644 $o6 0 d"
235 ) >expected &&
236 test_cmp expected actual
239 test_expect_success 'merge-recursive simple' '
241 rm -fr [abcd] &&
242 git checkout -f "$c2" &&
244 git merge-recursive "$c0" -- "$c2" "$c1"
245 status=$?
246 case "$status" in
248 : happy
251 echo >&2 "why status $status!!!"
252 false
254 esac
257 test_expect_success 'merge-recursive result' '
259 git ls-files -s >actual &&
261 echo "100644 $o0 1 a"
262 echo "100644 $o2 2 a"
263 echo "100644 $o1 3 a"
264 echo "100644 $o0 0 b"
265 echo "100644 $o0 0 c"
266 echo "100644 $o1 0 d/e"
267 ) >expected &&
268 test_cmp expected actual
272 test_expect_success 'fail if the index has unresolved entries' '
274 rm -fr [abcd] &&
275 git checkout -f "$c1" &&
277 test_must_fail git merge "$c5" &&
278 test_must_fail git merge "$c5" 2> out &&
279 grep "not possible because you have unmerged files" out &&
280 git add -u &&
281 test_must_fail git merge "$c5" 2> out &&
282 grep "You have not concluded your merge" out &&
283 rm -f .git/MERGE_HEAD &&
284 test_must_fail git merge "$c5" 2> out &&
285 grep "Your local changes to .* would be overwritten by merge." out
288 test_expect_success 'merge-recursive remove conflict' '
290 rm -fr [abcd] &&
291 git checkout -f "$c1" &&
293 git merge-recursive "$c0" -- "$c1" "$c5"
294 status=$?
295 case "$status" in
297 : happy
300 echo >&2 "why status $status!!!"
301 false
303 esac
306 test_expect_success 'merge-recursive remove conflict' '
308 git ls-files -s >actual &&
310 echo "100644 $o0 1 a"
311 echo "100644 $o1 2 a"
312 echo "100644 $o5 3 a"
313 echo "100644 $o0 0 c"
314 echo "100644 $o1 0 d/e"
315 ) >expected &&
316 test_cmp expected actual
320 test_expect_success 'merge-recursive d/f simple' '
321 rm -fr [abcd] &&
322 git reset --hard &&
323 git checkout -f "$c1" &&
325 git merge-recursive "$c0" -- "$c1" "$c3"
328 test_expect_success 'merge-recursive result' '
330 git ls-files -s >actual &&
332 echo "100644 $o1 0 a"
333 echo "100644 $o3 0 b/c"
334 echo "100644 $o0 0 c"
335 echo "100644 $o1 0 d/e"
336 ) >expected &&
337 test_cmp expected actual
341 test_expect_success 'merge-recursive d/f conflict' '
343 rm -fr [abcd] &&
344 git reset --hard &&
345 git checkout -f "$c1" &&
347 git merge-recursive "$c0" -- "$c1" "$c4"
348 status=$?
349 case "$status" in
351 : happy
354 echo >&2 "why status $status!!!"
355 false
357 esac
360 test_expect_success 'merge-recursive d/f conflict result' '
362 git ls-files -s >actual &&
364 echo "100644 $o0 1 a"
365 echo "100644 $o1 2 a"
366 echo "100644 $o4 0 a/c"
367 echo "100644 $o0 0 b"
368 echo "100644 $o0 0 c"
369 echo "100644 $o1 0 d/e"
370 ) >expected &&
371 test_cmp expected actual
375 test_expect_success 'merge-recursive d/f conflict the other way' '
377 rm -fr [abcd] &&
378 git reset --hard &&
379 git checkout -f "$c4" &&
381 git merge-recursive "$c0" -- "$c4" "$c1"
382 status=$?
383 case "$status" in
385 : happy
388 echo >&2 "why status $status!!!"
389 false
391 esac
394 test_expect_success 'merge-recursive d/f conflict result the other way' '
396 git ls-files -s >actual &&
398 echo "100644 $o0 1 a"
399 echo "100644 $o1 3 a"
400 echo "100644 $o4 0 a/c"
401 echo "100644 $o0 0 b"
402 echo "100644 $o0 0 c"
403 echo "100644 $o1 0 d/e"
404 ) >expected &&
405 test_cmp expected actual
409 test_expect_success 'merge-recursive d/f conflict' '
411 rm -fr [abcd] &&
412 git reset --hard &&
413 git checkout -f "$c1" &&
415 git merge-recursive "$c0" -- "$c1" "$c6"
416 status=$?
417 case "$status" in
419 : happy
422 echo >&2 "why status $status!!!"
423 false
425 esac
428 test_expect_success 'merge-recursive d/f conflict result' '
430 git ls-files -s >actual &&
432 echo "100644 $o1 0 a"
433 echo "100644 $o0 0 b"
434 echo "100644 $o0 0 c"
435 echo "100644 $o6 3 d"
436 echo "100644 $o0 1 d/e"
437 echo "100644 $o1 2 d/e"
438 ) >expected &&
439 test_cmp expected actual
443 test_expect_success 'merge-recursive d/f conflict' '
445 rm -fr [abcd] &&
446 git reset --hard &&
447 git checkout -f "$c6" &&
449 git merge-recursive "$c0" -- "$c6" "$c1"
450 status=$?
451 case "$status" in
453 : happy
456 echo >&2 "why status $status!!!"
457 false
459 esac
462 test_expect_success 'merge-recursive d/f conflict result' '
464 git ls-files -s >actual &&
466 echo "100644 $o1 0 a"
467 echo "100644 $o0 0 b"
468 echo "100644 $o0 0 c"
469 echo "100644 $o6 2 d"
470 echo "100644 $o0 1 d/e"
471 echo "100644 $o1 3 d/e"
472 ) >expected &&
473 test_cmp expected actual
477 test_expect_success 'reset and 3-way merge' '
479 git reset --hard "$c2" &&
480 git read-tree -m "$c0" "$c2" "$c1"
484 test_expect_success 'reset and bind merge' '
486 git reset --hard master &&
487 git read-tree --prefix=M/ master &&
488 git ls-files -s >actual &&
490 echo "100644 $o1 0 M/a"
491 echo "100644 $o0 0 M/b"
492 echo "100644 $o0 0 M/c"
493 echo "100644 $o1 0 M/d/e"
494 echo "100644 $o1 0 a"
495 echo "100644 $o0 0 b"
496 echo "100644 $o0 0 c"
497 echo "100644 $o1 0 d/e"
498 ) >expected &&
499 test_cmp expected actual &&
501 git read-tree --prefix=a1/ master &&
502 git ls-files -s >actual &&
504 echo "100644 $o1 0 M/a"
505 echo "100644 $o0 0 M/b"
506 echo "100644 $o0 0 M/c"
507 echo "100644 $o1 0 M/d/e"
508 echo "100644 $o1 0 a"
509 echo "100644 $o1 0 a1/a"
510 echo "100644 $o0 0 a1/b"
511 echo "100644 $o0 0 a1/c"
512 echo "100644 $o1 0 a1/d/e"
513 echo "100644 $o0 0 b"
514 echo "100644 $o0 0 c"
515 echo "100644 $o1 0 d/e"
516 ) >expected &&
517 test_cmp expected actual
519 git read-tree --prefix=z/ master &&
520 git ls-files -s >actual &&
522 echo "100644 $o1 0 M/a"
523 echo "100644 $o0 0 M/b"
524 echo "100644 $o0 0 M/c"
525 echo "100644 $o1 0 M/d/e"
526 echo "100644 $o1 0 a"
527 echo "100644 $o1 0 a1/a"
528 echo "100644 $o0 0 a1/b"
529 echo "100644 $o0 0 a1/c"
530 echo "100644 $o1 0 a1/d/e"
531 echo "100644 $o0 0 b"
532 echo "100644 $o0 0 c"
533 echo "100644 $o1 0 d/e"
534 echo "100644 $o1 0 z/a"
535 echo "100644 $o0 0 z/b"
536 echo "100644 $o0 0 z/c"
537 echo "100644 $o1 0 z/d/e"
538 ) >expected &&
539 test_cmp expected actual
543 test_expect_success 'merge removes empty directories' '
545 git reset --hard master &&
546 git checkout -b rm &&
547 git rm d/e &&
548 git commit -mremoved-d/e &&
549 git checkout master &&
550 git merge -s recursive rm &&
551 test_must_fail test -d d
554 test_done