39469d96d42dff5983f06059155fe2048a0b95bb
   1#!/bin/sh
   2#
   3# Copyright (c) 2008 Charles Bailey
   4#
   5
   6test_description='git mergetool
   7
   8Testing basic merge tool invocation'
   9
  10. ./test-lib.sh
  11
  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
  15
  16test_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 &&
  27        (
  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" &&
  36
  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 &&
  46        (
  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" &&
  57
  58        git checkout -b stash1 master &&
  59        echo stash1 change file11 >file11 &&
  60        git add file11 &&
  61        git commit -m "stash1 changes" &&
  62
  63        git checkout -b stash2 master &&
  64        echo stash2 change file11 >file11 &&
  65        git add file11 &&
  66        git commit -m "stash2 changes" &&
  67
  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 &&
  77        (
  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" &&
  88
  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
  94'
  95
  96test_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"
 112'
 113
 114test_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
 134'
 135
 136test_expect_success 'mergetool in subdir' '
 137        git checkout -b test3 branch1 &&
 138        git submodule update -N &&
 139        (
 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"
 144        )
 145'
 146
 147test_expect_success 'mergetool on file in parent dir' '
 148        (
 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"
 160        )
 161'
 162
 163test_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
 174'
 175
 176test_expect_success 'mergetool merges all from subdir' '
 177        test_config rerere.enabled false &&
 178        (
 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"
 189        )
 190'
 191
 192test_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
 204'
 205
 206test_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 &&
 211
 212        git checkout --detach stash2 &&
 213        test_must_fail git stash apply &&
 214
 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" &&
 220
 221        git commit -am "save the stash resolution" &&
 222
 223        git reset --hard stash2 &&
 224        test_must_fail git stash apply &&
 225
 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"
 231'
 232
 233test_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 &&
 239
 240        ( yes "" | git mergetool subdir ) &&
 241
 242        test "$(cat subdir/file3)" = "master new sub" &&
 243        git reset --hard
 244'
 245
 246test_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
 274'
 275
 276test_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        git reset --hard HEAD
 283'
 284
 285test_expect_success 'deleted vs modified submodule' '
 286        git checkout -b test6 branch1 &&
 287        git submodule update -N &&
 288        mv submod submod-movedaside &&
 289        git rm --cached submod &&
 290        git commit -m "Submodule deleted from branch" &&
 291        git checkout -b test6.a test6 &&
 292        test_must_fail git merge master &&
 293        test -n "$(git ls-files -u)" &&
 294        ( yes "" | git mergetool file1 file2 spaced\ name subdir/file3 >/dev/null 2>&1 ) &&
 295        ( yes "" | git mergetool both >/dev/null 2>&1 ) &&
 296        ( yes "d" | git mergetool file11 file12 >/dev/null 2>&1 ) &&
 297        ( yes "r" | git mergetool submod ) &&
 298        rmdir submod && mv submod-movedaside submod &&
 299        test "$(cat submod/bar)" = "branch1 submodule" &&
 300        git submodule update -N &&
 301        test "$(cat submod/bar)" = "master submodule" &&
 302        output="$(git mergetool --no-prompt)" &&
 303        test "$output" = "No files need merging" &&
 304        git commit -m "Merge resolved by keeping module" &&
 305
 306        mv submod submod-movedaside &&
 307        git checkout -b test6.b test6 &&
 308        git submodule update -N &&
 309        test_must_fail git merge master &&
 310        test -n "$(git ls-files -u)" &&
 311        ( yes "" | git mergetool file1 file2 spaced\ name subdir/file3 >/dev/null 2>&1 ) &&
 312        ( yes "" | git mergetool both >/dev/null 2>&1 ) &&
 313        ( yes "d" | git mergetool file11 file12 >/dev/null 2>&1 ) &&
 314        ( yes "l" | git mergetool submod ) &&
 315        test ! -e submod &&
 316        output="$(git mergetool --no-prompt)" &&
 317        test "$output" = "No files need merging" &&
 318        git commit -m "Merge resolved by deleting module" &&
 319
 320        mv submod-movedaside submod &&
 321        git checkout -b test6.c master &&
 322        git submodule update -N &&
 323        test_must_fail git merge test6 &&
 324        test -n "$(git ls-files -u)" &&
 325        ( yes "" | git mergetool file1 file2 spaced\ name subdir/file3 >/dev/null 2>&1 ) &&
 326        ( yes "" | git mergetool both >/dev/null 2>&1 ) &&
 327        ( yes "d" | git mergetool file11 file12 >/dev/null 2>&1 ) &&
 328        ( yes "r" | git mergetool submod ) &&
 329        test ! -e submod &&
 330        test -d submod.orig &&
 331        git submodule update -N &&
 332        output="$(git mergetool --no-prompt)" &&
 333        test "$output" = "No files need merging" &&
 334        git commit -m "Merge resolved by deleting module" &&
 335        mv submod.orig submod &&
 336
 337        git checkout -b test6.d master &&
 338        git submodule update -N &&
 339        test_must_fail git merge test6 &&
 340        test -n "$(git ls-files -u)" &&
 341        ( yes "" | git mergetool file1 file2 spaced\ name subdir/file3 >/dev/null 2>&1 ) &&
 342        ( yes "" | git mergetool both >/dev/null 2>&1 ) &&
 343        ( yes "d" | git mergetool file11 file12 >/dev/null 2>&1 ) &&
 344        ( yes "l" | git mergetool submod ) &&
 345        test "$(cat submod/bar)" = "master submodule" &&
 346        git submodule update -N &&
 347        test "$(cat submod/bar)" = "master submodule" &&
 348        output="$(git mergetool --no-prompt)" &&
 349        test "$output" = "No files need merging" &&
 350        git commit -m "Merge resolved by keeping module" &&
 351        git reset --hard HEAD
 352'
 353
 354test_expect_success 'file vs modified submodule' '
 355        git checkout -b test7 branch1 &&
 356        git submodule update -N &&
 357        mv submod submod-movedaside &&
 358        git rm --cached submod &&
 359        echo not a submodule >submod &&
 360        git add submod &&
 361        git commit -m "Submodule path becomes file" &&
 362        git checkout -b test7.a branch1 &&
 363        test_must_fail git merge master &&
 364        test -n "$(git ls-files -u)" &&
 365        ( yes "" | git mergetool file1 file2 spaced\ name subdir/file3 >/dev/null 2>&1 ) &&
 366        ( yes "" | git mergetool both >/dev/null 2>&1 ) &&
 367        ( yes "d" | git mergetool file11 file12 >/dev/null 2>&1 ) &&
 368        ( yes "r" | git mergetool submod ) &&
 369        rmdir submod && mv submod-movedaside submod &&
 370        test "$(cat submod/bar)" = "branch1 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
 377        mv submod submod-movedaside &&
 378        git checkout -b test7.b test7 &&
 379        test_must_fail git merge master &&
 380        test -n "$(git ls-files -u)" &&
 381        ( yes "" | git mergetool file1 file2 spaced\ name subdir/file3 >/dev/null 2>&1 ) &&
 382        ( yes "" | git mergetool both >/dev/null 2>&1 ) &&
 383        ( yes "d" | git mergetool file11 file12 >/dev/null 2>&1 ) &&
 384        ( yes "l" | git mergetool submod ) &&
 385        git submodule update -N &&
 386        test "$(cat submod)" = "not a submodule" &&
 387        output="$(git mergetool --no-prompt)" &&
 388        test "$output" = "No files need merging" &&
 389        git commit -m "Merge resolved by keeping file" &&
 390
 391        git checkout -b test7.c master &&
 392        rmdir submod && mv submod-movedaside submod &&
 393        test ! -e submod.orig &&
 394        git submodule update -N &&
 395        test_must_fail git merge test7 &&
 396        test -n "$(git ls-files -u)" &&
 397        ( yes "" | git mergetool file1 file2 spaced\ name subdir/file3 >/dev/null 2>&1 ) &&
 398        ( yes "" | git mergetool both >/dev/null 2>&1 ) &&
 399        ( yes "d" | git mergetool file11 file12 >/dev/null 2>&1 ) &&
 400        ( yes "r" | git mergetool submod ) &&
 401        test -d submod.orig &&
 402        git submodule update -N &&
 403        test "$(cat submod)" = "not a submodule" &&
 404        output="$(git mergetool --no-prompt)" &&
 405        test "$output" = "No files need merging" &&
 406        git commit -m "Merge resolved by keeping file" &&
 407
 408        git checkout -b test7.d master &&
 409        rmdir submod && mv submod.orig submod &&
 410        git submodule update -N &&
 411        test_must_fail git merge test7 &&
 412        test -n "$(git ls-files -u)" &&
 413        ( yes "" | git mergetool file1 file2 spaced\ name subdir/file3 >/dev/null 2>&1 ) &&
 414        ( yes "" | git mergetool both>/dev/null 2>&1 ) &&
 415        ( yes "d" | git mergetool file11 file12 >/dev/null 2>&1 ) &&
 416        ( yes "l" | git mergetool submod ) &&
 417        test "$(cat submod/bar)" = "master submodule" &&
 418        git submodule update -N &&
 419        test "$(cat submod/bar)" = "master submodule" &&
 420        output="$(git mergetool --no-prompt)" &&
 421        test "$output" = "No files need merging" &&
 422        git commit -m "Merge resolved by keeping module"
 423'
 424
 425test_expect_success 'submodule in subdirectory' '
 426        git checkout -b test10 branch1 &&
 427        git submodule update -N &&
 428        (
 429                cd subdir &&
 430                test_create_repo subdir_module &&
 431                (
 432                cd subdir_module &&
 433                : >file15 &&
 434                git add file15 &&
 435                git commit -m "add initial versions"
 436                )
 437        ) &&
 438        git submodule add git://example.com/subsubmodule subdir/subdir_module &&
 439        git add subdir/subdir_module &&
 440        git commit -m "add submodule in subdirectory" &&
 441
 442        git checkout -b test10.a test10 &&
 443        git submodule update -N &&
 444        (
 445        cd subdir/subdir_module &&
 446                git checkout -b super10.a &&
 447                echo test10.a >file15 &&
 448                git add file15 &&
 449                git commit -m "on branch 10.a"
 450        ) &&
 451        git add subdir/subdir_module &&
 452        git commit -m "change submodule in subdirectory on test10.a" &&
 453
 454        git checkout -b test10.b test10 &&
 455        git submodule update -N &&
 456        (
 457                cd subdir/subdir_module &&
 458                git checkout -b super10.b &&
 459                echo test10.b >file15 &&
 460                git add file15 &&
 461                git commit -m "on branch 10.b"
 462        ) &&
 463        git add subdir/subdir_module &&
 464        git commit -m "change submodule in subdirectory on test10.b" &&
 465
 466        test_must_fail git merge test10.a >/dev/null 2>&1 &&
 467        (
 468                cd subdir &&
 469                ( yes "l" | git mergetool subdir_module )
 470        ) &&
 471        test "$(cat subdir/subdir_module/file15)" = "test10.b" &&
 472        git submodule update -N &&
 473        test "$(cat subdir/subdir_module/file15)" = "test10.b" &&
 474        git reset --hard &&
 475        git submodule update -N &&
 476
 477        test_must_fail git merge test10.a >/dev/null 2>&1 &&
 478        ( yes "r" | git mergetool subdir/subdir_module ) &&
 479        test "$(cat subdir/subdir_module/file15)" = "test10.b" &&
 480        git submodule update -N &&
 481        test "$(cat subdir/subdir_module/file15)" = "test10.a" &&
 482        git commit -m "branch1 resolved with mergetool" &&
 483        rm -rf subdir/subdir_module
 484'
 485
 486test_expect_success 'directory vs modified submodule' '
 487        git checkout -b test11 branch1 &&
 488        mv submod submod-movedaside &&
 489        git rm --cached submod &&
 490        mkdir submod &&
 491        echo not a submodule >submod/file16 &&
 492        git add submod/file16 &&
 493        git commit -m "Submodule path becomes directory" &&
 494
 495        test_must_fail git merge master &&
 496        test -n "$(git ls-files -u)" &&
 497        ( yes "l" | git mergetool submod ) &&
 498        test "$(cat submod/file16)" = "not a submodule" &&
 499        rm -rf submod.orig &&
 500
 501        git reset --hard >/dev/null 2>&1 &&
 502        test_must_fail git merge master &&
 503        test -n "$(git ls-files -u)" &&
 504        test ! -e submod.orig &&
 505        ( yes "r" | git mergetool submod ) &&
 506        test -d submod.orig &&
 507        test "$(cat submod.orig/file16)" = "not a submodule" &&
 508        rm -r submod.orig &&
 509        mv submod-movedaside/.git submod &&
 510        ( cd submod && git clean -f && git reset --hard ) &&
 511        git submodule update -N &&
 512        test "$(cat submod/bar)" = "master submodule" &&
 513        git reset --hard >/dev/null 2>&1 && rm -rf submod-movedaside &&
 514
 515        git checkout -b test11.c master &&
 516        git submodule update -N &&
 517        test_must_fail git merge test11 &&
 518        test -n "$(git ls-files -u)" &&
 519        ( yes "l" | git mergetool submod ) &&
 520        git submodule update -N &&
 521        test "$(cat submod/bar)" = "master submodule" &&
 522
 523        git reset --hard >/dev/null 2>&1 &&
 524        git submodule update -N &&
 525        test_must_fail git merge test11 &&
 526        test -n "$(git ls-files -u)" &&
 527        test ! -e submod.orig &&
 528        ( yes "r" | git mergetool submod ) &&
 529        test "$(cat submod/file16)" = "not a submodule" &&
 530
 531        git reset --hard master >/dev/null 2>&1 &&
 532        ( cd submod && git clean -f && git reset --hard ) &&
 533        git submodule update -N
 534'
 535
 536test_expect_success 'file with no base' '
 537        git checkout -b test13 branch1 &&
 538        test_must_fail git merge master &&
 539        git mergetool --no-prompt --tool mybase -- both &&
 540        >expected &&
 541        test_cmp both expected &&
 542        git reset --hard master >/dev/null 2>&1
 543'
 544
 545test_expect_success 'custom commands override built-ins' '
 546        git checkout -b test14 branch1 &&
 547        test_config mergetool.defaults.cmd "cat \"\$REMOTE\" >\"\$MERGED\"" &&
 548        test_config mergetool.defaults.trustExitCode true &&
 549        test_must_fail git merge master &&
 550        git mergetool --no-prompt --tool defaults -- both &&
 551        echo master both added >expected &&
 552        test_cmp both expected &&
 553        git reset --hard master >/dev/null 2>&1
 554'
 555
 556test_expect_success 'filenames seen by tools start with ./' '
 557        git checkout -b test15 branch1 &&
 558        test_config mergetool.writeToTemp false &&
 559        test_config mergetool.myecho.cmd "echo \"\$LOCAL\"" &&
 560        test_config mergetool.myecho.trustExitCode true &&
 561        test_must_fail git merge master &&
 562        git mergetool --no-prompt --tool myecho -- both >actual &&
 563        grep ^\./both_LOCAL_ actual >/dev/null &&
 564        git reset --hard master >/dev/null 2>&1
 565'
 566
 567test_expect_success 'temporary filenames are used with mergetool.writeToTemp' '
 568        git checkout -b test16 branch1 &&
 569        test_config mergetool.writeToTemp true &&
 570        test_config mergetool.myecho.cmd "echo \"\$LOCAL\"" &&
 571        test_config mergetool.myecho.trustExitCode true &&
 572        test_must_fail git merge master &&
 573        git mergetool --no-prompt --tool myecho -- both >actual &&
 574        test_must_fail grep ^\./both_LOCAL_ actual >/dev/null &&
 575        grep /both_LOCAL_ actual >/dev/null &&
 576        git reset --hard master >/dev/null 2>&1
 577'
 578
 579test_done