ref-filter.c: drop return from void function
[git/debian.git] / t / t7610-mergetool.sh
blob63d36fb28e44426708a743979c4bc341bdac714e
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 stash1 master &&
59 echo stash1 change file11 >file11 &&
60 git add file11 &&
61 git commit -m "stash1 changes" &&
63 git checkout -b stash2 master &&
64 echo stash2 change file11 >file11 &&
65 git add file11 &&
66 git commit -m "stash2 changes" &&
68 git checkout master &&
69 git submodule update -N &&
70 echo master updated >file1 &&
71 echo master new >file2 &&
72 echo master updated spaced >"spaced name" &&
73 echo master both added >both &&
74 echo master updated file12 >file12 &&
75 echo master updated file14 >file14 &&
76 echo master new sub >subdir/file3 &&
78 cd submod &&
79 echo master submodule >bar &&
80 git add bar &&
81 git commit -m "Add bar on master" &&
82 git checkout -b submod-master
83 ) &&
84 git add file1 "spaced name" file12 file14 file2 subdir/file3 submod &&
85 git add both &&
86 git rm file11 &&
87 git commit -m "master updates" &&
89 git config merge.tool mytool &&
90 git config mergetool.mytool.cmd "cat \"\$REMOTE\" >\"\$MERGED\"" &&
91 git config mergetool.mytool.trustExitCode true &&
92 git config mergetool.mybase.cmd "cat \"\$BASE\" >\"\$MERGED\"" &&
93 git config mergetool.mybase.trustExitCode true
96 test_expect_success 'custom mergetool' '
97 git checkout -b test1 branch1 &&
98 git submodule update -N &&
99 test_must_fail git merge master >/dev/null 2>&1 &&
100 ( yes "" | git mergetool both >/dev/null 2>&1 ) &&
101 ( yes "" | git mergetool file1 file1 ) &&
102 ( yes "" | git mergetool file2 "spaced name" >/dev/null 2>&1 ) &&
103 ( yes "" | git mergetool subdir/file3 >/dev/null 2>&1 ) &&
104 ( yes "d" | git mergetool file11 >/dev/null 2>&1 ) &&
105 ( yes "d" | git mergetool file12 >/dev/null 2>&1 ) &&
106 ( yes "l" | git mergetool submod >/dev/null 2>&1 ) &&
107 test "$(cat file1)" = "master updated" &&
108 test "$(cat file2)" = "master new" &&
109 test "$(cat subdir/file3)" = "master new sub" &&
110 test "$(cat submod/bar)" = "branch1 submodule" &&
111 git commit -m "branch1 resolved with mergetool"
114 test_expect_success 'mergetool crlf' '
115 test_config core.autocrlf true &&
116 git checkout -b test2 branch1 &&
117 test_must_fail git merge master >/dev/null 2>&1 &&
118 ( yes "" | git mergetool file1 >/dev/null 2>&1 ) &&
119 ( yes "" | git mergetool file2 >/dev/null 2>&1 ) &&
120 ( yes "" | git mergetool "spaced name" >/dev/null 2>&1 ) &&
121 ( yes "" | git mergetool both >/dev/null 2>&1 ) &&
122 ( yes "" | git mergetool subdir/file3 >/dev/null 2>&1 ) &&
123 ( yes "d" | git mergetool file11 >/dev/null 2>&1 ) &&
124 ( yes "d" | git mergetool file12 >/dev/null 2>&1 ) &&
125 ( yes "r" | git mergetool submod >/dev/null 2>&1 ) &&
126 test "$(printf x | cat file1 -)" = "$(printf "master updated\r\nx")" &&
127 test "$(printf x | cat file2 -)" = "$(printf "master new\r\nx")" &&
128 test "$(printf x | cat subdir/file3 -)" = "$(printf "master new sub\r\nx")" &&
129 git submodule update -N &&
130 test "$(cat submod/bar)" = "master submodule" &&
131 git commit -m "branch1 resolved with mergetool - autocrlf" &&
132 test_config core.autocrlf false &&
133 git reset --hard
136 test_expect_success 'mergetool in subdir' '
137 git checkout -b test3 branch1 &&
138 git submodule update -N &&
140 cd subdir &&
141 test_must_fail git merge master >/dev/null 2>&1 &&
142 ( yes "" | git mergetool file3 >/dev/null 2>&1 ) &&
143 test "$(cat file3)" = "master new sub"
147 test_expect_success 'mergetool on file in parent dir' '
149 cd subdir &&
150 ( yes "" | git mergetool ../file1 >/dev/null 2>&1 ) &&
151 ( yes "" | git mergetool ../file2 ../spaced\ name >/dev/null 2>&1 ) &&
152 ( yes "" | git mergetool ../both >/dev/null 2>&1 ) &&
153 ( yes "d" | git mergetool ../file11 >/dev/null 2>&1 ) &&
154 ( yes "d" | git mergetool ../file12 >/dev/null 2>&1 ) &&
155 ( yes "l" | git mergetool ../submod >/dev/null 2>&1 ) &&
156 test "$(cat ../file1)" = "master updated" &&
157 test "$(cat ../file2)" = "master new" &&
158 test "$(cat ../submod/bar)" = "branch1 submodule" &&
159 git commit -m "branch1 resolved with mergetool - subdir"
163 test_expect_success 'mergetool skips autoresolved' '
164 git checkout -b test4 branch1 &&
165 git submodule update -N &&
166 test_must_fail git merge master &&
167 test -n "$(git ls-files -u)" &&
168 ( yes "d" | git mergetool file11 >/dev/null 2>&1 ) &&
169 ( yes "d" | git mergetool file12 >/dev/null 2>&1 ) &&
170 ( yes "l" | git mergetool submod >/dev/null 2>&1 ) &&
171 output="$(git mergetool --no-prompt)" &&
172 test "$output" = "No files need merging" &&
173 git reset --hard
176 test_expect_success 'mergetool merges all from subdir' '
177 test_config rerere.enabled false &&
179 cd subdir &&
180 test_must_fail git merge master &&
181 ( yes "r" | git mergetool ../submod ) &&
182 ( yes "d" "d" | git mergetool --no-prompt ) &&
183 test "$(cat ../file1)" = "master updated" &&
184 test "$(cat ../file2)" = "master new" &&
185 test "$(cat file3)" = "master new sub" &&
186 ( cd .. && git submodule update -N ) &&
187 test "$(cat ../submod/bar)" = "master submodule" &&
188 git commit -m "branch2 resolved by mergetool from subdir"
192 test_expect_success 'mergetool skips resolved paths when rerere is active' '
193 test_config rerere.enabled true &&
194 rm -rf .git/rr-cache &&
195 git checkout -b test5 branch1 &&
196 git submodule update -N &&
197 test_must_fail git merge master >/dev/null 2>&1 &&
198 ( yes "l" | git mergetool --no-prompt submod >/dev/null 2>&1 ) &&
199 ( yes "d" "d" | git mergetool --no-prompt >/dev/null 2>&1 ) &&
200 git submodule update -N &&
201 output="$(yes "n" | git mergetool --no-prompt)" &&
202 test "$output" = "No files need merging" &&
203 git reset --hard
206 test_expect_success 'conflicted stash sets up rerere' '
207 test_config rerere.enabled true &&
208 git checkout stash1 &&
209 echo "Conflicting stash content" >file11 &&
210 git stash &&
212 git checkout --detach stash2 &&
213 test_must_fail git stash apply &&
215 test -n "$(git ls-files -u)" &&
216 conflicts="$(git rerere remaining)" &&
217 test "$conflicts" = "file11" &&
218 output="$(git mergetool --no-prompt)" &&
219 test "$output" != "No files need merging" &&
221 git commit -am "save the stash resolution" &&
223 git reset --hard stash2 &&
224 test_must_fail git stash apply &&
226 test -n "$(git ls-files -u)" &&
227 conflicts="$(git rerere remaining)" &&
228 test -z "$conflicts" &&
229 output="$(git mergetool --no-prompt)" &&
230 test "$output" = "No files need merging"
233 test_expect_success 'mergetool takes partial path' '
234 git reset --hard &&
235 test_config rerere.enabled false &&
236 git checkout -b test12 branch1 &&
237 git submodule update -N &&
238 test_must_fail git merge master &&
240 ( yes "" | git mergetool subdir ) &&
242 test "$(cat subdir/file3)" = "master new sub" &&
243 git reset --hard
246 test_expect_success 'mergetool delete/delete conflict' '
247 git checkout -b delete-base branch1 &&
248 mkdir -p a/a &&
249 (echo one; echo two; echo 3; echo 4) >a/a/file.txt &&
250 git add a/a/file.txt &&
251 git commit -m"base file" &&
252 git checkout -b move-to-b delete-base &&
253 mkdir -p b/b &&
254 git mv a/a/file.txt b/b/file.txt &&
255 (echo one; echo two; echo 4) >b/b/file.txt &&
256 git commit -a -m"move to b" &&
257 git checkout -b move-to-c delete-base &&
258 mkdir -p c/c &&
259 git mv a/a/file.txt c/c/file.txt &&
260 (echo one; echo two; echo 3) >c/c/file.txt &&
261 git commit -a -m"move to c" &&
262 test_must_fail git merge move-to-b &&
263 echo d | git mergetool a/a/file.txt &&
264 ! test -f a/a/file.txt &&
265 git reset --hard HEAD &&
266 test_must_fail git merge move-to-b &&
267 echo m | git mergetool a/a/file.txt &&
268 test -f b/b/file.txt &&
269 git reset --hard HEAD &&
270 test_must_fail git merge move-to-b &&
271 ! echo a | git mergetool a/a/file.txt &&
272 ! test -f a/a/file.txt &&
273 git reset --hard HEAD
276 test_expect_success 'mergetool produces no errors when keepBackup is used' '
277 test_config mergetool.keepBackup true &&
278 test_must_fail git merge move-to-b &&
279 : >expect &&
280 echo d | git mergetool a/a/file.txt 2>actual &&
281 test_cmp expect actual &&
282 ! test -d a &&
283 git reset --hard HEAD
286 test_expect_success 'mergetool honors tempfile config for deleted files' '
287 test_config mergetool.keepTemporaries false &&
288 test_must_fail git merge move-to-b &&
289 echo d | git mergetool a/a/file.txt &&
290 ! test -d a &&
291 git reset --hard HEAD
294 test_expect_success 'mergetool keeps tempfiles when aborting delete/delete' '
295 test_config mergetool.keepTemporaries true &&
296 test_must_fail git merge move-to-b &&
297 ! (echo a; echo n) | git mergetool a/a/file.txt &&
298 test -d a/a &&
299 cat >expect <<-\EOF &&
300 file_BASE_.txt
301 file_LOCAL_.txt
302 file_REMOTE_.txt
304 ls -1 a/a | sed -e "s/[0-9]*//g" >actual &&
305 test_cmp expect actual &&
306 git clean -fdx &&
307 git reset --hard HEAD
310 test_expect_success 'deleted vs modified submodule' '
311 git checkout -b test6 branch1 &&
312 git submodule update -N &&
313 mv submod submod-movedaside &&
314 git rm --cached submod &&
315 git commit -m "Submodule deleted from branch" &&
316 git checkout -b test6.a test6 &&
317 test_must_fail git merge master &&
318 test -n "$(git ls-files -u)" &&
319 ( yes "" | git mergetool file1 file2 spaced\ name subdir/file3 >/dev/null 2>&1 ) &&
320 ( yes "" | git mergetool both >/dev/null 2>&1 ) &&
321 ( yes "d" | git mergetool file11 file12 >/dev/null 2>&1 ) &&
322 ( yes "r" | git mergetool submod ) &&
323 rmdir submod && mv submod-movedaside submod &&
324 test "$(cat submod/bar)" = "branch1 submodule" &&
325 git submodule update -N &&
326 test "$(cat submod/bar)" = "master submodule" &&
327 output="$(git mergetool --no-prompt)" &&
328 test "$output" = "No files need merging" &&
329 git commit -m "Merge resolved by keeping module" &&
331 mv submod submod-movedaside &&
332 git checkout -b test6.b test6 &&
333 git submodule update -N &&
334 test_must_fail git merge master &&
335 test -n "$(git ls-files -u)" &&
336 ( yes "" | git mergetool file1 file2 spaced\ name subdir/file3 >/dev/null 2>&1 ) &&
337 ( yes "" | git mergetool both >/dev/null 2>&1 ) &&
338 ( yes "d" | git mergetool file11 file12 >/dev/null 2>&1 ) &&
339 ( yes "l" | git mergetool submod ) &&
340 test ! -e submod &&
341 output="$(git mergetool --no-prompt)" &&
342 test "$output" = "No files need merging" &&
343 git commit -m "Merge resolved by deleting module" &&
345 mv submod-movedaside submod &&
346 git checkout -b test6.c master &&
347 git submodule update -N &&
348 test_must_fail git merge test6 &&
349 test -n "$(git ls-files -u)" &&
350 ( yes "" | git mergetool file1 file2 spaced\ name subdir/file3 >/dev/null 2>&1 ) &&
351 ( yes "" | git mergetool both >/dev/null 2>&1 ) &&
352 ( yes "d" | git mergetool file11 file12 >/dev/null 2>&1 ) &&
353 ( yes "r" | git mergetool submod ) &&
354 test ! -e submod &&
355 test -d submod.orig &&
356 git submodule update -N &&
357 output="$(git mergetool --no-prompt)" &&
358 test "$output" = "No files need merging" &&
359 git commit -m "Merge resolved by deleting module" &&
360 mv submod.orig submod &&
362 git checkout -b test6.d master &&
363 git submodule update -N &&
364 test_must_fail git merge test6 &&
365 test -n "$(git ls-files -u)" &&
366 ( yes "" | git mergetool file1 file2 spaced\ name subdir/file3 >/dev/null 2>&1 ) &&
367 ( yes "" | git mergetool both >/dev/null 2>&1 ) &&
368 ( yes "d" | git mergetool file11 file12 >/dev/null 2>&1 ) &&
369 ( yes "l" | git mergetool submod ) &&
370 test "$(cat submod/bar)" = "master submodule" &&
371 git submodule update -N &&
372 test "$(cat submod/bar)" = "master submodule" &&
373 output="$(git mergetool --no-prompt)" &&
374 test "$output" = "No files need merging" &&
375 git commit -m "Merge resolved by keeping module" &&
376 git reset --hard HEAD
379 test_expect_success 'file vs modified submodule' '
380 git checkout -b test7 branch1 &&
381 git submodule update -N &&
382 mv submod submod-movedaside &&
383 git rm --cached submod &&
384 echo not a submodule >submod &&
385 git add submod &&
386 git commit -m "Submodule path becomes file" &&
387 git checkout -b test7.a branch1 &&
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 "r" | git mergetool submod ) &&
394 rmdir submod && mv submod-movedaside submod &&
395 test "$(cat submod/bar)" = "branch1 submodule" &&
396 git submodule update -N &&
397 test "$(cat submod/bar)" = "master submodule" &&
398 output="$(git mergetool --no-prompt)" &&
399 test "$output" = "No files need merging" &&
400 git commit -m "Merge resolved by keeping module" &&
402 mv submod submod-movedaside &&
403 git checkout -b test7.b test7 &&
404 test_must_fail git merge master &&
405 test -n "$(git ls-files -u)" &&
406 ( yes "" | git mergetool file1 file2 spaced\ name subdir/file3 >/dev/null 2>&1 ) &&
407 ( yes "" | git mergetool both >/dev/null 2>&1 ) &&
408 ( yes "d" | git mergetool file11 file12 >/dev/null 2>&1 ) &&
409 ( yes "l" | git mergetool submod ) &&
410 git submodule update -N &&
411 test "$(cat submod)" = "not a submodule" &&
412 output="$(git mergetool --no-prompt)" &&
413 test "$output" = "No files need merging" &&
414 git commit -m "Merge resolved by keeping file" &&
416 git checkout -b test7.c master &&
417 rmdir submod && mv submod-movedaside submod &&
418 test ! -e submod.orig &&
419 git submodule update -N &&
420 test_must_fail git merge test7 &&
421 test -n "$(git ls-files -u)" &&
422 ( yes "" | git mergetool file1 file2 spaced\ name subdir/file3 >/dev/null 2>&1 ) &&
423 ( yes "" | git mergetool both >/dev/null 2>&1 ) &&
424 ( yes "d" | git mergetool file11 file12 >/dev/null 2>&1 ) &&
425 ( yes "r" | git mergetool submod ) &&
426 test -d submod.orig &&
427 git submodule update -N &&
428 test "$(cat submod)" = "not a submodule" &&
429 output="$(git mergetool --no-prompt)" &&
430 test "$output" = "No files need merging" &&
431 git commit -m "Merge resolved by keeping file" &&
433 git checkout -b test7.d master &&
434 rmdir submod && mv submod.orig submod &&
435 git submodule update -N &&
436 test_must_fail git merge test7 &&
437 test -n "$(git ls-files -u)" &&
438 ( yes "" | git mergetool file1 file2 spaced\ name subdir/file3 >/dev/null 2>&1 ) &&
439 ( yes "" | git mergetool both>/dev/null 2>&1 ) &&
440 ( yes "d" | git mergetool file11 file12 >/dev/null 2>&1 ) &&
441 ( yes "l" | git mergetool submod ) &&
442 test "$(cat submod/bar)" = "master submodule" &&
443 git submodule update -N &&
444 test "$(cat submod/bar)" = "master submodule" &&
445 output="$(git mergetool --no-prompt)" &&
446 test "$output" = "No files need merging" &&
447 git commit -m "Merge resolved by keeping module"
450 test_expect_success 'submodule in subdirectory' '
451 git checkout -b test10 branch1 &&
452 git submodule update -N &&
454 cd subdir &&
455 test_create_repo subdir_module &&
457 cd subdir_module &&
458 : >file15 &&
459 git add file15 &&
460 git commit -m "add initial versions"
462 ) &&
463 git submodule add git://example.com/subsubmodule subdir/subdir_module &&
464 git add subdir/subdir_module &&
465 git commit -m "add submodule in subdirectory" &&
467 git checkout -b test10.a test10 &&
468 git submodule update -N &&
470 cd subdir/subdir_module &&
471 git checkout -b super10.a &&
472 echo test10.a >file15 &&
473 git add file15 &&
474 git commit -m "on branch 10.a"
475 ) &&
476 git add subdir/subdir_module &&
477 git commit -m "change submodule in subdirectory on test10.a" &&
479 git checkout -b test10.b test10 &&
480 git submodule update -N &&
482 cd subdir/subdir_module &&
483 git checkout -b super10.b &&
484 echo test10.b >file15 &&
485 git add file15 &&
486 git commit -m "on branch 10.b"
487 ) &&
488 git add subdir/subdir_module &&
489 git commit -m "change submodule in subdirectory on test10.b" &&
491 test_must_fail git merge test10.a >/dev/null 2>&1 &&
493 cd subdir &&
494 ( yes "l" | git mergetool subdir_module )
495 ) &&
496 test "$(cat subdir/subdir_module/file15)" = "test10.b" &&
497 git submodule update -N &&
498 test "$(cat subdir/subdir_module/file15)" = "test10.b" &&
499 git reset --hard &&
500 git submodule update -N &&
502 test_must_fail git merge test10.a >/dev/null 2>&1 &&
503 ( yes "r" | git mergetool subdir/subdir_module ) &&
504 test "$(cat subdir/subdir_module/file15)" = "test10.b" &&
505 git submodule update -N &&
506 test "$(cat subdir/subdir_module/file15)" = "test10.a" &&
507 git commit -m "branch1 resolved with mergetool" &&
508 rm -rf subdir/subdir_module
511 test_expect_success 'directory vs modified submodule' '
512 git checkout -b test11 branch1 &&
513 mv submod submod-movedaside &&
514 git rm --cached submod &&
515 mkdir submod &&
516 echo not a submodule >submod/file16 &&
517 git add submod/file16 &&
518 git commit -m "Submodule path becomes directory" &&
520 test_must_fail git merge master &&
521 test -n "$(git ls-files -u)" &&
522 ( yes "l" | git mergetool submod ) &&
523 test "$(cat submod/file16)" = "not a submodule" &&
524 rm -rf submod.orig &&
526 git reset --hard >/dev/null 2>&1 &&
527 test_must_fail git merge master &&
528 test -n "$(git ls-files -u)" &&
529 test ! -e submod.orig &&
530 ( yes "r" | git mergetool submod ) &&
531 test -d submod.orig &&
532 test "$(cat submod.orig/file16)" = "not a submodule" &&
533 rm -r submod.orig &&
534 mv submod-movedaside/.git submod &&
535 ( cd submod && git clean -f && git reset --hard ) &&
536 git submodule update -N &&
537 test "$(cat submod/bar)" = "master submodule" &&
538 git reset --hard >/dev/null 2>&1 && rm -rf submod-movedaside &&
540 git checkout -b test11.c master &&
541 git submodule update -N &&
542 test_must_fail git merge test11 &&
543 test -n "$(git ls-files -u)" &&
544 ( yes "l" | git mergetool submod ) &&
545 git submodule update -N &&
546 test "$(cat submod/bar)" = "master submodule" &&
548 git reset --hard >/dev/null 2>&1 &&
549 git submodule update -N &&
550 test_must_fail git merge test11 &&
551 test -n "$(git ls-files -u)" &&
552 test ! -e submod.orig &&
553 ( yes "r" | git mergetool submod ) &&
554 test "$(cat submod/file16)" = "not a submodule" &&
556 git reset --hard master >/dev/null 2>&1 &&
557 ( cd submod && git clean -f && git reset --hard ) &&
558 git submodule update -N
561 test_expect_success 'file with no base' '
562 git checkout -b test13 branch1 &&
563 test_must_fail git merge master &&
564 git mergetool --no-prompt --tool mybase -- both &&
565 >expected &&
566 test_cmp both expected &&
567 git reset --hard master >/dev/null 2>&1
570 test_expect_success 'custom commands override built-ins' '
571 git checkout -b test14 branch1 &&
572 test_config mergetool.defaults.cmd "cat \"\$REMOTE\" >\"\$MERGED\"" &&
573 test_config mergetool.defaults.trustExitCode true &&
574 test_must_fail git merge master &&
575 git mergetool --no-prompt --tool defaults -- both &&
576 echo master both added >expected &&
577 test_cmp both expected &&
578 git reset --hard master >/dev/null 2>&1
581 test_expect_success 'filenames seen by tools start with ./' '
582 git checkout -b test15 branch1 &&
583 test_config mergetool.writeToTemp false &&
584 test_config mergetool.myecho.cmd "echo \"\$LOCAL\"" &&
585 test_config mergetool.myecho.trustExitCode true &&
586 test_must_fail git merge master &&
587 git mergetool --no-prompt --tool myecho -- both >actual &&
588 grep ^\./both_LOCAL_ actual >/dev/null &&
589 git reset --hard master >/dev/null 2>&1
592 test_lazy_prereq MKTEMP '
593 tempdir=$(mktemp -d -t foo.XXXXXX) &&
594 test -d "$tempdir" &&
595 rmdir "$tempdir"
598 test_expect_success MKTEMP 'temporary filenames are used with mergetool.writeToTemp' '
599 git checkout -b test16 branch1 &&
600 test_config mergetool.writeToTemp true &&
601 test_config mergetool.myecho.cmd "echo \"\$LOCAL\"" &&
602 test_config mergetool.myecho.trustExitCode true &&
603 test_must_fail git merge master &&
604 git mergetool --no-prompt --tool myecho -- both >actual &&
605 test_must_fail grep ^\./both_LOCAL_ actual >/dev/null &&
606 grep /both_LOCAL_ actual >/dev/null &&
607 git reset --hard master >/dev/null 2>&1
610 test_expect_success 'diff.orderFile configuration is honored' '
611 test_config diff.orderFile order-file &&
612 test_config mergetool.myecho.cmd "echo \"\$LOCAL\"" &&
613 test_config mergetool.myecho.trustExitCode true &&
614 echo b >order-file &&
615 echo a >>order-file &&
616 git checkout -b order-file-start master &&
617 echo start >a &&
618 echo start >b &&
619 git add a b &&
620 git commit -m start &&
621 git checkout -b order-file-side1 order-file-start &&
622 echo side1 >a &&
623 echo side1 >b &&
624 git add a b &&
625 git commit -m side1 &&
626 git checkout -b order-file-side2 order-file-start &&
627 echo side2 >a &&
628 echo side2 >b &&
629 git add a b &&
630 git commit -m side2 &&
631 test_must_fail git merge order-file-side1 &&
632 cat >expect <<-\EOF &&
633 Merging:
637 git mergetool --no-prompt --tool myecho >output &&
638 git grep --no-index -h -A2 Merging: output >actual &&
639 test_cmp expect actual &&
640 git reset --hard >/dev/null
642 test_expect_success 'mergetool -Oorder-file is honored' '
643 test_config diff.orderFile order-file &&
644 test_config mergetool.myecho.cmd "echo \"\$LOCAL\"" &&
645 test_config mergetool.myecho.trustExitCode true &&
646 test_must_fail git merge order-file-side1 &&
647 cat >expect <<-\EOF &&
648 Merging:
652 git mergetool -O/dev/null --no-prompt --tool myecho >output &&
653 git grep --no-index -h -A2 Merging: output >actual &&
654 test_cmp expect actual &&
655 git reset --hard >/dev/null 2>&1 &&
657 git config --unset diff.orderFile &&
658 test_must_fail git merge order-file-side1 &&
659 cat >expect <<-\EOF &&
660 Merging:
664 git mergetool -Oorder-file --no-prompt --tool myecho >output &&
665 git grep --no-index -h -A2 Merging: output >actual &&
666 test_cmp expect actual &&
667 git reset --hard >/dev/null 2>&1
670 test_done