i18n: for-each-ref: mark parseopt strings for translation
[git/jnareb-git.git] / t / t3030-merge-recursive.sh
bloba5e3da7e419e6f13ea0960722b4c1c712a995112
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 &&
25 git branch submod &&
26 git branch copy &&
27 git branch rename &&
28 if test_have_prereq SYMLINKS
29 then
30 git branch rename-ln
31 fi &&
33 echo hello >>a &&
34 cp a d/e &&
35 o1=$(git hash-object a) &&
37 git add a d/e &&
39 test_tick &&
40 git commit -m "master modifies a and d/e" &&
41 c1=$(git rev-parse --verify HEAD) &&
42 ( git ls-tree -r HEAD ; git ls-files -s ) >actual &&
44 echo "100644 blob $o1 a"
45 echo "100644 blob $o0 b"
46 echo "100644 blob $o0 c"
47 echo "100644 blob $o1 d/e"
48 echo "100644 $o1 0 a"
49 echo "100644 $o0 0 b"
50 echo "100644 $o0 0 c"
51 echo "100644 $o1 0 d/e"
52 ) >expected &&
53 test_cmp expected actual
56 test_expect_success 'setup 2' '
58 rm -rf [abcd] &&
59 git checkout side &&
60 ( git ls-tree -r HEAD ; git ls-files -s ) >actual &&
62 echo "100644 blob $o0 a"
63 echo "100644 blob $o0 b"
64 echo "100644 blob $o0 c"
65 echo "100644 blob $o0 d/e"
66 echo "100644 $o0 0 a"
67 echo "100644 $o0 0 b"
68 echo "100644 $o0 0 c"
69 echo "100644 $o0 0 d/e"
70 ) >expected &&
71 test_cmp expected actual &&
73 echo goodbye >>a &&
74 o2=$(git hash-object a) &&
76 git add a &&
78 test_tick &&
79 git commit -m "side modifies a" &&
80 c2=$(git rev-parse --verify HEAD) &&
81 ( git ls-tree -r HEAD ; git ls-files -s ) >actual &&
83 echo "100644 blob $o2 a"
84 echo "100644 blob $o0 b"
85 echo "100644 blob $o0 c"
86 echo "100644 blob $o0 d/e"
87 echo "100644 $o2 0 a"
88 echo "100644 $o0 0 b"
89 echo "100644 $o0 0 c"
90 echo "100644 $o0 0 d/e"
91 ) >expected &&
92 test_cmp expected actual
95 test_expect_success 'setup 3' '
97 rm -rf [abcd] &&
98 git checkout df-1 &&
99 ( git ls-tree -r HEAD ; git ls-files -s ) >actual &&
101 echo "100644 blob $o0 a"
102 echo "100644 blob $o0 b"
103 echo "100644 blob $o0 c"
104 echo "100644 blob $o0 d/e"
105 echo "100644 $o0 0 a"
106 echo "100644 $o0 0 b"
107 echo "100644 $o0 0 c"
108 echo "100644 $o0 0 d/e"
109 ) >expected &&
110 test_cmp expected actual &&
112 rm -f b && mkdir b && echo df-1 >b/c && git add b/c &&
113 o3=$(git hash-object b/c) &&
115 test_tick &&
116 git commit -m "df-1 makes b/c" &&
117 c3=$(git rev-parse --verify HEAD) &&
118 ( git ls-tree -r HEAD ; git ls-files -s ) >actual &&
120 echo "100644 blob $o0 a"
121 echo "100644 blob $o3 b/c"
122 echo "100644 blob $o0 c"
123 echo "100644 blob $o0 d/e"
124 echo "100644 $o0 0 a"
125 echo "100644 $o3 0 b/c"
126 echo "100644 $o0 0 c"
127 echo "100644 $o0 0 d/e"
128 ) >expected &&
129 test_cmp expected actual
132 test_expect_success 'setup 4' '
134 rm -rf [abcd] &&
135 git checkout df-2 &&
136 ( git ls-tree -r HEAD ; git ls-files -s ) >actual &&
138 echo "100644 blob $o0 a"
139 echo "100644 blob $o0 b"
140 echo "100644 blob $o0 c"
141 echo "100644 blob $o0 d/e"
142 echo "100644 $o0 0 a"
143 echo "100644 $o0 0 b"
144 echo "100644 $o0 0 c"
145 echo "100644 $o0 0 d/e"
146 ) >expected &&
147 test_cmp expected actual &&
149 rm -f a && mkdir a && echo df-2 >a/c && git add a/c &&
150 o4=$(git hash-object a/c) &&
152 test_tick &&
153 git commit -m "df-2 makes a/c" &&
154 c4=$(git rev-parse --verify HEAD) &&
155 ( git ls-tree -r HEAD ; git ls-files -s ) >actual &&
157 echo "100644 blob $o4 a/c"
158 echo "100644 blob $o0 b"
159 echo "100644 blob $o0 c"
160 echo "100644 blob $o0 d/e"
161 echo "100644 $o4 0 a/c"
162 echo "100644 $o0 0 b"
163 echo "100644 $o0 0 c"
164 echo "100644 $o0 0 d/e"
165 ) >expected &&
166 test_cmp expected actual
169 test_expect_success 'setup 5' '
171 rm -rf [abcd] &&
172 git checkout remove &&
173 ( git ls-tree -r HEAD ; git ls-files -s ) >actual &&
175 echo "100644 blob $o0 a"
176 echo "100644 blob $o0 b"
177 echo "100644 blob $o0 c"
178 echo "100644 blob $o0 d/e"
179 echo "100644 $o0 0 a"
180 echo "100644 $o0 0 b"
181 echo "100644 $o0 0 c"
182 echo "100644 $o0 0 d/e"
183 ) >expected &&
184 test_cmp expected actual &&
186 rm -f b &&
187 echo remove-conflict >a &&
189 git add a &&
190 git rm b &&
191 o5=$(git hash-object a) &&
193 test_tick &&
194 git commit -m "remove removes b and modifies a" &&
195 c5=$(git rev-parse --verify HEAD) &&
196 ( git ls-tree -r HEAD ; git ls-files -s ) >actual &&
198 echo "100644 blob $o5 a"
199 echo "100644 blob $o0 c"
200 echo "100644 blob $o0 d/e"
201 echo "100644 $o5 0 a"
202 echo "100644 $o0 0 c"
203 echo "100644 $o0 0 d/e"
204 ) >expected &&
205 test_cmp expected actual
209 test_expect_success 'setup 6' '
211 rm -rf [abcd] &&
212 git checkout df-3 &&
213 ( git ls-tree -r HEAD ; git ls-files -s ) >actual &&
215 echo "100644 blob $o0 a"
216 echo "100644 blob $o0 b"
217 echo "100644 blob $o0 c"
218 echo "100644 blob $o0 d/e"
219 echo "100644 $o0 0 a"
220 echo "100644 $o0 0 b"
221 echo "100644 $o0 0 c"
222 echo "100644 $o0 0 d/e"
223 ) >expected &&
224 test_cmp expected actual &&
226 rm -fr d && echo df-3 >d && git add d &&
227 o6=$(git hash-object d) &&
229 test_tick &&
230 git commit -m "df-3 makes d" &&
231 c6=$(git rev-parse --verify HEAD) &&
232 ( git ls-tree -r HEAD ; git ls-files -s ) >actual &&
234 echo "100644 blob $o0 a"
235 echo "100644 blob $o0 b"
236 echo "100644 blob $o0 c"
237 echo "100644 blob $o6 d"
238 echo "100644 $o0 0 a"
239 echo "100644 $o0 0 b"
240 echo "100644 $o0 0 c"
241 echo "100644 $o6 0 d"
242 ) >expected &&
243 test_cmp expected actual
246 test_expect_success 'setup 7' '
248 git checkout submod &&
249 git rm d/e &&
250 test_tick &&
251 git commit -m "remove d/e" &&
252 git update-index --add --cacheinfo 160000 $c1 d &&
253 test_tick &&
254 git commit -m "make d/ a submodule"
257 test_expect_success 'setup 8' '
258 git checkout rename &&
259 git mv a e &&
260 git add e &&
261 test_tick &&
262 git commit -m "rename a->e" &&
263 if test_have_prereq SYMLINKS
264 then
265 git checkout rename-ln &&
266 git mv a e &&
267 ln -s e a &&
268 git add a e &&
269 test_tick &&
270 git commit -m "rename a->e, symlink a->e" &&
271 oln=`printf e | git hash-object --stdin`
275 test_expect_success 'setup 9' '
276 git checkout copy &&
277 cp a e &&
278 git add e &&
279 test_tick &&
280 git commit -m "copy a->e"
283 test_expect_success 'merge-recursive simple' '
285 rm -fr [abcd] &&
286 git checkout -f "$c2" &&
288 test_expect_code 1 git merge-recursive "$c0" -- "$c2" "$c1"
291 test_expect_success 'merge-recursive result' '
293 git ls-files -s >actual &&
295 echo "100644 $o0 1 a"
296 echo "100644 $o2 2 a"
297 echo "100644 $o1 3 a"
298 echo "100644 $o0 0 b"
299 echo "100644 $o0 0 c"
300 echo "100644 $o1 0 d/e"
301 ) >expected &&
302 test_cmp expected actual
306 test_expect_success 'fail if the index has unresolved entries' '
308 rm -fr [abcd] &&
309 git checkout -f "$c1" &&
311 test_must_fail git merge "$c5" &&
312 test_must_fail git merge "$c5" 2> out &&
313 test_i18ngrep "not possible because you have unmerged files" out &&
314 git add -u &&
315 test_must_fail git merge "$c5" 2> out &&
316 test_i18ngrep "You have not concluded your merge" out &&
317 rm -f .git/MERGE_HEAD &&
318 test_must_fail git merge "$c5" 2> out &&
319 test_i18ngrep "Your local changes to the following files would be overwritten by merge:" out
322 test_expect_success 'merge-recursive remove conflict' '
324 rm -fr [abcd] &&
325 git checkout -f "$c1" &&
327 test_expect_code 1 git merge-recursive "$c0" -- "$c1" "$c5"
330 test_expect_success 'merge-recursive remove conflict' '
332 git ls-files -s >actual &&
334 echo "100644 $o0 1 a"
335 echo "100644 $o1 2 a"
336 echo "100644 $o5 3 a"
337 echo "100644 $o0 0 c"
338 echo "100644 $o1 0 d/e"
339 ) >expected &&
340 test_cmp expected actual
344 test_expect_success 'merge-recursive d/f simple' '
345 rm -fr [abcd] &&
346 git reset --hard &&
347 git checkout -f "$c1" &&
349 git merge-recursive "$c0" -- "$c1" "$c3"
352 test_expect_success 'merge-recursive result' '
354 git ls-files -s >actual &&
356 echo "100644 $o1 0 a"
357 echo "100644 $o3 0 b/c"
358 echo "100644 $o0 0 c"
359 echo "100644 $o1 0 d/e"
360 ) >expected &&
361 test_cmp expected actual
365 test_expect_success 'merge-recursive d/f conflict' '
367 rm -fr [abcd] &&
368 git reset --hard &&
369 git checkout -f "$c1" &&
371 test_expect_code 1 git merge-recursive "$c0" -- "$c1" "$c4"
374 test_expect_success 'merge-recursive d/f conflict result' '
376 git ls-files -s >actual &&
378 echo "100644 $o0 1 a"
379 echo "100644 $o1 2 a"
380 echo "100644 $o4 0 a/c"
381 echo "100644 $o0 0 b"
382 echo "100644 $o0 0 c"
383 echo "100644 $o1 0 d/e"
384 ) >expected &&
385 test_cmp expected actual
389 test_expect_success 'merge-recursive d/f conflict the other way' '
391 rm -fr [abcd] &&
392 git reset --hard &&
393 git checkout -f "$c4" &&
395 test_expect_code 1 git merge-recursive "$c0" -- "$c4" "$c1"
398 test_expect_success 'merge-recursive d/f conflict result the other way' '
400 git ls-files -s >actual &&
402 echo "100644 $o0 1 a"
403 echo "100644 $o1 3 a"
404 echo "100644 $o4 0 a/c"
405 echo "100644 $o0 0 b"
406 echo "100644 $o0 0 c"
407 echo "100644 $o1 0 d/e"
408 ) >expected &&
409 test_cmp expected actual
413 test_expect_success 'merge-recursive d/f conflict' '
415 rm -fr [abcd] &&
416 git reset --hard &&
417 git checkout -f "$c1" &&
419 test_expect_code 1 git merge-recursive "$c0" -- "$c1" "$c6"
422 test_expect_success 'merge-recursive d/f conflict result' '
424 git ls-files -s >actual &&
426 echo "100644 $o1 0 a"
427 echo "100644 $o0 0 b"
428 echo "100644 $o0 0 c"
429 echo "100644 $o6 3 d"
430 echo "100644 $o0 1 d/e"
431 echo "100644 $o1 2 d/e"
432 ) >expected &&
433 test_cmp expected actual
437 test_expect_success 'merge-recursive d/f conflict' '
439 rm -fr [abcd] &&
440 git reset --hard &&
441 git checkout -f "$c6" &&
443 test_expect_code 1 git merge-recursive "$c0" -- "$c6" "$c1"
446 test_expect_success 'merge-recursive d/f conflict result' '
448 git ls-files -s >actual &&
450 echo "100644 $o1 0 a"
451 echo "100644 $o0 0 b"
452 echo "100644 $o0 0 c"
453 echo "100644 $o6 2 d"
454 echo "100644 $o0 1 d/e"
455 echo "100644 $o1 3 d/e"
456 ) >expected &&
457 test_cmp expected actual
461 test_expect_success 'reset and 3-way merge' '
463 git reset --hard "$c2" &&
464 git read-tree -m "$c0" "$c2" "$c1"
468 test_expect_success 'reset and bind merge' '
470 git reset --hard master &&
471 git read-tree --prefix=M/ master &&
472 git ls-files -s >actual &&
474 echo "100644 $o1 0 M/a"
475 echo "100644 $o0 0 M/b"
476 echo "100644 $o0 0 M/c"
477 echo "100644 $o1 0 M/d/e"
478 echo "100644 $o1 0 a"
479 echo "100644 $o0 0 b"
480 echo "100644 $o0 0 c"
481 echo "100644 $o1 0 d/e"
482 ) >expected &&
483 test_cmp expected actual &&
485 git read-tree --prefix=a1/ master &&
486 git ls-files -s >actual &&
488 echo "100644 $o1 0 M/a"
489 echo "100644 $o0 0 M/b"
490 echo "100644 $o0 0 M/c"
491 echo "100644 $o1 0 M/d/e"
492 echo "100644 $o1 0 a"
493 echo "100644 $o1 0 a1/a"
494 echo "100644 $o0 0 a1/b"
495 echo "100644 $o0 0 a1/c"
496 echo "100644 $o1 0 a1/d/e"
497 echo "100644 $o0 0 b"
498 echo "100644 $o0 0 c"
499 echo "100644 $o1 0 d/e"
500 ) >expected &&
501 test_cmp expected actual &&
503 git read-tree --prefix=z/ master &&
504 git ls-files -s >actual &&
506 echo "100644 $o1 0 M/a"
507 echo "100644 $o0 0 M/b"
508 echo "100644 $o0 0 M/c"
509 echo "100644 $o1 0 M/d/e"
510 echo "100644 $o1 0 a"
511 echo "100644 $o1 0 a1/a"
512 echo "100644 $o0 0 a1/b"
513 echo "100644 $o0 0 a1/c"
514 echo "100644 $o1 0 a1/d/e"
515 echo "100644 $o0 0 b"
516 echo "100644 $o0 0 c"
517 echo "100644 $o1 0 d/e"
518 echo "100644 $o1 0 z/a"
519 echo "100644 $o0 0 z/b"
520 echo "100644 $o0 0 z/c"
521 echo "100644 $o1 0 z/d/e"
522 ) >expected &&
523 test_cmp expected actual
527 test_expect_success 'merge removes empty directories' '
529 git reset --hard master &&
530 git checkout -b rm &&
531 git rm d/e &&
532 git commit -mremoved-d/e &&
533 git checkout master &&
534 git merge -s recursive rm &&
535 test_must_fail test -d d
538 test_expect_failure 'merge-recursive simple w/submodule' '
540 git checkout submod &&
541 git merge remove
544 test_expect_failure 'merge-recursive simple w/submodule result' '
546 git ls-files -s >actual &&
548 echo "100644 $o5 0 a"
549 echo "100644 $o0 0 c"
550 echo "160000 $c1 0 d"
551 ) >expected &&
552 test_cmp expected actual
555 test_expect_success 'merge-recursive copy vs. rename' '
556 git checkout -f copy &&
557 git merge rename &&
558 ( git ls-tree -r HEAD && git ls-files -s ) >actual &&
560 echo "100644 blob $o0 b"
561 echo "100644 blob $o0 c"
562 echo "100644 blob $o0 d/e"
563 echo "100644 blob $o0 e"
564 echo "100644 $o0 0 b"
565 echo "100644 $o0 0 c"
566 echo "100644 $o0 0 d/e"
567 echo "100644 $o0 0 e"
568 ) >expected &&
569 test_cmp expected actual
572 if test_have_prereq SYMLINKS
573 then
574 test_expect_failure 'merge-recursive rename vs. rename/symlink' '
576 git checkout -f rename &&
577 git merge rename-ln &&
578 ( git ls-tree -r HEAD ; git ls-files -s ) >actual &&
580 echo "120000 blob $oln a"
581 echo "100644 blob $o0 b"
582 echo "100644 blob $o0 c"
583 echo "100644 blob $o0 d/e"
584 echo "100644 blob $o0 e"
585 echo "120000 $oln 0 a"
586 echo "100644 $o0 0 b"
587 echo "100644 $o0 0 c"
588 echo "100644 $o0 0 d/e"
589 echo "100644 $o0 0 e"
590 ) >expected &&
591 test_cmp expected actual
596 test_done