t7610: move setup code to the 'setup' test case
[alt-git.git] / t / t7610-mergetool.sh
blob6a284814bc9b7202c33a1b60200c7e8a4e66039d
1 #!/bin/sh
3 # Copyright (c) 2008 Charles Bailey
6 test_description='git mergetool
8 Testing basic merge tool invocation'
10 . ./test-lib.sh
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
14 # running mergetool
16 test_expect_success 'setup' '
17 test_config rerere.enabled true &&
18 echo master >file1 &&
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 &&
24 mkdir subdir &&
25 echo master sub >subdir/file3 &&
26 test_create_repo submod &&
28 cd submod &&
29 : >foo &&
30 git add foo &&
31 git commit -m "Add foo"
32 ) &&
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 &&
47 cd submod &&
48 echo branch1 submodule >bar &&
49 git add bar &&
50 git commit -m "Add bar on branch1" &&
51 git checkout -b submod-branch1
52 ) &&
53 git add file1 "spaced name" file11 file13 file2 subdir/file3 submod &&
54 git add both &&
55 git rm file12 &&
56 git commit -m "branch1 changes" &&
58 git checkout -b delete-base branch1 &&
59 mkdir -p a/a &&
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 &&
64 mkdir -p b/b &&
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 &&
69 mkdir -p c/c &&
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 &&
76 git add file11 &&
77 git commit -m "stash1 changes" &&
79 git checkout -b stash2 master &&
80 echo stash2 change file11 >file11 &&
81 git add 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 &&
94 cd submod &&
95 echo master submodule >bar &&
96 git add bar &&
97 git commit -m "Add bar on master" &&
98 git checkout -b submod-master
99 ) &&
100 git add file1 "spaced name" file12 file14 file2 subdir/file3 submod &&
101 git add both &&
102 git rm file11 &&
103 git commit -m "master updates" &&
105 git clean -fdx &&
106 git checkout -b order-file-start master &&
107 echo start >a &&
108 echo start >b &&
109 git add a b &&
110 git commit -m start &&
111 git checkout -b order-file-side1 order-file-start &&
112 echo side1 >a &&
113 echo side1 >b &&
114 git add a b &&
115 git commit -m side1 &&
116 git checkout -b order-file-side2 order-file-start &&
117 echo side2 >a &&
118 echo side2 >b &&
119 git add a b &&
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 git checkout -b test$test_count branch1 &&
131 git submodule update -N &&
132 test_must_fail git merge master >/dev/null 2>&1 &&
133 ( yes "" | git mergetool both >/dev/null 2>&1 ) &&
134 ( yes "" | git mergetool file1 file1 ) &&
135 ( yes "" | git mergetool file2 "spaced name" >/dev/null 2>&1 ) &&
136 ( yes "" | git mergetool subdir/file3 >/dev/null 2>&1 ) &&
137 ( yes "d" | git mergetool file11 >/dev/null 2>&1 ) &&
138 ( yes "d" | git mergetool file12 >/dev/null 2>&1 ) &&
139 ( yes "l" | git mergetool submod >/dev/null 2>&1 ) &&
140 test "$(cat file1)" = "master updated" &&
141 test "$(cat file2)" = "master new" &&
142 test "$(cat subdir/file3)" = "master new sub" &&
143 test "$(cat submod/bar)" = "branch1 submodule" &&
144 git commit -m "branch1 resolved with mergetool"
147 test_expect_success 'mergetool crlf' '
148 test_config core.autocrlf true &&
149 git checkout -b test$test_count branch1 &&
150 test_must_fail git merge master >/dev/null 2>&1 &&
151 ( yes "" | git mergetool file1 >/dev/null 2>&1 ) &&
152 ( yes "" | git mergetool file2 >/dev/null 2>&1 ) &&
153 ( yes "" | git mergetool "spaced name" >/dev/null 2>&1 ) &&
154 ( yes "" | git mergetool both >/dev/null 2>&1 ) &&
155 ( yes "" | git mergetool subdir/file3 >/dev/null 2>&1 ) &&
156 ( yes "d" | git mergetool file11 >/dev/null 2>&1 ) &&
157 ( yes "d" | git mergetool file12 >/dev/null 2>&1 ) &&
158 ( yes "r" | git mergetool submod >/dev/null 2>&1 ) &&
159 test "$(printf x | cat file1 -)" = "$(printf "master updated\r\nx")" &&
160 test "$(printf x | cat file2 -)" = "$(printf "master new\r\nx")" &&
161 test "$(printf x | cat subdir/file3 -)" = "$(printf "master new sub\r\nx")" &&
162 git submodule update -N &&
163 test "$(cat submod/bar)" = "master submodule" &&
164 git commit -m "branch1 resolved with mergetool - autocrlf" &&
165 test_config core.autocrlf false &&
166 git reset --hard
169 test_expect_success 'mergetool in subdir' '
170 git checkout -b test$test_count branch1 &&
171 git submodule update -N &&
173 cd subdir &&
174 test_must_fail git merge master >/dev/null 2>&1 &&
175 ( yes "" | git mergetool file3 >/dev/null 2>&1 ) &&
176 test "$(cat file3)" = "master new sub"
180 test_expect_success 'mergetool on file in parent dir' '
182 cd subdir &&
183 ( yes "" | git mergetool ../file1 >/dev/null 2>&1 ) &&
184 ( yes "" | git mergetool ../file2 ../spaced\ name >/dev/null 2>&1 ) &&
185 ( yes "" | git mergetool ../both >/dev/null 2>&1 ) &&
186 ( yes "d" | git mergetool ../file11 >/dev/null 2>&1 ) &&
187 ( yes "d" | git mergetool ../file12 >/dev/null 2>&1 ) &&
188 ( yes "l" | git mergetool ../submod >/dev/null 2>&1 ) &&
189 test "$(cat ../file1)" = "master updated" &&
190 test "$(cat ../file2)" = "master new" &&
191 test "$(cat ../submod/bar)" = "branch1 submodule" &&
192 git commit -m "branch1 resolved with mergetool - subdir"
196 test_expect_success 'mergetool skips autoresolved' '
197 git checkout -b test$test_count branch1 &&
198 git submodule update -N &&
199 test_must_fail git merge master &&
200 test -n "$(git ls-files -u)" &&
201 ( yes "d" | git mergetool file11 >/dev/null 2>&1 ) &&
202 ( yes "d" | git mergetool file12 >/dev/null 2>&1 ) &&
203 ( yes "l" | git mergetool submod >/dev/null 2>&1 ) &&
204 output="$(git mergetool --no-prompt)" &&
205 test "$output" = "No files need merging" &&
206 git reset --hard
209 test_expect_success 'mergetool merges all from subdir' '
210 test_config rerere.enabled false &&
212 cd subdir &&
213 test_must_fail git merge master &&
214 ( yes "r" | git mergetool ../submod ) &&
215 ( yes "d" "d" | git mergetool --no-prompt ) &&
216 test "$(cat ../file1)" = "master updated" &&
217 test "$(cat ../file2)" = "master new" &&
218 test "$(cat file3)" = "master new sub" &&
219 ( cd .. && git submodule update -N ) &&
220 test "$(cat ../submod/bar)" = "master submodule" &&
221 git commit -m "branch2 resolved by mergetool from subdir"
225 test_expect_success 'mergetool skips resolved paths when rerere is active' '
226 test_config rerere.enabled true &&
227 rm -rf .git/rr-cache &&
228 git checkout -b test$test_count branch1 &&
229 git submodule update -N &&
230 test_must_fail git merge master >/dev/null 2>&1 &&
231 ( yes "l" | git mergetool --no-prompt submod >/dev/null 2>&1 ) &&
232 ( yes "d" "d" | git mergetool --no-prompt >/dev/null 2>&1 ) &&
233 git submodule update -N &&
234 output="$(yes "n" | git mergetool --no-prompt)" &&
235 test "$output" = "No files need merging" &&
236 git reset --hard
239 test_expect_success 'conflicted stash sets up rerere' '
240 test_config rerere.enabled true &&
241 git checkout stash1 &&
242 echo "Conflicting stash content" >file11 &&
243 git stash &&
245 git checkout --detach stash2 &&
246 test_must_fail git stash apply &&
248 test -n "$(git ls-files -u)" &&
249 conflicts="$(git rerere remaining)" &&
250 test "$conflicts" = "file11" &&
251 output="$(git mergetool --no-prompt)" &&
252 test "$output" != "No files need merging" &&
254 git commit -am "save the stash resolution" &&
256 git reset --hard stash2 &&
257 test_must_fail git stash apply &&
259 test -n "$(git ls-files -u)" &&
260 conflicts="$(git rerere remaining)" &&
261 test -z "$conflicts" &&
262 output="$(git mergetool --no-prompt)" &&
263 test "$output" = "No files need merging"
266 test_expect_success 'mergetool takes partial path' '
267 git reset --hard &&
268 test_config rerere.enabled false &&
269 git checkout -b test$test_count branch1 &&
270 git submodule update -N &&
271 test_must_fail git merge master &&
273 ( yes "" | git mergetool subdir ) &&
275 test "$(cat subdir/file3)" = "master new sub" &&
276 git reset --hard
279 test_expect_success 'mergetool delete/delete conflict' '
280 git checkout move-to-c &&
281 test_must_fail git merge move-to-b &&
282 echo d | git mergetool a/a/file.txt &&
283 ! test -f a/a/file.txt &&
284 git reset --hard HEAD &&
285 test_must_fail git merge move-to-b &&
286 echo m | git mergetool a/a/file.txt &&
287 test -f b/b/file.txt &&
288 git reset --hard HEAD &&
289 test_must_fail git merge move-to-b &&
290 ! echo a | git mergetool a/a/file.txt &&
291 ! test -f a/a/file.txt &&
292 git reset --hard HEAD
295 test_expect_success 'mergetool produces no errors when keepBackup is used' '
296 test_config mergetool.keepBackup true &&
297 test_must_fail git merge move-to-b &&
298 : >expect &&
299 echo d | git mergetool a/a/file.txt 2>actual &&
300 test_cmp expect actual &&
301 ! test -d a &&
302 git reset --hard HEAD
305 test_expect_success 'mergetool honors tempfile config for deleted files' '
306 test_config mergetool.keepTemporaries false &&
307 test_must_fail git merge move-to-b &&
308 echo d | git mergetool a/a/file.txt &&
309 ! test -d a &&
310 git reset --hard HEAD
313 test_expect_success 'mergetool keeps tempfiles when aborting delete/delete' '
314 test_config mergetool.keepTemporaries true &&
315 test_must_fail git merge move-to-b &&
316 ! (echo a; echo n) | git mergetool a/a/file.txt &&
317 test -d a/a &&
318 cat >expect <<-\EOF &&
319 file_BASE_.txt
320 file_LOCAL_.txt
321 file_REMOTE_.txt
323 ls -1 a/a | sed -e "s/[0-9]*//g" >actual &&
324 test_cmp expect actual &&
325 git clean -fdx &&
326 git reset --hard HEAD
329 test_expect_success 'deleted vs modified submodule' '
330 git checkout -b test$test_count branch1 &&
331 git submodule update -N &&
332 mv submod submod-movedaside &&
333 git rm --cached submod &&
334 git commit -m "Submodule deleted from branch" &&
335 git checkout -b test$test_count.a test$test_count &&
336 test_must_fail git merge master &&
337 test -n "$(git ls-files -u)" &&
338 ( yes "" | git mergetool file1 file2 spaced\ name subdir/file3 >/dev/null 2>&1 ) &&
339 ( yes "" | git mergetool both >/dev/null 2>&1 ) &&
340 ( yes "d" | git mergetool file11 file12 >/dev/null 2>&1 ) &&
341 ( yes "r" | git mergetool submod ) &&
342 rmdir submod && mv submod-movedaside submod &&
343 test "$(cat submod/bar)" = "branch1 submodule" &&
344 git submodule update -N &&
345 test "$(cat submod/bar)" = "master submodule" &&
346 output="$(git mergetool --no-prompt)" &&
347 test "$output" = "No files need merging" &&
348 git commit -m "Merge resolved by keeping module" &&
350 mv submod submod-movedaside &&
351 git checkout -b test$test_count.b test$test_count &&
352 git submodule update -N &&
353 test_must_fail git merge master &&
354 test -n "$(git ls-files -u)" &&
355 ( yes "" | git mergetool file1 file2 spaced\ name subdir/file3 >/dev/null 2>&1 ) &&
356 ( yes "" | git mergetool both >/dev/null 2>&1 ) &&
357 ( yes "d" | git mergetool file11 file12 >/dev/null 2>&1 ) &&
358 ( yes "l" | git mergetool submod ) &&
359 test ! -e submod &&
360 output="$(git mergetool --no-prompt)" &&
361 test "$output" = "No files need merging" &&
362 git commit -m "Merge resolved by deleting module" &&
364 mv submod-movedaside submod &&
365 git checkout -b test$test_count.c master &&
366 git submodule update -N &&
367 test_must_fail git merge test$test_count &&
368 test -n "$(git ls-files -u)" &&
369 ( yes "" | git mergetool file1 file2 spaced\ name subdir/file3 >/dev/null 2>&1 ) &&
370 ( yes "" | git mergetool both >/dev/null 2>&1 ) &&
371 ( yes "d" | git mergetool file11 file12 >/dev/null 2>&1 ) &&
372 ( yes "r" | git mergetool submod ) &&
373 test ! -e submod &&
374 test -d submod.orig &&
375 git submodule update -N &&
376 output="$(git mergetool --no-prompt)" &&
377 test "$output" = "No files need merging" &&
378 git commit -m "Merge resolved by deleting module" &&
379 mv submod.orig submod &&
381 git checkout -b test$test_count.d master &&
382 git submodule update -N &&
383 test_must_fail git merge test$test_count &&
384 test -n "$(git ls-files -u)" &&
385 ( yes "" | git mergetool file1 file2 spaced\ name subdir/file3 >/dev/null 2>&1 ) &&
386 ( yes "" | git mergetool both >/dev/null 2>&1 ) &&
387 ( yes "d" | git mergetool file11 file12 >/dev/null 2>&1 ) &&
388 ( yes "l" | git mergetool submod ) &&
389 test "$(cat submod/bar)" = "master submodule" &&
390 git submodule update -N &&
391 test "$(cat submod/bar)" = "master submodule" &&
392 output="$(git mergetool --no-prompt)" &&
393 test "$output" = "No files need merging" &&
394 git commit -m "Merge resolved by keeping module" &&
395 git reset --hard HEAD
398 test_expect_success 'file vs modified submodule' '
399 git checkout -b test$test_count branch1 &&
400 git submodule update -N &&
401 mv submod submod-movedaside &&
402 git rm --cached submod &&
403 echo not a submodule >submod &&
404 git add submod &&
405 git commit -m "Submodule path becomes file" &&
406 git checkout -b test$test_count.a branch1 &&
407 test_must_fail git merge master &&
408 test -n "$(git ls-files -u)" &&
409 ( yes "" | git mergetool file1 file2 spaced\ name subdir/file3 >/dev/null 2>&1 ) &&
410 ( yes "" | git mergetool both >/dev/null 2>&1 ) &&
411 ( yes "d" | git mergetool file11 file12 >/dev/null 2>&1 ) &&
412 ( yes "r" | git mergetool submod ) &&
413 rmdir submod && mv submod-movedaside submod &&
414 test "$(cat submod/bar)" = "branch1 submodule" &&
415 git submodule update -N &&
416 test "$(cat submod/bar)" = "master submodule" &&
417 output="$(git mergetool --no-prompt)" &&
418 test "$output" = "No files need merging" &&
419 git commit -m "Merge resolved by keeping module" &&
421 mv submod submod-movedaside &&
422 git checkout -b test$test_count.b test$test_count &&
423 test_must_fail git merge master &&
424 test -n "$(git ls-files -u)" &&
425 ( yes "" | git mergetool file1 file2 spaced\ name subdir/file3 >/dev/null 2>&1 ) &&
426 ( yes "" | git mergetool both >/dev/null 2>&1 ) &&
427 ( yes "d" | git mergetool file11 file12 >/dev/null 2>&1 ) &&
428 ( yes "l" | git mergetool submod ) &&
429 git submodule update -N &&
430 test "$(cat submod)" = "not a submodule" &&
431 output="$(git mergetool --no-prompt)" &&
432 test "$output" = "No files need merging" &&
433 git commit -m "Merge resolved by keeping file" &&
435 git checkout -b test$test_count.c master &&
436 rmdir submod && mv submod-movedaside submod &&
437 test ! -e submod.orig &&
438 git submodule update -N &&
439 test_must_fail git merge test$test_count &&
440 test -n "$(git ls-files -u)" &&
441 ( yes "" | git mergetool file1 file2 spaced\ name subdir/file3 >/dev/null 2>&1 ) &&
442 ( yes "" | git mergetool both >/dev/null 2>&1 ) &&
443 ( yes "d" | git mergetool file11 file12 >/dev/null 2>&1 ) &&
444 ( yes "r" | git mergetool submod ) &&
445 test -d submod.orig &&
446 git submodule update -N &&
447 test "$(cat submod)" = "not a submodule" &&
448 output="$(git mergetool --no-prompt)" &&
449 test "$output" = "No files need merging" &&
450 git commit -m "Merge resolved by keeping file" &&
452 git checkout -b test$test_count.d master &&
453 rmdir submod && mv submod.orig submod &&
454 git submodule update -N &&
455 test_must_fail git merge test$test_count &&
456 test -n "$(git ls-files -u)" &&
457 ( yes "" | git mergetool file1 file2 spaced\ name subdir/file3 >/dev/null 2>&1 ) &&
458 ( yes "" | git mergetool both>/dev/null 2>&1 ) &&
459 ( yes "d" | git mergetool file11 file12 >/dev/null 2>&1 ) &&
460 ( yes "l" | git mergetool submod ) &&
461 test "$(cat submod/bar)" = "master submodule" &&
462 git submodule update -N &&
463 test "$(cat submod/bar)" = "master submodule" &&
464 output="$(git mergetool --no-prompt)" &&
465 test "$output" = "No files need merging" &&
466 git commit -m "Merge resolved by keeping module"
469 test_expect_success 'submodule in subdirectory' '
470 git checkout -b test$test_count branch1 &&
471 git submodule update -N &&
473 cd subdir &&
474 test_create_repo subdir_module &&
476 cd subdir_module &&
477 : >file15 &&
478 git add file15 &&
479 git commit -m "add initial versions"
481 ) &&
482 git submodule add git://example.com/subsubmodule subdir/subdir_module &&
483 git add subdir/subdir_module &&
484 git commit -m "add submodule in subdirectory" &&
486 git checkout -b test$test_count.a test$test_count &&
487 git submodule update -N &&
489 cd subdir/subdir_module &&
490 git checkout -b super10.a &&
491 echo test$test_count.a >file15 &&
492 git add file15 &&
493 git commit -m "on branch 10.a"
494 ) &&
495 git add subdir/subdir_module &&
496 git commit -m "change submodule in subdirectory on test$test_count.a" &&
498 git checkout -b test$test_count.b test$test_count &&
499 git submodule update -N &&
501 cd subdir/subdir_module &&
502 git checkout -b super10.b &&
503 echo test$test_count.b >file15 &&
504 git add file15 &&
505 git commit -m "on branch 10.b"
506 ) &&
507 git add subdir/subdir_module &&
508 git commit -m "change submodule in subdirectory on test$test_count.b" &&
510 test_must_fail git merge test$test_count.a >/dev/null 2>&1 &&
512 cd subdir &&
513 ( yes "l" | git mergetool subdir_module )
514 ) &&
515 test "$(cat subdir/subdir_module/file15)" = "test$test_count.b" &&
516 git submodule update -N &&
517 test "$(cat subdir/subdir_module/file15)" = "test$test_count.b" &&
518 git reset --hard &&
519 git submodule update -N &&
521 test_must_fail git merge test$test_count.a >/dev/null 2>&1 &&
522 ( yes "r" | git mergetool subdir/subdir_module ) &&
523 test "$(cat subdir/subdir_module/file15)" = "test$test_count.b" &&
524 git submodule update -N &&
525 test "$(cat subdir/subdir_module/file15)" = "test$test_count.a" &&
526 git commit -m "branch1 resolved with mergetool" &&
527 rm -rf subdir/subdir_module
530 test_expect_success 'directory vs modified submodule' '
531 git checkout -b test$test_count branch1 &&
532 mv submod submod-movedaside &&
533 git rm --cached submod &&
534 mkdir submod &&
535 echo not a submodule >submod/file16 &&
536 git add submod/file16 &&
537 git commit -m "Submodule path becomes directory" &&
539 test_must_fail git merge master &&
540 test -n "$(git ls-files -u)" &&
541 ( yes "l" | git mergetool submod ) &&
542 test "$(cat submod/file16)" = "not a submodule" &&
543 rm -rf submod.orig &&
545 git reset --hard >/dev/null 2>&1 &&
546 test_must_fail git merge master &&
547 test -n "$(git ls-files -u)" &&
548 test ! -e submod.orig &&
549 ( yes "r" | git mergetool submod ) &&
550 test -d submod.orig &&
551 test "$(cat submod.orig/file16)" = "not a submodule" &&
552 rm -r submod.orig &&
553 mv submod-movedaside/.git submod &&
554 ( cd submod && git clean -f && git reset --hard ) &&
555 git submodule update -N &&
556 test "$(cat submod/bar)" = "master submodule" &&
557 git reset --hard >/dev/null 2>&1 && rm -rf submod-movedaside &&
559 git checkout -b test$test_count.c master &&
560 git submodule update -N &&
561 test_must_fail git merge test$test_count &&
562 test -n "$(git ls-files -u)" &&
563 ( yes "l" | git mergetool submod ) &&
564 git submodule update -N &&
565 test "$(cat submod/bar)" = "master submodule" &&
567 git reset --hard >/dev/null 2>&1 &&
568 git submodule update -N &&
569 test_must_fail git merge test$test_count &&
570 test -n "$(git ls-files -u)" &&
571 test ! -e submod.orig &&
572 ( yes "r" | git mergetool submod ) &&
573 test "$(cat submod/file16)" = "not a submodule" &&
575 git reset --hard master >/dev/null 2>&1 &&
576 ( cd submod && git clean -f && git reset --hard ) &&
577 git submodule update -N
580 test_expect_success 'file with no base' '
581 git checkout -b test$test_count branch1 &&
582 test_must_fail git merge master &&
583 git mergetool --no-prompt --tool mybase -- both &&
584 >expected &&
585 test_cmp both expected &&
586 git reset --hard master >/dev/null 2>&1
589 test_expect_success 'custom commands override built-ins' '
590 git checkout -b test$test_count branch1 &&
591 test_config mergetool.defaults.cmd "cat \"\$REMOTE\" >\"\$MERGED\"" &&
592 test_config mergetool.defaults.trustExitCode true &&
593 test_must_fail git merge master &&
594 git mergetool --no-prompt --tool defaults -- both &&
595 echo master both added >expected &&
596 test_cmp both expected &&
597 git reset --hard master >/dev/null 2>&1
600 test_expect_success 'filenames seen by tools start with ./' '
601 git checkout -b test$test_count branch1 &&
602 test_config mergetool.writeToTemp false &&
603 test_config mergetool.myecho.cmd "echo \"\$LOCAL\"" &&
604 test_config mergetool.myecho.trustExitCode true &&
605 test_must_fail git merge master &&
606 git mergetool --no-prompt --tool myecho -- both >actual &&
607 grep ^\./both_LOCAL_ actual >/dev/null &&
608 git reset --hard master >/dev/null 2>&1
611 test_lazy_prereq MKTEMP '
612 tempdir=$(mktemp -d -t foo.XXXXXX) &&
613 test -d "$tempdir" &&
614 rmdir "$tempdir"
617 test_expect_success MKTEMP 'temporary filenames are used with mergetool.writeToTemp' '
618 git checkout -b test$test_count branch1 &&
619 test_config mergetool.writeToTemp true &&
620 test_config mergetool.myecho.cmd "echo \"\$LOCAL\"" &&
621 test_config mergetool.myecho.trustExitCode true &&
622 test_must_fail git merge master &&
623 git mergetool --no-prompt --tool myecho -- both >actual &&
624 test_must_fail grep ^\./both_LOCAL_ actual >/dev/null &&
625 grep /both_LOCAL_ actual >/dev/null &&
626 git reset --hard master >/dev/null 2>&1
629 test_expect_success 'diff.orderFile configuration is honored' '
630 git checkout order-file-side2 &&
631 test_config diff.orderFile order-file &&
632 test_config mergetool.myecho.cmd "echo \"\$LOCAL\"" &&
633 test_config mergetool.myecho.trustExitCode true &&
634 echo b >order-file &&
635 echo a >>order-file &&
636 test_must_fail git merge order-file-side1 &&
637 cat >expect <<-\EOF &&
638 Merging:
642 git mergetool --no-prompt --tool myecho >output &&
643 git grep --no-index -h -A2 Merging: output >actual &&
644 test_cmp expect actual &&
645 git reset --hard >/dev/null
647 test_expect_success 'mergetool -Oorder-file is honored' '
648 test_config diff.orderFile order-file &&
649 test_config mergetool.myecho.cmd "echo \"\$LOCAL\"" &&
650 test_config mergetool.myecho.trustExitCode true &&
651 test_must_fail git merge order-file-side1 &&
652 cat >expect <<-\EOF &&
653 Merging:
657 git mergetool -O/dev/null --no-prompt --tool myecho >output &&
658 git grep --no-index -h -A2 Merging: output >actual &&
659 test_cmp expect actual &&
660 git reset --hard >/dev/null 2>&1 &&
662 git config --unset diff.orderFile &&
663 test_must_fail git merge order-file-side1 &&
664 cat >expect <<-\EOF &&
665 Merging:
669 git mergetool -Oorder-file --no-prompt --tool myecho >output &&
670 git grep --no-index -h -A2 Merging: output >actual &&
671 test_cmp expect actual &&
672 git reset --hard >/dev/null 2>&1
675 test_done