3 # Copyright (c) 2008 Charles Bailey
6 test_description='git mergetool
8 Testing basic merge tool invocation'
12 # All the mergetool test work by checking out a temporary branch based
13 # off 'branch1' and then merging in master and checking the results of
16 test_expect_success 'setup' '
17 test_config rerere.enabled true &&
19 echo master spaced >"spaced name" &&
20 echo master file11 >file11 &&
21 echo master file12 >file12 &&
22 echo master file13 >file13 &&
23 echo master file14 >file14 &&
25 echo master sub >subdir/file3 &&
26 test_create_repo submod &&
31 git commit -m "Add foo"
33 git submodule add git://example.com/submod submod &&
34 git add file1 "spaced name" file1[1-4] subdir/file3 .gitmodules submod &&
35 git commit -m "add initial versions" &&
37 git checkout -b branch1 master &&
38 git submodule update -N &&
39 echo branch1 change >file1 &&
40 echo branch1 newfile >file2 &&
41 echo branch1 spaced >"spaced name" &&
42 echo branch1 both added >both &&
43 echo branch1 change file11 >file11 &&
44 echo branch1 change file13 >file13 &&
45 echo branch1 sub >subdir/file3 &&
48 echo branch1 submodule >bar &&
50 git commit -m "Add bar on branch1" &&
51 git checkout -b submod-branch1
53 git add file1 "spaced name" file11 file13 file2 subdir/file3 submod &&
56 git commit -m "branch1 changes" &&
58 git checkout -b delete-base branch1 &&
60 test_write_lines one two 3 4 >a/a/file.txt &&
61 git add a/a/file.txt &&
62 git commit -m"base file" &&
63 git checkout -b move-to-b delete-base &&
65 git mv a/a/file.txt b/b/file.txt &&
66 test_write_lines one two 4 >b/b/file.txt &&
67 git commit -a -m"move to b" &&
68 git checkout -b move-to-c delete-base &&
70 git mv a/a/file.txt c/c/file.txt &&
71 test_write_lines one two 3 >c/c/file.txt &&
72 git commit -a -m"move to c" &&
74 git checkout -b stash1 master &&
75 echo stash1 change file11 >file11 &&
77 git commit -m "stash1 changes" &&
79 git checkout -b stash2 master &&
80 echo stash2 change file11 >file11 &&
82 git commit -m "stash2 changes" &&
84 git checkout master &&
85 git submodule update -N &&
86 echo master updated >file1 &&
87 echo master new >file2 &&
88 echo master updated spaced >"spaced name" &&
89 echo master both added >both &&
90 echo master updated file12 >file12 &&
91 echo master updated file14 >file14 &&
92 echo master new sub >subdir/file3 &&
95 echo master submodule >bar &&
97 git commit -m "Add bar on master" &&
98 git checkout -b submod-master
100 git add file1 "spaced name" file12 file14 file2 subdir/file3 submod &&
103 git commit -m "master updates" &&
106 git checkout -b order-file-start master &&
110 git commit -m start &&
111 git checkout -b order-file-side1 order-file-start &&
115 git commit -m side1 &&
116 git checkout -b order-file-side2 order-file-start &&
120 git commit -m side2 &&
122 git config merge.tool mytool &&
123 git config mergetool.mytool.cmd "cat \"\$REMOTE\" >\"\$MERGED\"" &&
124 git config mergetool.mytool.trustExitCode true &&
125 git config mergetool.mybase.cmd "cat \"\$BASE\" >\"\$MERGED\"" &&
126 git config mergetool.mybase.trustExitCode true
129 test_expect_success 'custom mergetool' '
130 test_when_finished "git reset --hard" &&
131 git checkout -b test$test_count branch1 &&
132 git submodule update -N &&
133 test_must_fail git merge master &&
134 yes "" | git mergetool both &&
135 yes "" | git mergetool file1 file1 &&
136 yes "" | git mergetool file2 "spaced name" &&
137 yes "" | git mergetool subdir/file3 &&
138 yes "d" | git mergetool file11 &&
139 yes "d" | git mergetool file12 &&
140 yes "l" | git mergetool submod &&
141 echo "master updated" >expect &&
142 test_cmp expect file1 &&
143 echo "master new" >expect &&
144 test_cmp expect file2 &&
145 echo "master new sub" >expect &&
146 test_cmp expect subdir/file3 &&
147 echo "branch1 submodule" >expect &&
148 test_cmp expect submod/bar &&
149 git commit -m "branch1 resolved with mergetool"
152 test_expect_success 'gui mergetool' '
153 test_config merge.guitool myguitool &&
154 test_config mergetool.myguitool.cmd "(printf \"gui \" && cat \"\$REMOTE\") >\"\$MERGED\"" &&
155 test_config mergetool.myguitool.trustExitCode true &&
156 test_when_finished "git reset --hard" &&
157 git checkout -b test$test_count branch1 &&
158 git submodule update -N &&
159 test_must_fail git merge master &&
160 yes "" | git mergetool --gui both &&
161 yes "" | git mergetool -g file1 file1 &&
162 yes "" | git mergetool --gui file2 "spaced name" &&
163 yes "" | git mergetool --gui subdir/file3 &&
164 yes "d" | git mergetool --gui file11 &&
165 yes "d" | git mergetool --gui file12 &&
166 yes "l" | git mergetool --gui submod &&
167 echo "gui master updated" >expect &&
168 test_cmp expect file1 &&
169 echo "gui master new" >expect &&
170 test_cmp expect file2 &&
171 echo "gui master new sub" >expect &&
172 test_cmp expect subdir/file3 &&
173 echo "branch1 submodule" >expect &&
174 test_cmp expect submod/bar &&
175 git commit -m "branch1 resolved with mergetool"
178 test_expect_success 'gui mergetool without merge.guitool set falls back to merge.tool' '
179 test_when_finished "git reset --hard" &&
180 git checkout -b test$test_count branch1 &&
181 git submodule update -N &&
182 test_must_fail git merge master &&
183 yes "" | git mergetool --gui both &&
184 yes "" | git mergetool -g file1 file1 &&
185 yes "" | git mergetool --gui file2 "spaced name" &&
186 yes "" | git mergetool --gui subdir/file3 &&
187 yes "d" | git mergetool --gui file11 &&
188 yes "d" | git mergetool --gui file12 &&
189 yes "l" | git mergetool --gui submod &&
190 echo "master updated" >expect &&
191 test_cmp expect file1 &&
192 echo "master new" >expect &&
193 test_cmp expect file2 &&
194 echo "master new sub" >expect &&
195 test_cmp expect subdir/file3 &&
196 echo "branch1 submodule" >expect &&
197 test_cmp expect submod/bar &&
198 git commit -m "branch1 resolved with mergetool"
201 test_expect_success 'mergetool crlf' '
202 test_when_finished "git reset --hard" &&
203 # This test_config line must go after the above reset line so that
204 # core.autocrlf is unconfigured before reset runs. (The
205 # test_config command uses test_when_finished internally and
206 # test_when_finished is LIFO.)
207 test_config core.autocrlf true &&
208 git checkout -b test$test_count branch1 &&
209 test_must_fail git merge master &&
210 yes "" | git mergetool file1 &&
211 yes "" | git mergetool file2 &&
212 yes "" | git mergetool "spaced name" &&
213 yes "" | git mergetool both &&
214 yes "" | git mergetool subdir/file3 &&
215 yes "d" | git mergetool file11 &&
216 yes "d" | git mergetool file12 &&
217 yes "r" | git mergetool submod &&
218 test "$(printf x | cat file1 -)" = "$(printf "master updated\r\nx")" &&
219 test "$(printf x | cat file2 -)" = "$(printf "master new\r\nx")" &&
220 test "$(printf x | cat subdir/file3 -)" = "$(printf "master new sub\r\nx")" &&
221 git submodule update -N &&
222 echo "master submodule" >expect &&
223 test_cmp expect submod/bar &&
224 git commit -m "branch1 resolved with mergetool - autocrlf"
227 test_expect_success 'mergetool in subdir' '
228 test_when_finished "git reset --hard" &&
229 git checkout -b test$test_count branch1 &&
230 git submodule update -N &&
233 test_must_fail git merge master &&
234 yes "" | git mergetool file3 &&
235 echo "master new sub" >expect &&
236 test_cmp expect file3
240 test_expect_success 'mergetool on file in parent dir' '
241 test_when_finished "git reset --hard" &&
242 git checkout -b test$test_count branch1 &&
243 git submodule update -N &&
246 test_must_fail git merge master &&
247 yes "" | git mergetool file3 &&
248 yes "" | git mergetool ../file1 &&
249 yes "" | git mergetool ../file2 ../spaced\ name &&
250 yes "" | git mergetool ../both &&
251 yes "d" | git mergetool ../file11 &&
252 yes "d" | git mergetool ../file12 &&
253 yes "l" | git mergetool ../submod &&
254 echo "master updated" >expect &&
255 test_cmp expect ../file1 &&
256 echo "master new" >expect &&
257 test_cmp expect ../file2 &&
258 echo "branch1 submodule" >expect &&
259 test_cmp expect ../submod/bar &&
260 git commit -m "branch1 resolved with mergetool - subdir"
264 test_expect_success 'mergetool skips autoresolved' '
265 test_when_finished "git reset --hard" &&
266 git checkout -b test$test_count branch1 &&
267 git submodule update -N &&
268 test_must_fail git merge master &&
269 test -n "$(git ls-files -u)" &&
270 yes "d" | git mergetool file11 &&
271 yes "d" | git mergetool file12 &&
272 yes "l" | git mergetool submod &&
273 output="$(git mergetool --no-prompt)" &&
274 test "$output" = "No files need merging"
277 test_expect_success 'mergetool merges all from subdir (rerere disabled)' '
278 test_when_finished "git reset --hard" &&
279 git checkout -b test$test_count branch1 &&
280 test_config rerere.enabled false &&
283 test_must_fail git merge master &&
284 yes "r" | git mergetool ../submod &&
285 yes "d" "d" | git mergetool --no-prompt &&
286 echo "master updated" >expect &&
287 test_cmp expect ../file1 &&
288 echo "master new" >expect &&
289 test_cmp expect ../file2 &&
290 echo "master new sub" >expect &&
291 test_cmp expect file3 &&
292 ( cd .. && git submodule update -N ) &&
293 echo "master submodule" >expect &&
294 test_cmp expect ../submod/bar &&
295 git commit -m "branch2 resolved by mergetool from subdir"
299 test_expect_success 'mergetool merges all from subdir (rerere enabled)' '
300 test_when_finished "git reset --hard" &&
301 git checkout -b test$test_count branch1 &&
302 test_config rerere.enabled true &&
303 rm -rf .git/rr-cache &&
306 test_must_fail git merge master &&
307 yes "r" | git mergetool ../submod &&
308 yes "d" "d" | git mergetool --no-prompt &&
309 echo "master updated" >expect &&
310 test_cmp expect ../file1 &&
311 echo "master new" >expect &&
312 test_cmp expect ../file2 &&
313 echo "master new sub" >expect &&
314 test_cmp expect file3 &&
315 ( cd .. && git submodule update -N ) &&
316 echo "master submodule" >expect &&
317 test_cmp expect ../submod/bar &&
318 git commit -m "branch2 resolved by mergetool from subdir"
322 test_expect_success 'mergetool skips resolved paths when rerere is active' '
323 test_when_finished "git reset --hard" &&
324 test_config rerere.enabled true &&
325 rm -rf .git/rr-cache &&
326 git checkout -b test$test_count branch1 &&
327 git submodule update -N &&
328 test_must_fail git merge master &&
329 yes "l" | git mergetool --no-prompt submod &&
330 yes "d" "d" | git mergetool --no-prompt &&
331 git submodule update -N &&
332 output="$(yes "n" | git mergetool --no-prompt)" &&
333 test "$output" = "No files need merging"
336 test_expect_success 'conflicted stash sets up rerere' '
337 test_when_finished "git reset --hard" &&
338 test_config rerere.enabled true &&
339 git checkout stash1 &&
340 echo "Conflicting stash content" >file11 &&
343 git checkout --detach stash2 &&
344 test_must_fail git stash apply &&
346 test -n "$(git ls-files -u)" &&
347 conflicts="$(git rerere remaining)" &&
348 test "$conflicts" = "file11" &&
349 output="$(git mergetool --no-prompt)" &&
350 test "$output" != "No files need merging" &&
352 git commit -am "save the stash resolution" &&
354 git reset --hard stash2 &&
355 test_must_fail git stash apply &&
357 test -n "$(git ls-files -u)" &&
358 conflicts="$(git rerere remaining)" &&
359 test -z "$conflicts" &&
360 output="$(git mergetool --no-prompt)" &&
361 test "$output" = "No files need merging"
364 test_expect_success 'mergetool takes partial path' '
365 test_when_finished "git reset --hard" &&
366 test_config rerere.enabled false &&
367 git checkout -b test$test_count branch1 &&
368 git submodule update -N &&
369 test_must_fail git merge master &&
371 yes "" | git mergetool subdir &&
373 echo "master new sub" >expect &&
374 test_cmp expect subdir/file3
377 test_expect_success 'mergetool delete/delete conflict' '
378 test_when_finished "git reset --hard" &&
379 git checkout -b test$test_count move-to-c &&
380 test_must_fail git merge move-to-b &&
381 echo d | git mergetool a/a/file.txt &&
382 ! test -f a/a/file.txt &&
384 test_must_fail git merge move-to-b &&
385 echo m | git mergetool a/a/file.txt &&
386 test -f b/b/file.txt &&
388 test_must_fail git merge move-to-b &&
389 ! echo a | git mergetool a/a/file.txt &&
390 ! test -f a/a/file.txt
393 test_expect_success 'mergetool produces no errors when keepBackup is used' '
394 test_when_finished "git reset --hard" &&
395 git checkout -b test$test_count move-to-c &&
396 test_config mergetool.keepBackup true &&
397 test_must_fail git merge move-to-b &&
398 echo d | git mergetool a/a/file.txt 2>actual &&
399 test_must_be_empty actual &&
403 test_expect_success 'mergetool honors tempfile config for deleted files' '
404 test_when_finished "git reset --hard" &&
405 git checkout -b test$test_count move-to-c &&
406 test_config mergetool.keepTemporaries false &&
407 test_must_fail git merge move-to-b &&
408 echo d | git mergetool a/a/file.txt &&
412 test_expect_success 'mergetool keeps tempfiles when aborting delete/delete' '
413 test_when_finished "git reset --hard" &&
414 test_when_finished "git clean -fdx" &&
415 git checkout -b test$test_count move-to-c &&
416 test_config mergetool.keepTemporaries true &&
417 test_must_fail git merge move-to-b &&
418 ! test_write_lines a n | git mergetool a/a/file.txt &&
420 cat >expect <<-\EOF &&
425 ls -1 a/a | sed -e "s/[0-9]*//g" >actual &&
426 test_cmp expect actual
429 test_expect_success 'deleted vs modified submodule' '
430 test_when_finished "git reset --hard" &&
431 git checkout -b test$test_count branch1 &&
432 git submodule update -N &&
433 mv submod submod-movedaside &&
434 git rm --cached submod &&
435 git commit -m "Submodule deleted from branch" &&
436 git checkout -b test$test_count.a test$test_count &&
437 test_must_fail git merge master &&
438 test -n "$(git ls-files -u)" &&
439 yes "" | git mergetool file1 file2 spaced\ name subdir/file3 &&
440 yes "" | git mergetool both &&
441 yes "d" | git mergetool file11 file12 &&
442 yes "r" | git mergetool submod &&
443 rmdir submod && mv submod-movedaside submod &&
444 echo "branch1 submodule" >expect &&
445 test_cmp expect submod/bar &&
446 git submodule update -N &&
447 echo "master submodule" >expect &&
448 test_cmp expect submod/bar &&
449 output="$(git mergetool --no-prompt)" &&
450 test "$output" = "No files need merging" &&
451 git commit -m "Merge resolved by keeping module" &&
453 mv submod submod-movedaside &&
454 git checkout -b test$test_count.b test$test_count &&
455 git submodule update -N &&
456 test_must_fail git merge master &&
457 test -n "$(git ls-files -u)" &&
458 yes "" | git mergetool file1 file2 spaced\ name subdir/file3 &&
459 yes "" | git mergetool both &&
460 yes "d" | git mergetool file11 file12 &&
461 yes "l" | git mergetool submod &&
463 output="$(git mergetool --no-prompt)" &&
464 test "$output" = "No files need merging" &&
465 git commit -m "Merge resolved by deleting module" &&
467 mv submod-movedaside submod &&
468 git checkout -b test$test_count.c master &&
469 git submodule update -N &&
470 test_must_fail git merge test$test_count &&
471 test -n "$(git ls-files -u)" &&
472 yes "" | git mergetool file1 file2 spaced\ name subdir/file3 &&
473 yes "" | git mergetool both &&
474 yes "d" | git mergetool file11 file12 &&
475 yes "r" | git mergetool submod &&
477 test -d submod.orig &&
478 git submodule update -N &&
479 output="$(git mergetool --no-prompt)" &&
480 test "$output" = "No files need merging" &&
481 git commit -m "Merge resolved by deleting module" &&
482 mv submod.orig submod &&
484 git checkout -b test$test_count.d master &&
485 git submodule update -N &&
486 test_must_fail git merge test$test_count &&
487 test -n "$(git ls-files -u)" &&
488 yes "" | git mergetool file1 file2 spaced\ name subdir/file3 &&
489 yes "" | git mergetool both &&
490 yes "d" | git mergetool file11 file12 &&
491 yes "l" | git mergetool submod &&
492 echo "master submodule" >expect &&
493 test_cmp expect submod/bar &&
494 git submodule update -N &&
495 echo "master submodule" >expect &&
496 test_cmp expect submod/bar &&
497 output="$(git mergetool --no-prompt)" &&
498 test "$output" = "No files need merging" &&
499 git commit -m "Merge resolved by keeping module"
502 test_expect_success 'file vs modified submodule' '
503 test_when_finished "git reset --hard" &&
504 git checkout -b test$test_count branch1 &&
505 git submodule update -N &&
506 mv submod submod-movedaside &&
507 git rm --cached submod &&
508 echo not a submodule >submod &&
510 git commit -m "Submodule path becomes file" &&
511 git checkout -b test$test_count.a branch1 &&
512 test_must_fail git merge master &&
513 test -n "$(git ls-files -u)" &&
514 yes "" | git mergetool file1 file2 spaced\ name subdir/file3 &&
515 yes "" | git mergetool both &&
516 yes "d" | git mergetool file11 file12 &&
517 yes "r" | git mergetool submod &&
518 rmdir submod && mv submod-movedaside submod &&
519 echo "branch1 submodule" >expect &&
520 test_cmp expect submod/bar &&
521 git submodule update -N &&
522 echo "master submodule" >expect &&
523 test_cmp expect submod/bar &&
524 output="$(git mergetool --no-prompt)" &&
525 test "$output" = "No files need merging" &&
526 git commit -m "Merge resolved by keeping module" &&
528 mv submod submod-movedaside &&
529 git checkout -b test$test_count.b test$test_count &&
530 test_must_fail git merge master &&
531 test -n "$(git ls-files -u)" &&
532 yes "" | git mergetool file1 file2 spaced\ name subdir/file3 &&
533 yes "" | git mergetool both &&
534 yes "d" | git mergetool file11 file12 &&
535 if test "$GIT_TEST_MERGE_ALGORITHM" = ort
537 yes "c" | git mergetool submod~HEAD &&
539 git mv submod~HEAD submod
541 yes "l" | git mergetool submod
543 git submodule update -N &&
544 echo "not a submodule" >expect &&
545 test_cmp expect submod &&
546 output="$(git mergetool --no-prompt)" &&
547 test "$output" = "No files need merging" &&
548 git commit -m "Merge resolved by keeping file" &&
550 git checkout -b test$test_count.c master &&
551 rmdir submod && mv submod-movedaside submod &&
552 test ! -e submod.orig &&
553 git submodule update -N &&
554 test_must_fail git merge test$test_count &&
555 test -n "$(git ls-files -u)" &&
556 yes "" | git mergetool file1 file2 spaced\ name subdir/file3 &&
557 yes "" | git mergetool both &&
558 yes "d" | git mergetool file11 file12 &&
559 if test "$GIT_TEST_MERGE_ALGORITHM" = ort
561 mv submod submod.orig &&
562 git rm --cached submod &&
563 yes "c" | git mergetool submod~test19 &&
564 git mv submod~test19 submod
566 yes "r" | git mergetool submod
568 test -d submod.orig &&
569 git submodule update -N &&
570 echo "not a submodule" >expect &&
571 test_cmp expect submod &&
572 output="$(git mergetool --no-prompt)" &&
573 test "$output" = "No files need merging" &&
574 git commit -m "Merge resolved by keeping file" &&
576 git checkout -b test$test_count.d master &&
577 rmdir submod && mv submod.orig submod &&
578 git submodule update -N &&
579 test_must_fail git merge test$test_count &&
580 test -n "$(git ls-files -u)" &&
581 yes "" | git mergetool file1 file2 spaced\ name subdir/file3 &&
582 yes "" | git mergetool both &&
583 yes "d" | git mergetool file11 file12 &&
584 yes "l" | git mergetool submod &&
585 if test "$GIT_TEST_MERGE_ALGORITHM" = ort
587 yes "d" | git mergetool submod~test19
589 echo "master submodule" >expect &&
590 test_cmp expect submod/bar &&
591 git submodule update -N &&
592 echo "master submodule" >expect &&
593 test_cmp expect submod/bar &&
594 output="$(git mergetool --no-prompt)" &&
595 test "$output" = "No files need merging" &&
596 git commit -m "Merge resolved by keeping module"
599 test_expect_success 'submodule in subdirectory' '
600 test_when_finished "git reset --hard" &&
601 git checkout -b test$test_count branch1 &&
602 git submodule update -N &&
605 test_create_repo subdir_module &&
610 git commit -m "add initial versions"
613 test_when_finished "rm -rf subdir/subdir_module" &&
614 git submodule add git://example.com/subsubmodule subdir/subdir_module &&
615 git add subdir/subdir_module &&
616 git commit -m "add submodule in subdirectory" &&
618 git checkout -b test$test_count.a test$test_count &&
619 git submodule update -N &&
621 cd subdir/subdir_module &&
622 git checkout -b super10.a &&
623 echo test$test_count.a >file15 &&
625 git commit -m "on branch 10.a"
627 git add subdir/subdir_module &&
628 git commit -m "change submodule in subdirectory on test$test_count.a" &&
630 git checkout -b test$test_count.b test$test_count &&
631 git submodule update -N &&
633 cd subdir/subdir_module &&
634 git checkout -b super10.b &&
635 echo test$test_count.b >file15 &&
637 git commit -m "on branch 10.b"
639 git add subdir/subdir_module &&
640 git commit -m "change submodule in subdirectory on test$test_count.b" &&
642 test_must_fail git merge test$test_count.a &&
645 yes "l" | git mergetool subdir_module
647 echo "test$test_count.b" >expect &&
648 test_cmp expect subdir/subdir_module/file15 &&
649 git submodule update -N &&
650 echo "test$test_count.b" >expect &&
651 test_cmp expect subdir/subdir_module/file15 &&
653 git submodule update -N &&
655 test_must_fail git merge test$test_count.a &&
656 yes "r" | git mergetool subdir/subdir_module &&
657 echo "test$test_count.b" >expect &&
658 test_cmp expect subdir/subdir_module/file15 &&
659 git submodule update -N &&
660 echo "test$test_count.a" >expect &&
661 test_cmp expect subdir/subdir_module/file15 &&
662 git commit -m "branch1 resolved with mergetool"
665 test_expect_success 'directory vs modified submodule' '
666 test_when_finished "git reset --hard" &&
667 git checkout -b test$test_count branch1 &&
668 mv submod submod-movedaside &&
669 git rm --cached submod &&
671 echo not a submodule >submod/file16 &&
672 git add submod/file16 &&
673 git commit -m "Submodule path becomes directory" &&
675 test_must_fail git merge master &&
676 test -n "$(git ls-files -u)" &&
677 yes "l" | git mergetool submod &&
678 echo "not a submodule" >expect &&
679 test_cmp expect submod/file16 &&
680 rm -rf submod.orig &&
683 test_must_fail git merge master &&
684 test -n "$(git ls-files -u)" &&
685 test ! -e submod.orig &&
686 if test "$GIT_TEST_MERGE_ALGORITHM" = ort
688 yes "r" | git mergetool submod~master &&
689 git mv submod submod.orig &&
690 git mv submod~master submod
692 yes "r" | git mergetool submod
694 test -d submod.orig &&
695 echo "not a submodule" >expect &&
696 test_cmp expect submod.orig/file16 &&
698 mv submod-movedaside/.git submod &&
699 ( cd submod && git clean -f && git reset --hard ) &&
700 git submodule update -N &&
701 echo "master submodule" >expect &&
702 test_cmp expect submod/bar &&
704 rm -rf submod-movedaside &&
706 git checkout -b test$test_count.c master &&
707 git submodule update -N &&
708 test_must_fail git merge test$test_count &&
709 test -n "$(git ls-files -u)" &&
710 yes "l" | git mergetool submod &&
711 git submodule update -N &&
712 echo "master submodule" >expect &&
713 test_cmp expect submod/bar &&
716 git submodule update -N &&
717 test_must_fail git merge test$test_count &&
718 test -n "$(git ls-files -u)" &&
719 test ! -e submod.orig &&
720 yes "r" | git mergetool submod &&
721 echo "not a submodule" >expect &&
722 test_cmp expect submod/file16 &&
724 git reset --hard master &&
725 ( cd submod && git clean -f && git reset --hard ) &&
726 git submodule update -N
729 test_expect_success 'file with no base' '
730 test_when_finished "git reset --hard" &&
731 git checkout -b test$test_count branch1 &&
732 test_must_fail git merge master &&
733 git mergetool --no-prompt --tool mybase -- both &&
734 test_must_be_empty both
737 test_expect_success 'custom commands override built-ins' '
738 test_when_finished "git reset --hard" &&
739 git checkout -b test$test_count branch1 &&
740 test_config mergetool.defaults.cmd "cat \"\$REMOTE\" >\"\$MERGED\"" &&
741 test_config mergetool.defaults.trustExitCode true &&
742 test_must_fail git merge master &&
743 git mergetool --no-prompt --tool defaults -- both &&
744 echo master both added >expected &&
745 test_cmp expected both
748 test_expect_success 'filenames seen by tools start with ./' '
749 test_when_finished "git reset --hard" &&
750 git checkout -b test$test_count branch1 &&
751 test_config mergetool.writeToTemp false &&
752 test_config mergetool.myecho.cmd "echo \"\$LOCAL\"" &&
753 test_config mergetool.myecho.trustExitCode true &&
754 test_must_fail git merge master &&
755 git mergetool --no-prompt --tool myecho -- both >actual &&
756 grep ^\./both_LOCAL_ actual
759 test_lazy_prereq MKTEMP '
760 tempdir=$(mktemp -d -t foo.XXXXXX) &&
761 test -d "$tempdir" &&
765 test_expect_success MKTEMP 'temporary filenames are used with mergetool.writeToTemp' '
766 test_when_finished "git reset --hard" &&
767 git checkout -b test$test_count branch1 &&
768 test_config mergetool.writeToTemp true &&
769 test_config mergetool.myecho.cmd "echo \"\$LOCAL\"" &&
770 test_config mergetool.myecho.trustExitCode true &&
771 test_must_fail git merge master &&
772 git mergetool --no-prompt --tool myecho -- both >actual &&
773 ! grep ^\./both_LOCAL_ actual &&
774 grep /both_LOCAL_ actual
777 test_expect_success 'diff.orderFile configuration is honored' '
778 test_when_finished "git reset --hard" &&
779 git checkout -b test$test_count order-file-side2 &&
780 test_config diff.orderFile order-file &&
781 test_config mergetool.myecho.cmd "echo \"\$LOCAL\"" &&
782 test_config mergetool.myecho.trustExitCode true &&
783 echo b >order-file &&
784 echo a >>order-file &&
785 test_must_fail git merge order-file-side1 &&
786 cat >expect <<-\EOF &&
792 # make sure "order-file" that is ambiguous between
793 # rev and path is understood correctly.
794 git branch order-file HEAD &&
796 git mergetool --no-prompt --tool myecho >output &&
797 git grep --no-index -h -A2 Merging: output >actual &&
798 test_cmp expect actual
800 test_expect_success 'mergetool -Oorder-file is honored' '
801 test_when_finished "git reset --hard" &&
802 git checkout -b test$test_count order-file-side2 &&
803 test_config diff.orderFile order-file &&
804 test_config mergetool.myecho.cmd "echo \"\$LOCAL\"" &&
805 test_config mergetool.myecho.trustExitCode true &&
806 echo b >order-file &&
807 echo a >>order-file &&
808 test_must_fail git merge order-file-side1 &&
809 cat >expect <<-\EOF &&
814 git mergetool -O/dev/null --no-prompt --tool myecho >output &&
815 git grep --no-index -h -A2 Merging: output >actual &&
816 test_cmp expect actual &&
819 git config --unset diff.orderFile &&
820 test_must_fail git merge order-file-side1 &&
821 cat >expect <<-\EOF &&
826 git mergetool -Oorder-file --no-prompt --tool myecho >output &&
827 git grep --no-index -h -A2 Merging: output >actual &&
828 test_cmp expect actual
831 test_expect_success 'mergetool --tool-help shows recognized tools' '
832 # Check a few known tools are correctly shown
833 git mergetool --tool-help >mergetools &&
834 grep vimdiff mergetools &&
835 grep vimdiff3 mergetools &&
836 grep gvimdiff2 mergetools &&
837 grep araxis mergetools &&
838 grep xxdiff mergetools &&