(CommandList children: [ (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:test_description) op: Equal rhs: {(SQ <"git mergetool\n"> <"\n"> <"Testing basic merge tool invocation">)} spids: [13] ) ] spids: [13] ) (C {(.)} {(./test-lib.sh)}) (C {(test_expect_success)} {(SQ <setup>)} { (SQ <"\n"> <"\ttest_config rerere.enabled true &&\n"> <"\techo master >file1 &&\n"> <"\techo master spaced >\"spaced name\" &&\n"> <"\techo master file11 >file11 &&\n"> <"\techo master file12 >file12 &&\n"> <"\techo master file13 >file13 &&\n"> <"\techo master file14 >file14 &&\n"> <"\tmkdir subdir &&\n"> <"\techo master sub >subdir/file3 &&\n"> <"\ttest_create_repo submod &&\n"> <"\t(\n"> <"\t\tcd submod &&\n"> <"\t\t: >foo &&\n"> <"\t\tgit add foo &&\n"> <"\t\tgit commit -m \"Add foo\"\n"> <"\t) &&\n"> <"\tgit submodule add git://example.com/submod submod &&\n"> <"\tgit add file1 \"spaced name\" file1[1-4] subdir/file3 .gitmodules submod &&\n"> <"\tgit commit -m \"add initial versions\" &&\n"> <"\n"> <"\tgit checkout -b branch1 master &&\n"> <"\tgit submodule update -N &&\n"> <"\techo branch1 change >file1 &&\n"> <"\techo branch1 newfile >file2 &&\n"> <"\techo branch1 spaced >\"spaced name\" &&\n"> <"\techo branch1 both added >both &&\n"> <"\techo branch1 change file11 >file11 &&\n"> <"\techo branch1 change file13 >file13 &&\n"> <"\techo branch1 sub >subdir/file3 &&\n"> <"\t(\n"> <"\t\tcd submod &&\n"> <"\t\techo branch1 submodule >bar &&\n"> <"\t\tgit add bar &&\n"> <"\t\tgit commit -m \"Add bar on branch1\" &&\n"> <"\t\tgit checkout -b submod-branch1\n"> <"\t) &&\n"> <"\tgit add file1 \"spaced name\" file11 file13 file2 subdir/file3 submod &&\n"> <"\tgit add both &&\n"> <"\tgit rm file12 &&\n"> <"\tgit commit -m \"branch1 changes\" &&\n"> <"\n"> <"\tgit checkout -b stash1 master &&\n"> <"\techo stash1 change file11 >file11 &&\n"> <"\tgit add file11 &&\n"> <"\tgit commit -m \"stash1 changes\" &&\n"> <"\n"> <"\tgit checkout -b stash2 master &&\n"> <"\techo stash2 change file11 >file11 &&\n"> <"\tgit add file11 &&\n"> <"\tgit commit -m \"stash2 changes\" &&\n"> <"\n"> <"\tgit checkout master &&\n"> <"\tgit submodule update -N &&\n"> <"\techo master updated >file1 &&\n"> <"\techo master new >file2 &&\n"> <"\techo master updated spaced >\"spaced name\" &&\n"> <"\techo master both added >both &&\n"> <"\techo master updated file12 >file12 &&\n"> <"\techo master updated file14 >file14 &&\n"> <"\techo master new sub >subdir/file3 &&\n"> <"\t(\n"> <"\t\tcd submod &&\n"> <"\t\techo master submodule >bar &&\n"> <"\t\tgit add bar &&\n"> <"\t\tgit commit -m \"Add bar on master\" &&\n"> <"\t\tgit checkout -b submod-master\n"> <"\t) &&\n"> <"\tgit add file1 \"spaced name\" file12 file14 file2 subdir/file3 submod &&\n"> <"\tgit add both &&\n"> <"\tgit rm file11 &&\n"> <"\tgit commit -m \"master updates\" &&\n"> <"\n"> <"\tgit config merge.tool mytool &&\n"> <"\tgit config mergetool.mytool.cmd \"cat \\\"\\$REMOTE\\\" >\\\"\\$MERGED\\\"\" &&\n"> <"\tgit config mergetool.mytool.trustExitCode true &&\n"> <"\tgit config mergetool.mybase.cmd \"cat \\\"\\$BASE\\\" >\\\"\\$MERGED\\\"\" &&\n"> <"\tgit config mergetool.mybase.trustExitCode true\n"> ) } ) (C {(test_expect_success)} {(SQ <"custom mergetool">)} { (SQ <"\n"> <"\tgit checkout -b test1 branch1 &&\n"> <"\tgit submodule update -N &&\n"> <"\ttest_must_fail git merge master >/dev/null 2>&1 &&\n"> <"\t( yes \"\" | git mergetool both >/dev/null 2>&1 ) &&\n"> <"\t( yes \"\" | git mergetool file1 file1 ) &&\n"> <"\t( yes \"\" | git mergetool file2 \"spaced name\" >/dev/null 2>&1 ) &&\n"> <"\t( yes \"\" | git mergetool subdir/file3 >/dev/null 2>&1 ) &&\n"> <"\t( yes \"d\" | git mergetool file11 >/dev/null 2>&1 ) &&\n"> <"\t( yes \"d\" | git mergetool file12 >/dev/null 2>&1 ) &&\n"> <"\t( yes \"l\" | git mergetool submod >/dev/null 2>&1 ) &&\n"> <"\ttest \"$(cat file1)\" = \"master updated\" &&\n"> <"\ttest \"$(cat file2)\" = \"master new\" &&\n"> <"\ttest \"$(cat subdir/file3)\" = \"master new sub\" &&\n"> <"\ttest \"$(cat submod/bar)\" = \"branch1 submodule\" &&\n"> <"\tgit commit -m \"branch1 resolved with mergetool\"\n"> ) } ) (C {(test_expect_success)} {(SQ <"mergetool crlf">)} { (SQ <"\n"> <"\ttest_config core.autocrlf true &&\n"> <"\tgit checkout -b test2 branch1 &&\n"> <"\ttest_must_fail git merge master >/dev/null 2>&1 &&\n"> <"\t( yes \"\" | git mergetool file1 >/dev/null 2>&1 ) &&\n"> <"\t( yes \"\" | git mergetool file2 >/dev/null 2>&1 ) &&\n"> <"\t( yes \"\" | git mergetool \"spaced name\" >/dev/null 2>&1 ) &&\n"> <"\t( yes \"\" | git mergetool both >/dev/null 2>&1 ) &&\n"> <"\t( yes \"\" | git mergetool subdir/file3 >/dev/null 2>&1 ) &&\n"> <"\t( yes \"d\" | git mergetool file11 >/dev/null 2>&1 ) &&\n"> <"\t( yes \"d\" | git mergetool file12 >/dev/null 2>&1 ) &&\n"> <"\t( yes \"r\" | git mergetool submod >/dev/null 2>&1 ) &&\n"> <"\ttest \"$(printf x | cat file1 -)\" = \"$(printf \"master updated\\r\\nx\")\" &&\n"> <"\ttest \"$(printf x | cat file2 -)\" = \"$(printf \"master new\\r\\nx\")\" &&\n"> <"\ttest \"$(printf x | cat subdir/file3 -)\" = \"$(printf \"master new sub\\r\\nx\")\" &&\n"> <"\tgit submodule update -N &&\n"> <"\ttest \"$(cat submod/bar)\" = \"master submodule\" &&\n"> <"\tgit commit -m \"branch1 resolved with mergetool - autocrlf\" &&\n"> <"\ttest_config core.autocrlf false &&\n"> <"\tgit reset --hard\n"> ) } ) (C {(test_expect_success)} {(SQ <"mergetool in subdir">)} { (SQ <"\n"> <"\tgit checkout -b test3 branch1 &&\n"> <"\tgit submodule update -N &&\n"> <"\t(\n"> <"\t\tcd subdir &&\n"> <"\t\ttest_must_fail git merge master >/dev/null 2>&1 &&\n"> <"\t\t( yes \"\" | git mergetool file3 >/dev/null 2>&1 ) &&\n"> <"\t\ttest \"$(cat file3)\" = \"master new sub\"\n"> <"\t)\n"> ) } ) (C {(test_expect_success)} {(SQ <"mergetool on file in parent dir">)} { (SQ <"\n"> <"\t(\n"> <"\t\tcd subdir &&\n"> <"\t\t( yes \"\" | git mergetool ../file1 >/dev/null 2>&1 ) &&\n"> <"\t\t( yes \"\" | git mergetool ../file2 ../spaced\\ name >/dev/null 2>&1 ) &&\n"> <"\t\t( yes \"\" | git mergetool ../both >/dev/null 2>&1 ) &&\n"> <"\t\t( yes \"d\" | git mergetool ../file11 >/dev/null 2>&1 ) &&\n"> <"\t\t( yes \"d\" | git mergetool ../file12 >/dev/null 2>&1 ) &&\n"> <"\t\t( yes \"l\" | git mergetool ../submod >/dev/null 2>&1 ) &&\n"> <"\t\ttest \"$(cat ../file1)\" = \"master updated\" &&\n"> <"\t\ttest \"$(cat ../file2)\" = \"master new\" &&\n"> <"\t\ttest \"$(cat ../submod/bar)\" = \"branch1 submodule\" &&\n"> <"\t\tgit commit -m \"branch1 resolved with mergetool - subdir\"\n"> <"\t)\n"> ) } ) (C {(test_expect_success)} {(SQ <"mergetool skips autoresolved">)} { (SQ <"\n"> <"\tgit checkout -b test4 branch1 &&\n"> <"\tgit submodule update -N &&\n"> <"\ttest_must_fail git merge master &&\n"> <"\ttest -n \"$(git ls-files -u)\" &&\n"> <"\t( yes \"d\" | git mergetool file11 >/dev/null 2>&1 ) &&\n"> <"\t( yes \"d\" | git mergetool file12 >/dev/null 2>&1 ) &&\n"> <"\t( yes \"l\" | git mergetool submod >/dev/null 2>&1 ) &&\n"> <"\toutput=\"$(git mergetool --no-prompt)\" &&\n"> <"\ttest \"$output\" = \"No files need merging\" &&\n"> <"\tgit reset --hard\n"> ) } ) (C {(test_expect_success)} {(SQ <"mergetool merges all from subdir">)} { (SQ <"\n"> <"\ttest_config rerere.enabled false &&\n"> <"\t(\n"> <"\t\tcd subdir &&\n"> <"\t\ttest_must_fail git merge master &&\n"> <"\t\t( yes \"r\" | git mergetool ../submod ) &&\n"> <"\t\t( yes \"d\" \"d\" | git mergetool --no-prompt ) &&\n"> <"\t\ttest \"$(cat ../file1)\" = \"master updated\" &&\n"> <"\t\ttest \"$(cat ../file2)\" = \"master new\" &&\n"> <"\t\ttest \"$(cat file3)\" = \"master new sub\" &&\n"> <"\t\t( cd .. && git submodule update -N ) &&\n"> <"\t\ttest \"$(cat ../submod/bar)\" = \"master submodule\" &&\n"> <"\t\tgit commit -m \"branch2 resolved by mergetool from subdir\"\n"> <"\t)\n"> ) } ) (C {(test_expect_success)} {(SQ <"mergetool skips resolved paths when rerere is active">)} { (SQ <"\n"> <"\ttest_config rerere.enabled true &&\n"> <"\trm -rf .git/rr-cache &&\n"> <"\tgit checkout -b test5 branch1 &&\n"> <"\tgit submodule update -N &&\n"> <"\ttest_must_fail git merge master >/dev/null 2>&1 &&\n"> <"\t( yes \"l\" | git mergetool --no-prompt submod >/dev/null 2>&1 ) &&\n"> <"\t( yes \"d\" \"d\" | git mergetool --no-prompt >/dev/null 2>&1 ) &&\n"> <"\tgit submodule update -N &&\n"> <"\toutput=\"$(yes \"n\" | git mergetool --no-prompt)\" &&\n"> <"\ttest \"$output\" = \"No files need merging\" &&\n"> <"\tgit reset --hard\n"> ) } ) (C {(test_expect_success)} {(SQ <"conflicted stash sets up rerere">)} { (SQ <"\n"> <"\ttest_config rerere.enabled true &&\n"> <"\tgit checkout stash1 &&\n"> <"\techo \"Conflicting stash content\" >file11 &&\n"> <"\tgit stash &&\n"> <"\n"> <"\tgit checkout --detach stash2 &&\n"> <"\ttest_must_fail git stash apply &&\n"> <"\n"> <"\ttest -n \"$(git ls-files -u)\" &&\n"> <"\tconflicts=\"$(git rerere remaining)\" &&\n"> <"\ttest \"$conflicts\" = \"file11\" &&\n"> <"\toutput=\"$(git mergetool --no-prompt)\" &&\n"> <"\ttest \"$output\" != \"No files need merging\" &&\n"> <"\n"> <"\tgit commit -am \"save the stash resolution\" &&\n"> <"\n"> <"\tgit reset --hard stash2 &&\n"> <"\ttest_must_fail git stash apply &&\n"> <"\n"> <"\ttest -n \"$(git ls-files -u)\" &&\n"> <"\tconflicts=\"$(git rerere remaining)\" &&\n"> <"\ttest -z \"$conflicts\" &&\n"> <"\toutput=\"$(git mergetool --no-prompt)\" &&\n"> <"\ttest \"$output\" = \"No files need merging\"\n"> ) } ) (C {(test_expect_success)} {(SQ <"mergetool takes partial path">)} { (SQ <"\n"> <"\tgit reset --hard &&\n"> <"\ttest_config rerere.enabled false &&\n"> <"\tgit checkout -b test12 branch1 &&\n"> <"\tgit submodule update -N &&\n"> <"\ttest_must_fail git merge master &&\n"> <"\n"> <"\t( yes \"\" | git mergetool subdir ) &&\n"> <"\n"> <"\ttest \"$(cat subdir/file3)\" = \"master new sub\" &&\n"> <"\tgit reset --hard\n"> ) } ) (C {(test_expect_success)} {(SQ <"mergetool delete/delete conflict">)} { (SQ <"\n"> <"\tgit checkout -b delete-base branch1 &&\n"> <"\tmkdir -p a/a &&\n"> <"\t(echo one; echo two; echo 3; echo 4) >a/a/file.txt &&\n"> <"\tgit add a/a/file.txt &&\n"> <"\tgit commit -m\"base file\" &&\n"> <"\tgit checkout -b move-to-b delete-base &&\n"> <"\tmkdir -p b/b &&\n"> <"\tgit mv a/a/file.txt b/b/file.txt &&\n"> <"\t(echo one; echo two; echo 4) >b/b/file.txt &&\n"> <"\tgit commit -a -m\"move to b\" &&\n"> <"\tgit checkout -b move-to-c delete-base &&\n"> <"\tmkdir -p c/c &&\n"> <"\tgit mv a/a/file.txt c/c/file.txt &&\n"> <"\t(echo one; echo two; echo 3) >c/c/file.txt &&\n"> <"\tgit commit -a -m\"move to c\" &&\n"> <"\ttest_must_fail git merge move-to-b &&\n"> <"\techo d | git mergetool a/a/file.txt &&\n"> <"\t! test -f a/a/file.txt &&\n"> <"\tgit reset --hard HEAD &&\n"> <"\ttest_must_fail git merge move-to-b &&\n"> <"\techo m | git mergetool a/a/file.txt &&\n"> <"\ttest -f b/b/file.txt &&\n"> <"\tgit reset --hard HEAD &&\n"> <"\ttest_must_fail git merge move-to-b &&\n"> <"\t! echo a | git mergetool a/a/file.txt &&\n"> <"\t! test -f a/a/file.txt &&\n"> <"\tgit reset --hard HEAD\n"> ) } ) (C {(test_expect_success)} {(SQ <"mergetool produces no errors when keepBackup is used">)} { (SQ <"\n"> <"\ttest_config mergetool.keepBackup true &&\n"> <"\ttest_must_fail git merge move-to-b &&\n"> <"\t: >expect &&\n"> <"\techo d | git mergetool a/a/file.txt 2>actual &&\n"> <"\ttest_cmp expect actual &&\n"> <"\t! test -d a &&\n"> <"\tgit reset --hard HEAD\n"> ) } ) (C {(test_expect_success)} {(SQ <"mergetool honors tempfile config for deleted files">)} { (SQ <"\n"> <"\ttest_config mergetool.keepTemporaries false &&\n"> <"\ttest_must_fail git merge move-to-b &&\n"> <"\techo d | git mergetool a/a/file.txt &&\n"> <"\t! test -d a &&\n"> <"\tgit reset --hard HEAD\n"> ) } ) (C {(test_expect_success)} {(SQ <"mergetool keeps tempfiles when aborting delete/delete">)} { (SQ <"\n"> <"\ttest_config mergetool.keepTemporaries true &&\n"> <"\ttest_must_fail git merge move-to-b &&\n"> <"\t! (echo a; echo n) | git mergetool a/a/file.txt &&\n"> <"\ttest -d a/a &&\n"> <"\tcat >expect <<-\\EOF &&\n"> <"\tfile_BASE_.txt\n"> <"\tfile_LOCAL_.txt\n"> <"\tfile_REMOTE_.txt\n"> <"\tEOF\n"> <"\tls -1 a/a | sed -e \"s/[0-9]*//g\" >actual &&\n"> <"\ttest_cmp expect actual &&\n"> <"\tgit clean -fdx &&\n"> <"\tgit reset --hard HEAD\n"> ) } ) (C {(test_expect_success)} {(SQ <"deleted vs modified submodule">)} { (SQ <"\n"> <"\tgit checkout -b test6 branch1 &&\n"> <"\tgit submodule update -N &&\n"> <"\tmv submod submod-movedaside &&\n"> <"\tgit rm --cached submod &&\n"> <"\tgit commit -m \"Submodule deleted from branch\" &&\n"> <"\tgit checkout -b test6.a test6 &&\n"> <"\ttest_must_fail git merge master &&\n"> <"\ttest -n \"$(git ls-files -u)\" &&\n"> < "\t( yes \"\" | git mergetool file1 file2 spaced\\ name subdir/file3 >/dev/null 2>&1 ) &&\n" > <"\t( yes \"\" | git mergetool both >/dev/null 2>&1 ) &&\n"> <"\t( yes \"d\" | git mergetool file11 file12 >/dev/null 2>&1 ) &&\n"> <"\t( yes \"r\" | git mergetool submod ) &&\n"> <"\trmdir submod && mv submod-movedaside submod &&\n"> <"\ttest \"$(cat submod/bar)\" = \"branch1 submodule\" &&\n"> <"\tgit submodule update -N &&\n"> <"\ttest \"$(cat submod/bar)\" = \"master submodule\" &&\n"> <"\toutput=\"$(git mergetool --no-prompt)\" &&\n"> <"\ttest \"$output\" = \"No files need merging\" &&\n"> <"\tgit commit -m \"Merge resolved by keeping module\" &&\n"> <"\n"> <"\tmv submod submod-movedaside &&\n"> <"\tgit checkout -b test6.b test6 &&\n"> <"\tgit submodule update -N &&\n"> <"\ttest_must_fail git merge master &&\n"> <"\ttest -n \"$(git ls-files -u)\" &&\n"> < "\t( yes \"\" | git mergetool file1 file2 spaced\\ name subdir/file3 >/dev/null 2>&1 ) &&\n" > <"\t( yes \"\" | git mergetool both >/dev/null 2>&1 ) &&\n"> <"\t( yes \"d\" | git mergetool file11 file12 >/dev/null 2>&1 ) &&\n"> <"\t( yes \"l\" | git mergetool submod ) &&\n"> <"\ttest ! -e submod &&\n"> <"\toutput=\"$(git mergetool --no-prompt)\" &&\n"> <"\ttest \"$output\" = \"No files need merging\" &&\n"> <"\tgit commit -m \"Merge resolved by deleting module\" &&\n"> <"\n"> <"\tmv submod-movedaside submod &&\n"> <"\tgit checkout -b test6.c master &&\n"> <"\tgit submodule update -N &&\n"> <"\ttest_must_fail git merge test6 &&\n"> <"\ttest -n \"$(git ls-files -u)\" &&\n"> < "\t( yes \"\" | git mergetool file1 file2 spaced\\ name subdir/file3 >/dev/null 2>&1 ) &&\n" > <"\t( yes \"\" | git mergetool both >/dev/null 2>&1 ) &&\n"> <"\t( yes \"d\" | git mergetool file11 file12 >/dev/null 2>&1 ) &&\n"> <"\t( yes \"r\" | git mergetool submod ) &&\n"> <"\ttest ! -e submod &&\n"> <"\ttest -d submod.orig &&\n"> <"\tgit submodule update -N &&\n"> <"\toutput=\"$(git mergetool --no-prompt)\" &&\n"> <"\ttest \"$output\" = \"No files need merging\" &&\n"> <"\tgit commit -m \"Merge resolved by deleting module\" &&\n"> <"\tmv submod.orig submod &&\n"> <"\n"> <"\tgit checkout -b test6.d master &&\n"> <"\tgit submodule update -N &&\n"> <"\ttest_must_fail git merge test6 &&\n"> <"\ttest -n \"$(git ls-files -u)\" &&\n"> <"\t( yes \"\" | git mergetool file1 file2 spaced\\ name subdir/file3 >/dev/null 2>&1 ) &&\n"> <"\t( yes \"\" | git mergetool both >/dev/null 2>&1 ) &&\n"> <"\t( yes \"d\" | git mergetool file11 file12 >/dev/null 2>&1 ) &&\n"> <"\t( yes \"l\" | git mergetool submod ) &&\n"> <"\ttest \"$(cat submod/bar)\" = \"master submodule\" &&\n"> <"\tgit submodule update -N &&\n"> <"\ttest \"$(cat submod/bar)\" = \"master submodule\" &&\n"> <"\toutput=\"$(git mergetool --no-prompt)\" &&\n"> <"\ttest \"$output\" = \"No files need merging\" &&\n"> <"\tgit commit -m \"Merge resolved by keeping module\" &&\n"> <"\tgit reset --hard HEAD\n"> ) } ) (C {(test_expect_success)} {(SQ <"file vs modified submodule">)} { (SQ <"\n"> <"\tgit checkout -b test7 branch1 &&\n"> <"\tgit submodule update -N &&\n"> <"\tmv submod submod-movedaside &&\n"> <"\tgit rm --cached submod &&\n"> <"\techo not a submodule >submod &&\n"> <"\tgit add submod &&\n"> <"\tgit commit -m \"Submodule path becomes file\" &&\n"> <"\tgit checkout -b test7.a branch1 &&\n"> <"\ttest_must_fail git merge master &&\n"> <"\ttest -n \"$(git ls-files -u)\" &&\n"> <"\t( yes \"\" | git mergetool file1 file2 spaced\\ name subdir/file3 >/dev/null 2>&1 ) &&\n"> <"\t( yes \"\" | git mergetool both >/dev/null 2>&1 ) &&\n"> <"\t( yes \"d\" | git mergetool file11 file12 >/dev/null 2>&1 ) &&\n"> <"\t( yes \"r\" | git mergetool submod ) &&\n"> <"\trmdir submod && mv submod-movedaside submod &&\n"> <"\ttest \"$(cat submod/bar)\" = \"branch1 submodule\" &&\n"> <"\tgit submodule update -N &&\n"> <"\ttest \"$(cat submod/bar)\" = \"master submodule\" &&\n"> <"\toutput=\"$(git mergetool --no-prompt)\" &&\n"> <"\ttest \"$output\" = \"No files need merging\" &&\n"> <"\tgit commit -m \"Merge resolved by keeping module\" &&\n"> <"\n"> <"\tmv submod submod-movedaside &&\n"> <"\tgit checkout -b test7.b test7 &&\n"> <"\ttest_must_fail git merge master &&\n"> <"\ttest -n \"$(git ls-files -u)\" &&\n"> < "\t( yes \"\" | git mergetool file1 file2 spaced\\ name subdir/file3 >/dev/null 2>&1 ) &&\n" > <"\t( yes \"\" | git mergetool both >/dev/null 2>&1 ) &&\n"> <"\t( yes \"d\" | git mergetool file11 file12 >/dev/null 2>&1 ) &&\n"> <"\t( yes \"l\" | git mergetool submod ) &&\n"> <"\tgit submodule update -N &&\n"> <"\ttest \"$(cat submod)\" = \"not a submodule\" &&\n"> <"\toutput=\"$(git mergetool --no-prompt)\" &&\n"> <"\ttest \"$output\" = \"No files need merging\" &&\n"> <"\tgit commit -m \"Merge resolved by keeping file\" &&\n"> <"\n"> <"\tgit checkout -b test7.c master &&\n"> <"\trmdir submod && mv submod-movedaside submod &&\n"> <"\ttest ! -e submod.orig &&\n"> <"\tgit submodule update -N &&\n"> <"\ttest_must_fail git merge test7 &&\n"> <"\ttest -n \"$(git ls-files -u)\" &&\n"> < "\t( yes \"\" | git mergetool file1 file2 spaced\\ name subdir/file3 >/dev/null 2>&1 ) &&\n" > <"\t( yes \"\" | git mergetool both >/dev/null 2>&1 ) &&\n"> <"\t( yes \"d\" | git mergetool file11 file12 >/dev/null 2>&1 ) &&\n"> <"\t( yes \"r\" | git mergetool submod ) &&\n"> <"\ttest -d submod.orig &&\n"> <"\tgit submodule update -N &&\n"> <"\ttest \"$(cat submod)\" = \"not a submodule\" &&\n"> <"\toutput=\"$(git mergetool --no-prompt)\" &&\n"> <"\ttest \"$output\" = \"No files need merging\" &&\n"> <"\tgit commit -m \"Merge resolved by keeping file\" &&\n"> <"\n"> <"\tgit checkout -b test7.d master &&\n"> <"\trmdir submod && mv submod.orig submod &&\n"> <"\tgit submodule update -N &&\n"> <"\ttest_must_fail git merge test7 &&\n"> <"\ttest -n \"$(git ls-files -u)\" &&\n"> < "\t( yes \"\" | git mergetool file1 file2 spaced\\ name subdir/file3 >/dev/null 2>&1 ) &&\n" > <"\t( yes \"\" | git mergetool both>/dev/null 2>&1 ) &&\n"> <"\t( yes \"d\" | git mergetool file11 file12 >/dev/null 2>&1 ) &&\n"> <"\t( yes \"l\" | git mergetool submod ) &&\n"> <"\ttest \"$(cat submod/bar)\" = \"master submodule\" &&\n"> <"\tgit submodule update -N &&\n"> <"\ttest \"$(cat submod/bar)\" = \"master submodule\" &&\n"> <"\toutput=\"$(git mergetool --no-prompt)\" &&\n"> <"\ttest \"$output\" = \"No files need merging\" &&\n"> <"\tgit commit -m \"Merge resolved by keeping module\"\n"> ) } ) (C {(test_expect_success)} {(SQ <"submodule in subdirectory">)} { (SQ <"\n"> <"\tgit checkout -b test10 branch1 &&\n"> <"\tgit submodule update -N &&\n"> <"\t(\n"> <"\t\tcd subdir &&\n"> <"\t\ttest_create_repo subdir_module &&\n"> <"\t\t(\n"> <"\t\tcd subdir_module &&\n"> <"\t\t: >file15 &&\n"> <"\t\tgit add file15 &&\n"> <"\t\tgit commit -m \"add initial versions\"\n"> <"\t\t)\n"> <"\t) &&\n"> <"\tgit submodule add git://example.com/subsubmodule subdir/subdir_module &&\n"> <"\tgit add subdir/subdir_module &&\n"> <"\tgit commit -m \"add submodule in subdirectory\" &&\n"> <"\n"> <"\tgit checkout -b test10.a test10 &&\n"> <"\tgit submodule update -N &&\n"> <"\t(\n"> <"\tcd subdir/subdir_module &&\n"> <"\t\tgit checkout -b super10.a &&\n"> <"\t\techo test10.a >file15 &&\n"> <"\t\tgit add file15 &&\n"> <"\t\tgit commit -m \"on branch 10.a\"\n"> <"\t) &&\n"> <"\tgit add subdir/subdir_module &&\n"> <"\tgit commit -m \"change submodule in subdirectory on test10.a\" &&\n"> <"\n"> <"\tgit checkout -b test10.b test10 &&\n"> <"\tgit submodule update -N &&\n"> <"\t(\n"> <"\t\tcd subdir/subdir_module &&\n"> <"\t\tgit checkout -b super10.b &&\n"> <"\t\techo test10.b >file15 &&\n"> <"\t\tgit add file15 &&\n"> <"\t\tgit commit -m \"on branch 10.b\"\n"> <"\t) &&\n"> <"\tgit add subdir/subdir_module &&\n"> <"\tgit commit -m \"change submodule in subdirectory on test10.b\" &&\n"> <"\n"> <"\ttest_must_fail git merge test10.a >/dev/null 2>&1 &&\n"> <"\t(\n"> <"\t\tcd subdir &&\n"> <"\t\t( yes \"l\" | git mergetool subdir_module )\n"> <"\t) &&\n"> <"\ttest \"$(cat subdir/subdir_module/file15)\" = \"test10.b\" &&\n"> <"\tgit submodule update -N &&\n"> <"\ttest \"$(cat subdir/subdir_module/file15)\" = \"test10.b\" &&\n"> <"\tgit reset --hard &&\n"> <"\tgit submodule update -N &&\n"> <"\n"> <"\ttest_must_fail git merge test10.a >/dev/null 2>&1 &&\n"> <"\t( yes \"r\" | git mergetool subdir/subdir_module ) &&\n"> <"\ttest \"$(cat subdir/subdir_module/file15)\" = \"test10.b\" &&\n"> <"\tgit submodule update -N &&\n"> <"\ttest \"$(cat subdir/subdir_module/file15)\" = \"test10.a\" &&\n"> <"\tgit commit -m \"branch1 resolved with mergetool\" &&\n"> <"\trm -rf subdir/subdir_module\n"> ) } ) (C {(test_expect_success)} {(SQ <"directory vs modified submodule">)} { (SQ <"\n"> <"\tgit checkout -b test11 branch1 &&\n"> <"\tmv submod submod-movedaside &&\n"> <"\tgit rm --cached submod &&\n"> <"\tmkdir submod &&\n"> <"\techo not a submodule >submod/file16 &&\n"> <"\tgit add submod/file16 &&\n"> <"\tgit commit -m \"Submodule path becomes directory\" &&\n"> <"\n"> <"\ttest_must_fail git merge master &&\n"> <"\ttest -n \"$(git ls-files -u)\" &&\n"> <"\t( yes \"l\" | git mergetool submod ) &&\n"> <"\ttest \"$(cat submod/file16)\" = \"not a submodule\" &&\n"> <"\trm -rf submod.orig &&\n"> <"\n"> <"\tgit reset --hard >/dev/null 2>&1 &&\n"> <"\ttest_must_fail git merge master &&\n"> <"\ttest -n \"$(git ls-files -u)\" &&\n"> <"\ttest ! -e submod.orig &&\n"> <"\t( yes \"r\" | git mergetool submod ) &&\n"> <"\ttest -d submod.orig &&\n"> <"\ttest \"$(cat submod.orig/file16)\" = \"not a submodule\" &&\n"> <"\trm -r submod.orig &&\n"> <"\tmv submod-movedaside/.git submod &&\n"> <"\t( cd submod && git clean -f && git reset --hard ) &&\n"> <"\tgit submodule update -N &&\n"> <"\ttest \"$(cat submod/bar)\" = \"master submodule\" &&\n"> <"\tgit reset --hard >/dev/null 2>&1 && rm -rf submod-movedaside &&\n"> <"\n"> <"\tgit checkout -b test11.c master &&\n"> <"\tgit submodule update -N &&\n"> <"\ttest_must_fail git merge test11 &&\n"> <"\ttest -n \"$(git ls-files -u)\" &&\n"> <"\t( yes \"l\" | git mergetool submod ) &&\n"> <"\tgit submodule update -N &&\n"> <"\ttest \"$(cat submod/bar)\" = \"master submodule\" &&\n"> <"\n"> <"\tgit reset --hard >/dev/null 2>&1 &&\n"> <"\tgit submodule update -N &&\n"> <"\ttest_must_fail git merge test11 &&\n"> <"\ttest -n \"$(git ls-files -u)\" &&\n"> <"\ttest ! -e submod.orig &&\n"> <"\t( yes \"r\" | git mergetool submod ) &&\n"> <"\ttest \"$(cat submod/file16)\" = \"not a submodule\" &&\n"> <"\n"> <"\tgit reset --hard master >/dev/null 2>&1 &&\n"> <"\t( cd submod && git clean -f && git reset --hard ) &&\n"> <"\tgit submodule update -N\n"> ) } ) (C {(test_expect_success)} {(SQ <"file with no base">)} { (SQ <"\n"> <"\tgit checkout -b test13 branch1 &&\n"> <"\ttest_must_fail git merge master &&\n"> <"\tgit mergetool --no-prompt --tool mybase -- both &&\n"> <"\t>expected &&\n"> <"\ttest_cmp both expected &&\n"> <"\tgit reset --hard master >/dev/null 2>&1\n"> ) } ) (C {(test_expect_success)} {(SQ <"custom commands override built-ins">)} { (SQ <"\n"> <"\tgit checkout -b test14 branch1 &&\n"> < "\ttest_config mergetool.defaults.cmd \"cat \\\"\\$REMOTE\\\" >\\\"\\$MERGED\\\"\" &&\n" > <"\ttest_config mergetool.defaults.trustExitCode true &&\n"> <"\ttest_must_fail git merge master &&\n"> <"\tgit mergetool --no-prompt --tool defaults -- both &&\n"> <"\techo master both added >expected &&\n"> <"\ttest_cmp both expected &&\n"> <"\tgit reset --hard master >/dev/null 2>&1\n"> ) } ) (C {(test_expect_success)} {(SQ <"filenames seen by tools start with ./">)} { (SQ <"\n"> <"\tgit checkout -b test15 branch1 &&\n"> <"\ttest_config mergetool.writeToTemp false &&\n"> <"\ttest_config mergetool.myecho.cmd \"echo \\\"\\$LOCAL\\\"\" &&\n"> <"\ttest_config mergetool.myecho.trustExitCode true &&\n"> <"\ttest_must_fail git merge master &&\n"> <"\tgit mergetool --no-prompt --tool myecho -- both >actual &&\n"> <"\tgrep ^\\./both_LOCAL_ actual >/dev/null &&\n"> <"\tgit reset --hard master >/dev/null 2>&1\n"> ) } ) (C {(test_lazy_prereq)} {(MKTEMP)} {(SQ <"\n"> <"\ttempdir=$(mktemp -d -t foo.XXXXXX) &&\n"> <"\ttest -d \"$tempdir\"\n">)} ) (C {(test_expect_success)} {(MKTEMP)} {(SQ <"temporary filenames are used with mergetool.writeToTemp">)} { (SQ <"\n"> <"\tgit checkout -b test16 branch1 &&\n"> <"\ttest_config mergetool.writeToTemp true &&\n"> <"\ttest_config mergetool.myecho.cmd \"echo \\\"\\$LOCAL\\\"\" &&\n"> <"\ttest_config mergetool.myecho.trustExitCode true &&\n"> <"\ttest_must_fail git merge master &&\n"> <"\tgit mergetool --no-prompt --tool myecho -- both >actual &&\n"> <"\ttest_must_fail grep ^\\./both_LOCAL_ actual >/dev/null &&\n"> <"\tgrep /both_LOCAL_ actual >/dev/null &&\n"> <"\tgit reset --hard master >/dev/null 2>&1\n"> ) } ) (C {(test_expect_success)} {(SQ <"diff.orderFile configuration is honored">)} { (SQ <"\n"> <"\ttest_config diff.orderFile order-file &&\n"> <"\ttest_config mergetool.myecho.cmd \"echo \\\"\\$LOCAL\\\"\" &&\n"> <"\ttest_config mergetool.myecho.trustExitCode true &&\n"> <"\techo b >order-file &&\n"> <"\techo a >>order-file &&\n"> <"\tgit checkout -b order-file-start master &&\n"> <"\techo start >a &&\n"> <"\techo start >b &&\n"> <"\tgit add a b &&\n"> <"\tgit commit -m start &&\n"> <"\tgit checkout -b order-file-side1 order-file-start &&\n"> <"\techo side1 >a &&\n"> <"\techo side1 >b &&\n"> <"\tgit add a b &&\n"> <"\tgit commit -m side1 &&\n"> <"\tgit checkout -b order-file-side2 order-file-start &&\n"> <"\techo side2 >a &&\n"> <"\techo side2 >b &&\n"> <"\tgit add a b &&\n"> <"\tgit commit -m side2 &&\n"> <"\ttest_must_fail git merge order-file-side1 &&\n"> <"\tcat >expect <<-\\EOF &&\n"> <"\t\tMerging:\n"> <"\t\tb\n"> <"\t\ta\n"> <"\tEOF\n"> <"\tgit mergetool --no-prompt --tool myecho >output &&\n"> <"\tgit grep --no-index -h -A2 Merging: output >actual &&\n"> <"\ttest_cmp expect actual &&\n"> <"\tgit reset --hard >/dev/null\n"> ) } ) (C {(test_expect_success)} {(SQ <"mergetool -Oorder-file is honored">)} { (SQ <"\n"> <"\ttest_config diff.orderFile order-file &&\n"> <"\ttest_config mergetool.myecho.cmd \"echo \\\"\\$LOCAL\\\"\" &&\n"> <"\ttest_config mergetool.myecho.trustExitCode true &&\n"> <"\ttest_must_fail git merge order-file-side1 &&\n"> <"\tcat >expect <<-\\EOF &&\n"> <"\t\tMerging:\n"> <"\t\ta\n"> <"\t\tb\n"> <"\tEOF\n"> <"\tgit mergetool -O/dev/null --no-prompt --tool myecho >output &&\n"> <"\tgit grep --no-index -h -A2 Merging: output >actual &&\n"> <"\ttest_cmp expect actual &&\n"> <"\tgit reset --hard >/dev/null 2>&1 &&\n"> <"\n"> <"\tgit config --unset diff.orderFile &&\n"> <"\ttest_must_fail git merge order-file-side1 &&\n"> <"\tcat >expect <<-\\EOF &&\n"> <"\t\tMerging:\n"> <"\t\tb\n"> <"\t\ta\n"> <"\tEOF\n"> <"\tgit mergetool -Oorder-file --no-prompt --tool myecho >output &&\n"> <"\tgit grep --no-index -h -A2 Merging: output >actual &&\n"> <"\ttest_cmp expect actual &&\n"> <"\tgit reset --hard >/dev/null 2>&1\n"> ) } ) (C {(test_done)}) ] )