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 (echo one; echo two; echo 3; echo 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 (echo one; echo two; echo 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 (echo one; echo two; echo 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 >/dev/null 2>&1 &&
134 ( yes "" | git mergetool both >/dev/null 2>&1 ) &&
135 ( yes "" | git mergetool file1 file1 ) &&
136 ( yes "" | git mergetool file2 "spaced name" >/dev/null 2>&1 ) &&
137 ( yes "" | git mergetool subdir/file3 >/dev/null 2>&1 ) &&
138 ( yes "d" | git mergetool file11 >/dev/null 2>&1 ) &&
139 ( yes "d" | git mergetool file12 >/dev/null 2>&1 ) &&
140 ( yes "l" | git mergetool submod >/dev/null 2>&1 ) &&
141 test "$(cat file1)" = "master updated" &&
142 test "$(cat file2)" = "master new" &&
143 test "$(cat subdir/file3)" = "master new sub" &&
144 test "$(cat submod/bar)" = "branch1 submodule" &&
145 git commit -m "branch1 resolved with mergetool"
148 test_expect_success
'mergetool crlf' '
149 test_when_finished "git reset --hard" &&
150 # This test_config line must go after the above reset line so that
151 # core.autocrlf is unconfigured before reset runs. (The
152 # test_config command uses test_when_finished internally and
153 # test_when_finished is LIFO.)
154 test_config core.autocrlf true &&
155 git checkout -b test$test_count branch1 &&
156 test_must_fail git merge master >/dev/null 2>&1 &&
157 ( yes "" | git mergetool file1 >/dev/null 2>&1 ) &&
158 ( yes "" | git mergetool file2 >/dev/null 2>&1 ) &&
159 ( yes "" | git mergetool "spaced name" >/dev/null 2>&1 ) &&
160 ( yes "" | git mergetool both >/dev/null 2>&1 ) &&
161 ( yes "" | git mergetool subdir/file3 >/dev/null 2>&1 ) &&
162 ( yes "d" | git mergetool file11 >/dev/null 2>&1 ) &&
163 ( yes "d" | git mergetool file12 >/dev/null 2>&1 ) &&
164 ( yes "r" | git mergetool submod >/dev/null 2>&1 ) &&
165 test "$(printf x | cat file1 -)" = "$(printf "master updated\r\nx")" &&
166 test "$(printf x | cat file2 -)" = "$(printf "master new\r\nx")" &&
167 test "$(printf x | cat subdir/file3 -)" = "$(printf "master new sub\r\nx")" &&
168 git submodule update -N &&
169 test "$(cat submod/bar)" = "master submodule" &&
170 git commit -m "branch1 resolved with mergetool - autocrlf"
173 test_expect_success
'mergetool in subdir' '
174 test_when_finished "git reset --hard" &&
175 git checkout -b test$test_count branch1 &&
176 git submodule update -N &&
179 test_must_fail git merge master >/dev/null 2>&1 &&
180 ( yes "" | git mergetool file3 >/dev/null 2>&1 ) &&
181 test "$(cat file3)" = "master new sub"
185 test_expect_success
'mergetool on file in parent dir' '
186 test_when_finished "git reset --hard" &&
187 git checkout -b test$test_count branch1 &&
188 git submodule update -N &&
191 test_must_fail git merge master >/dev/null 2>&1 &&
192 ( yes "" | git mergetool file3 >/dev/null 2>&1 ) &&
193 ( yes "" | git mergetool ../file1 >/dev/null 2>&1 ) &&
194 ( yes "" | git mergetool ../file2 ../spaced\ name >/dev/null 2>&1 ) &&
195 ( yes "" | git mergetool ../both >/dev/null 2>&1 ) &&
196 ( yes "d" | git mergetool ../file11 >/dev/null 2>&1 ) &&
197 ( yes "d" | git mergetool ../file12 >/dev/null 2>&1 ) &&
198 ( yes "l" | git mergetool ../submod >/dev/null 2>&1 ) &&
199 test "$(cat ../file1)" = "master updated" &&
200 test "$(cat ../file2)" = "master new" &&
201 test "$(cat ../submod/bar)" = "branch1 submodule" &&
202 git commit -m "branch1 resolved with mergetool - subdir"
206 test_expect_success
'mergetool skips autoresolved' '
207 test_when_finished "git reset --hard" &&
208 git checkout -b test$test_count branch1 &&
209 git submodule update -N &&
210 test_must_fail git merge master &&
211 test -n "$(git ls-files -u)" &&
212 ( yes "d" | git mergetool file11 >/dev/null 2>&1 ) &&
213 ( yes "d" | git mergetool file12 >/dev/null 2>&1 ) &&
214 ( yes "l" | git mergetool submod >/dev/null 2>&1 ) &&
215 output="$(git mergetool --no-prompt)" &&
216 test "$output" = "No files need merging"
219 test_expect_success
'mergetool merges all from subdir (rerere disabled)' '
220 test_when_finished "git reset --hard" &&
221 git checkout -b test$test_count branch1 &&
222 test_config rerere.enabled false &&
225 test_must_fail git merge master &&
226 ( yes "r" | git mergetool ../submod ) &&
227 ( yes "d" "d" | git mergetool --no-prompt ) &&
228 test "$(cat ../file1)" = "master updated" &&
229 test "$(cat ../file2)" = "master new" &&
230 test "$(cat file3)" = "master new sub" &&
231 ( cd .. && git submodule update -N ) &&
232 test "$(cat ../submod/bar)" = "master submodule" &&
233 git commit -m "branch2 resolved by mergetool from subdir"
237 test_expect_success
'mergetool merges all from subdir (rerere enabled)' '
238 test_when_finished "git reset --hard" &&
239 git checkout -b test$test_count branch1 &&
240 test_config rerere.enabled true &&
241 rm -rf .git/rr-cache &&
244 test_must_fail git merge master &&
245 ( yes "r" | git mergetool ../submod ) &&
246 ( yes "d" "d" | git mergetool --no-prompt ) &&
247 test "$(cat ../file1)" = "master updated" &&
248 test "$(cat ../file2)" = "master new" &&
249 test "$(cat file3)" = "master new sub" &&
250 ( cd .. && git submodule update -N ) &&
251 test "$(cat ../submod/bar)" = "master submodule" &&
252 git commit -m "branch2 resolved by mergetool from subdir"
256 test_expect_success
'mergetool skips resolved paths when rerere is active' '
257 test_when_finished "git reset --hard" &&
258 test_config rerere.enabled true &&
259 rm -rf .git/rr-cache &&
260 git checkout -b test$test_count branch1 &&
261 git submodule update -N &&
262 test_must_fail git merge master >/dev/null 2>&1 &&
263 ( yes "l" | git mergetool --no-prompt submod >/dev/null 2>&1 ) &&
264 ( yes "d" "d" | git mergetool --no-prompt >/dev/null 2>&1 ) &&
265 git submodule update -N &&
266 output="$(yes "n" | git mergetool --no-prompt)" &&
267 test "$output" = "No files need merging"
270 test_expect_success
'conflicted stash sets up rerere' '
271 test_when_finished "git reset --hard" &&
272 test_config rerere.enabled true &&
273 git checkout stash1 &&
274 echo "Conflicting stash content" >file11 &&
277 git checkout --detach stash2 &&
278 test_must_fail git stash apply &&
280 test -n "$(git ls-files -u)" &&
281 conflicts="$(git rerere remaining)" &&
282 test "$conflicts" = "file11" &&
283 output="$(git mergetool --no-prompt)" &&
284 test "$output" != "No files need merging" &&
286 git commit -am "save the stash resolution" &&
288 git reset --hard stash2 &&
289 test_must_fail git stash apply &&
291 test -n "$(git ls-files -u)" &&
292 conflicts="$(git rerere remaining)" &&
293 test -z "$conflicts" &&
294 output="$(git mergetool --no-prompt)" &&
295 test "$output" = "No files need merging"
298 test_expect_success
'mergetool takes partial path' '
299 test_when_finished "git reset --hard" &&
300 test_config rerere.enabled false &&
301 git checkout -b test$test_count branch1 &&
302 git submodule update -N &&
303 test_must_fail git merge master &&
305 ( yes "" | git mergetool subdir ) &&
307 test "$(cat subdir/file3)" = "master new sub"
310 test_expect_success
'mergetool delete/delete conflict' '
311 test_when_finished "git reset --hard" &&
312 git checkout -b test$test_count move-to-c &&
313 test_must_fail git merge move-to-b &&
314 echo d | git mergetool a/a/file.txt &&
315 ! test -f a/a/file.txt &&
317 test_must_fail git merge move-to-b &&
318 echo m | git mergetool a/a/file.txt &&
319 test -f b/b/file.txt &&
321 test_must_fail git merge move-to-b &&
322 ! echo a | git mergetool a/a/file.txt &&
323 ! test -f a/a/file.txt
326 test_expect_success
'mergetool produces no errors when keepBackup is used' '
327 test_when_finished "git reset --hard" &&
328 git checkout -b test$test_count move-to-c &&
329 test_config mergetool.keepBackup true &&
330 test_must_fail git merge move-to-b &&
332 echo d | git mergetool a/a/file.txt 2>actual &&
333 test_cmp expect actual &&
337 test_expect_success
'mergetool honors tempfile config for deleted files' '
338 test_when_finished "git reset --hard" &&
339 git checkout -b test$test_count move-to-c &&
340 test_config mergetool.keepTemporaries false &&
341 test_must_fail git merge move-to-b &&
342 echo d | git mergetool a/a/file.txt &&
346 test_expect_success
'mergetool keeps tempfiles when aborting delete/delete' '
347 test_when_finished "git reset --hard" &&
348 test_when_finished "git clean -fdx" &&
349 git checkout -b test$test_count move-to-c &&
350 test_config mergetool.keepTemporaries true &&
351 test_must_fail git merge move-to-b &&
352 ! (echo a; echo n) | git mergetool a/a/file.txt &&
354 cat >expect <<-\EOF &&
359 ls -1 a/a | sed -e "s/[0-9]*//g" >actual &&
360 test_cmp expect actual
363 test_expect_success
'deleted vs modified submodule' '
364 test_when_finished "git reset --hard" &&
365 git checkout -b test$test_count branch1 &&
366 git submodule update -N &&
367 mv submod submod-movedaside &&
368 git rm --cached submod &&
369 git commit -m "Submodule deleted from branch" &&
370 git checkout -b test$test_count.a test$test_count &&
371 test_must_fail git merge master &&
372 test -n "$(git ls-files -u)" &&
373 ( yes "" | git mergetool file1 file2 spaced\ name subdir/file3 >/dev/null 2>&1 ) &&
374 ( yes "" | git mergetool both >/dev/null 2>&1 ) &&
375 ( yes "d" | git mergetool file11 file12 >/dev/null 2>&1 ) &&
376 ( yes "r" | git mergetool submod ) &&
377 rmdir submod && mv submod-movedaside submod &&
378 test "$(cat submod/bar)" = "branch1 submodule" &&
379 git submodule update -N &&
380 test "$(cat submod/bar)" = "master submodule" &&
381 output="$(git mergetool --no-prompt)" &&
382 test "$output" = "No files need merging" &&
383 git commit -m "Merge resolved by keeping module" &&
385 mv submod submod-movedaside &&
386 git checkout -b test$test_count.b test$test_count &&
387 git submodule update -N &&
388 test_must_fail git merge master &&
389 test -n "$(git ls-files -u)" &&
390 ( yes "" | git mergetool file1 file2 spaced\ name subdir/file3 >/dev/null 2>&1 ) &&
391 ( yes "" | git mergetool both >/dev/null 2>&1 ) &&
392 ( yes "d" | git mergetool file11 file12 >/dev/null 2>&1 ) &&
393 ( yes "l" | git mergetool submod ) &&
395 output="$(git mergetool --no-prompt)" &&
396 test "$output" = "No files need merging" &&
397 git commit -m "Merge resolved by deleting module" &&
399 mv submod-movedaside submod &&
400 git checkout -b test$test_count.c master &&
401 git submodule update -N &&
402 test_must_fail git merge test$test_count &&
403 test -n "$(git ls-files -u)" &&
404 ( yes "" | git mergetool file1 file2 spaced\ name subdir/file3 >/dev/null 2>&1 ) &&
405 ( yes "" | git mergetool both >/dev/null 2>&1 ) &&
406 ( yes "d" | git mergetool file11 file12 >/dev/null 2>&1 ) &&
407 ( yes "r" | git mergetool submod ) &&
409 test -d submod.orig &&
410 git submodule update -N &&
411 output="$(git mergetool --no-prompt)" &&
412 test "$output" = "No files need merging" &&
413 git commit -m "Merge resolved by deleting module" &&
414 mv submod.orig submod &&
416 git checkout -b test$test_count.d master &&
417 git submodule update -N &&
418 test_must_fail git merge test$test_count &&
419 test -n "$(git ls-files -u)" &&
420 ( yes "" | git mergetool file1 file2 spaced\ name subdir/file3 >/dev/null 2>&1 ) &&
421 ( yes "" | git mergetool both >/dev/null 2>&1 ) &&
422 ( yes "d" | git mergetool file11 file12 >/dev/null 2>&1 ) &&
423 ( yes "l" | git mergetool submod ) &&
424 test "$(cat submod/bar)" = "master submodule" &&
425 git submodule update -N &&
426 test "$(cat submod/bar)" = "master submodule" &&
427 output="$(git mergetool --no-prompt)" &&
428 test "$output" = "No files need merging" &&
429 git commit -m "Merge resolved by keeping module"
432 test_expect_success
'file vs modified submodule' '
433 test_when_finished "git reset --hard" &&
434 git checkout -b test$test_count branch1 &&
435 git submodule update -N &&
436 mv submod submod-movedaside &&
437 git rm --cached submod &&
438 echo not a submodule >submod &&
440 git commit -m "Submodule path becomes file" &&
441 git checkout -b test$test_count.a branch1 &&
442 test_must_fail git merge master &&
443 test -n "$(git ls-files -u)" &&
444 ( yes "" | git mergetool file1 file2 spaced\ name subdir/file3 >/dev/null 2>&1 ) &&
445 ( yes "" | git mergetool both >/dev/null 2>&1 ) &&
446 ( yes "d" | git mergetool file11 file12 >/dev/null 2>&1 ) &&
447 ( yes "r" | git mergetool submod ) &&
448 rmdir submod && mv submod-movedaside submod &&
449 test "$(cat submod/bar)" = "branch1 submodule" &&
450 git submodule update -N &&
451 test "$(cat submod/bar)" = "master submodule" &&
452 output="$(git mergetool --no-prompt)" &&
453 test "$output" = "No files need merging" &&
454 git commit -m "Merge resolved by keeping module" &&
456 mv submod submod-movedaside &&
457 git checkout -b test$test_count.b test$test_count &&
458 test_must_fail git merge master &&
459 test -n "$(git ls-files -u)" &&
460 ( yes "" | git mergetool file1 file2 spaced\ name subdir/file3 >/dev/null 2>&1 ) &&
461 ( yes "" | git mergetool both >/dev/null 2>&1 ) &&
462 ( yes "d" | git mergetool file11 file12 >/dev/null 2>&1 ) &&
463 ( yes "l" | git mergetool submod ) &&
464 git submodule update -N &&
465 test "$(cat submod)" = "not a submodule" &&
466 output="$(git mergetool --no-prompt)" &&
467 test "$output" = "No files need merging" &&
468 git commit -m "Merge resolved by keeping file" &&
470 git checkout -b test$test_count.c master &&
471 rmdir submod && mv submod-movedaside submod &&
472 test ! -e submod.orig &&
473 git submodule update -N &&
474 test_must_fail git merge test$test_count &&
475 test -n "$(git ls-files -u)" &&
476 ( yes "" | git mergetool file1 file2 spaced\ name subdir/file3 >/dev/null 2>&1 ) &&
477 ( yes "" | git mergetool both >/dev/null 2>&1 ) &&
478 ( yes "d" | git mergetool file11 file12 >/dev/null 2>&1 ) &&
479 ( yes "r" | git mergetool submod ) &&
480 test -d submod.orig &&
481 git submodule update -N &&
482 test "$(cat submod)" = "not a submodule" &&
483 output="$(git mergetool --no-prompt)" &&
484 test "$output" = "No files need merging" &&
485 git commit -m "Merge resolved by keeping file" &&
487 git checkout -b test$test_count.d master &&
488 rmdir submod && mv submod.orig submod &&
489 git submodule update -N &&
490 test_must_fail git merge test$test_count &&
491 test -n "$(git ls-files -u)" &&
492 ( yes "" | git mergetool file1 file2 spaced\ name subdir/file3 >/dev/null 2>&1 ) &&
493 ( yes "" | git mergetool both>/dev/null 2>&1 ) &&
494 ( yes "d" | git mergetool file11 file12 >/dev/null 2>&1 ) &&
495 ( yes "l" | git mergetool submod ) &&
496 test "$(cat submod/bar)" = "master submodule" &&
497 git submodule update -N &&
498 test "$(cat submod/bar)" = "master submodule" &&
499 output="$(git mergetool --no-prompt)" &&
500 test "$output" = "No files need merging" &&
501 git commit -m "Merge resolved by keeping module"
504 test_expect_success
'submodule in subdirectory' '
505 test_when_finished "git reset --hard" &&
506 git checkout -b test$test_count branch1 &&
507 git submodule update -N &&
510 test_create_repo subdir_module &&
515 git commit -m "add initial versions"
518 test_when_finished "rm -rf subdir/subdir_module" &&
519 git submodule add git://example.com/subsubmodule subdir/subdir_module &&
520 git add subdir/subdir_module &&
521 git commit -m "add submodule in subdirectory" &&
523 git checkout -b test$test_count.a test$test_count &&
524 git submodule update -N &&
526 cd subdir/subdir_module &&
527 git checkout -b super10.a &&
528 echo test$test_count.a >file15 &&
530 git commit -m "on branch 10.a"
532 git add subdir/subdir_module &&
533 git commit -m "change submodule in subdirectory on test$test_count.a" &&
535 git checkout -b test$test_count.b test$test_count &&
536 git submodule update -N &&
538 cd subdir/subdir_module &&
539 git checkout -b super10.b &&
540 echo test$test_count.b >file15 &&
542 git commit -m "on branch 10.b"
544 git add subdir/subdir_module &&
545 git commit -m "change submodule in subdirectory on test$test_count.b" &&
547 test_must_fail git merge test$test_count.a >/dev/null 2>&1 &&
550 ( yes "l" | git mergetool subdir_module )
552 test "$(cat subdir/subdir_module/file15)" = "test$test_count.b" &&
553 git submodule update -N &&
554 test "$(cat subdir/subdir_module/file15)" = "test$test_count.b" &&
556 git submodule update -N &&
558 test_must_fail git merge test$test_count.a >/dev/null 2>&1 &&
559 ( yes "r" | git mergetool subdir/subdir_module ) &&
560 test "$(cat subdir/subdir_module/file15)" = "test$test_count.b" &&
561 git submodule update -N &&
562 test "$(cat subdir/subdir_module/file15)" = "test$test_count.a" &&
563 git commit -m "branch1 resolved with mergetool"
566 test_expect_success
'directory vs modified submodule' '
567 test_when_finished "git reset --hard" &&
568 git checkout -b test$test_count branch1 &&
569 mv submod submod-movedaside &&
570 git rm --cached submod &&
572 echo not a submodule >submod/file16 &&
573 git add submod/file16 &&
574 git commit -m "Submodule path becomes directory" &&
576 test_must_fail git merge master &&
577 test -n "$(git ls-files -u)" &&
578 ( yes "l" | git mergetool submod ) &&
579 test "$(cat submod/file16)" = "not a submodule" &&
580 rm -rf submod.orig &&
583 test_must_fail git merge master &&
584 test -n "$(git ls-files -u)" &&
585 test ! -e submod.orig &&
586 ( yes "r" | git mergetool submod ) &&
587 test -d submod.orig &&
588 test "$(cat submod.orig/file16)" = "not a submodule" &&
590 mv submod-movedaside/.git submod &&
591 ( cd submod && git clean -f && git reset --hard ) &&
592 git submodule update -N &&
593 test "$(cat submod/bar)" = "master submodule" &&
595 rm -rf submod-movedaside &&
597 git checkout -b test$test_count.c master &&
598 git submodule update -N &&
599 test_must_fail git merge test$test_count &&
600 test -n "$(git ls-files -u)" &&
601 ( yes "l" | git mergetool submod ) &&
602 git submodule update -N &&
603 test "$(cat submod/bar)" = "master submodule" &&
606 git submodule update -N &&
607 test_must_fail git merge test$test_count &&
608 test -n "$(git ls-files -u)" &&
609 test ! -e submod.orig &&
610 ( yes "r" | git mergetool submod ) &&
611 test "$(cat submod/file16)" = "not a submodule" &&
613 git reset --hard master &&
614 ( cd submod && git clean -f && git reset --hard ) &&
615 git submodule update -N
618 test_expect_success
'file with no base' '
619 test_when_finished "git reset --hard" &&
620 git checkout -b test$test_count branch1 &&
621 test_must_fail git merge master &&
622 git mergetool --no-prompt --tool mybase -- both &&
623 test_must_be_empty both
626 test_expect_success
'custom commands override built-ins' '
627 test_when_finished "git reset --hard" &&
628 git checkout -b test$test_count branch1 &&
629 test_config mergetool.defaults.cmd "cat \"\$REMOTE\" >\"\$MERGED\"" &&
630 test_config mergetool.defaults.trustExitCode true &&
631 test_must_fail git merge master &&
632 git mergetool --no-prompt --tool defaults -- both &&
633 echo master both added >expected &&
634 test_cmp expected both
637 test_expect_success
'filenames seen by tools start with ./' '
638 test_when_finished "git reset --hard" &&
639 git checkout -b test$test_count branch1 &&
640 test_config mergetool.writeToTemp false &&
641 test_config mergetool.myecho.cmd "echo \"\$LOCAL\"" &&
642 test_config mergetool.myecho.trustExitCode true &&
643 test_must_fail git merge master &&
644 git mergetool --no-prompt --tool myecho -- both >actual &&
645 grep ^\./both_LOCAL_ actual >/dev/null
648 test_lazy_prereq MKTEMP
'
649 tempdir=$(mktemp -d -t foo.XXXXXX) &&
650 test -d "$tempdir" &&
654 test_expect_success MKTEMP
'temporary filenames are used with mergetool.writeToTemp' '
655 test_when_finished "git reset --hard" &&
656 git checkout -b test$test_count branch1 &&
657 test_config mergetool.writeToTemp true &&
658 test_config mergetool.myecho.cmd "echo \"\$LOCAL\"" &&
659 test_config mergetool.myecho.trustExitCode true &&
660 test_must_fail git merge master &&
661 git mergetool --no-prompt --tool myecho -- both >actual &&
662 ! grep ^\./both_LOCAL_ actual >/dev/null &&
663 grep /both_LOCAL_ actual >/dev/null
666 test_expect_success
'diff.orderFile configuration is honored' '
667 test_when_finished "git reset --hard" &&
668 git checkout -b test$test_count order-file-side2 &&
669 test_config diff.orderFile order-file &&
670 test_config mergetool.myecho.cmd "echo \"\$LOCAL\"" &&
671 test_config mergetool.myecho.trustExitCode true &&
672 echo b >order-file &&
673 echo a >>order-file &&
674 test_must_fail git merge order-file-side1 &&
675 cat >expect <<-\EOF &&
681 # make sure "order-file" that is ambiguous between
682 # rev and path is understood correctly.
683 git branch order-file HEAD &&
685 git mergetool --no-prompt --tool myecho >output &&
686 git grep --no-index -h -A2 Merging: output >actual &&
687 test_cmp expect actual
689 test_expect_success
'mergetool -Oorder-file is honored' '
690 test_when_finished "git reset --hard" &&
691 git checkout -b test$test_count order-file-side2 &&
692 test_config diff.orderFile order-file &&
693 test_config mergetool.myecho.cmd "echo \"\$LOCAL\"" &&
694 test_config mergetool.myecho.trustExitCode true &&
695 echo b >order-file &&
696 echo a >>order-file &&
697 test_must_fail git merge order-file-side1 &&
698 cat >expect <<-\EOF &&
703 git mergetool -O/dev/null --no-prompt --tool myecho >output &&
704 git grep --no-index -h -A2 Merging: output >actual &&
705 test_cmp expect actual &&
708 git config --unset diff.orderFile &&
709 test_must_fail git merge order-file-side1 &&
710 cat >expect <<-\EOF &&
715 git mergetool -Oorder-file --no-prompt --tool myecho >output &&
716 git grep --no-index -h -A2 Merging: output >actual &&
717 test_cmp expect actual