{"thread":{"id":"29394","subject":"Interesting behavior in git mergetool with no BASE revision","startedAt":"2012-01-18T23:05:56Z","lastAt":"2012-01-20T18:28:25Z","messageCount":17,"participants":["Jason Wenger","David Aguilar","Junio C Hamano"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"182752","messageId":"CAM6z=4_+yC4EnL9SZFd6=Nxs89QeHevNCakVzVycGBe7G+nTKQ@mail.gmail.com","threadId":"29394","inReplyTo":null,"subject":"Interesting behavior in git mergetool with no BASE revision","fromName":"Jason Wenger","fromEmail":"jcwenger@gmail.com","sentAt":"2012-01-18T23:05:56Z","receivedAt":"2012-01-18T23:05:56Z","isPatch":false,"sender":{"key":"jcwenger@gmail.com","avatar":null},"body":"Doing a git merge on 1.7.4.3, on a case where both branches have a\nfile created, and the base does not.  Per git-mergetool:\n\n\"the configured command line will be invoked with $BASE set to the\nname of a temporary file containing the common base for the merge, if\navailable;\"\n\nSo testing in this case, I set my mergetool cmd as \"echo $MERGED\n$LOCAL $REMOTE $BASE\", and I get the following:\n\ncio/.cproject ./cio/.cproject.LOCAL.9029.cproject\n./cio/.cproject.REMOTE.9029.cproject\n./cio/.cproject.BASE.9029.cproject\n\nls -a cio shows the following files:\n\n.cproject\n.cproject.LOCAL.9325.cproject\n.cproject.BACKUP.9325.cproject\n.cproject.REMOTE.9325.cproject\n\nSo the lack of base file makes sense -- There is no base to start\nfrom.  However, $BASE evaluates to ./cio/.cproject.BASE.9029.cproject,\nwhich is a nonexistent file.  This makes my actual mergetool upset to\nno end.  Intuitively from documents, I would expect $BASE to evaluate\nto an empty string in this case.\n\nIs this intended behavior?\n\n--Jason C. Wenger\n"},{"id":"182827","messageId":"CAJDDKr5mUiJkNk-urNn5fP5x+gkzaTfx2y=K1S0AJZCy7Muwdg@mail.gmail.com","threadId":"29394","inReplyTo":"CAM6z=4_+yC4EnL9SZFd6=Nxs89QeHevNCakVzVycGBe7G+nTKQ@mail.gmail.com","subject":"Re: Interesting behavior in git mergetool with no BASE revision","fromName":"David Aguilar","fromEmail":"davvid@gmail.com","sentAt":"2012-01-20T06:43:24Z","receivedAt":"2012-01-20T06:43:24Z","isPatch":false,"sender":{"key":"davvid@gmail.com","avatar":"https://avatars.githubusercontent.com/u/13196?v=4"},"body":"On Wed, Jan 18, 2012 at 3:05 PM, Jason Wenger <jcwenger@gmail.com> wrote:\n> Doing a git merge on 1.7.4.3, on a case where both branches have a\n> file created, and the base does not.  Per git-mergetool:\n>\n> \"the configured command line will be invoked with $BASE set to the\n> name of a temporary file containing the common base for the merge, if\n> available;\"\n>\n> So testing in this case, I set my mergetool cmd as \"echo $MERGED\n> $LOCAL $REMOTE $BASE\", and I get the following:\n\nI have not seen this in practice.  Maybe escape the variables?\n\nIn any case, I added a test case to cover this case.  I think we\nshould at least provide an empty file in place of a missing $BASE.\n\n\n\n> cio/.cproject ./cio/.cproject.LOCAL.9029.cproject\n> ./cio/.cproject.REMOTE.9029.cproject\n> ./cio/.cproject.BASE.9029.cproject\n>\n> ls -a cio shows the following files:\n>\n> .cproject\n> .cproject.LOCAL.9325.cproject\n> .cproject.BACKUP.9325.cproject\n> .cproject.REMOTE.9325.cproject\n>\n> So the lack of base file makes sense -- There is no base to start\n> from.  However, $BASE evaluates to ./cio/.cproject.BASE.9029.cproject,\n> which is a nonexistent file.  This makes my actual mergetool upset to\n> no end.  Intuitively from documents, I would expect $BASE to evaluate\n> to an empty string in this case.\n>\n> Is this intended behavior?\n\nNot really.  I'll send a patch shortly.\n-- \n            David\n"},{"id":"182828","messageId":"1327042010-79552-1-git-send-email-davvid@gmail.com","threadId":"29394","inReplyTo":"CAJDDKr5mUiJkNk-urNn5fP5x+gkzaTfx2y=K1S0AJZCy7Muwdg@mail.gmail.com","subject":"[PATCH] mergetool: Provide an empty file when no base exists","fromName":"David Aguilar","fromEmail":"davvid@gmail.com","sentAt":"2012-01-20T06:46:50Z","receivedAt":"2012-01-20T06:46:50Z","isPatch":true,"sender":{"key":"davvid@gmail.com","avatar":"https://avatars.githubusercontent.com/u/13196?v=4"},"body":"Some mergetools cannot cope when $BASE is missing.\nThis can happen when two branches add the same file.\nProvide an empty file to make these tools happy.\n\nReported-by: Jason Wenger <jcwenger@gmail.com>\nSigned-off-by: David Aguilar <davvid@gmail.com>\n---\n git-mergetool.sh     |    6 +++++-\n t/t7610-mergetool.sh |   27 ++++++++++++++++++++++++++-\n 2 files changed, 31 insertions(+), 2 deletions(-)\n\ndiff --git a/git-mergetool.sh b/git-mergetool.sh\nindex 085e213..8521b81 100755\n--- a/git-mergetool.sh\n+++ b/git-mergetool.sh\n@@ -224,7 +224,11 @@ merge_file () {\n     mv -- \"$MERGED\" \"$BACKUP\"\n     cp -- \"$BACKUP\" \"$MERGED\"\n \n-    base_present   && checkout_staged_file 1 \"$MERGED\" \"$BASE\"\n+    if base_present; then\n+\tcheckout_staged_file 1 \"$MERGED\" \"$BASE\"\n+    else\n+\ttouch \"$BASE\"\n+    fi\n     local_present  && checkout_staged_file 2 \"$MERGED\" \"$LOCAL\"\n     remote_present && checkout_staged_file 3 \"$MERGED\" \"$REMOTE\"\n \ndiff --git a/t/t7610-mergetool.sh b/t/t7610-mergetool.sh\nindex 4aab2a7..2272743 100755\n--- a/t/t7610-mergetool.sh\n+++ b/t/t7610-mergetool.sh\n@@ -39,6 +39,7 @@ test_expect_success 'setup' '\n     echo branch1 change >file1 &&\n     echo branch1 newfile >file2 &&\n     echo branch1 spaced >\"spaced name\" &&\n+    echo branch1 both added > both &&\n     echo branch1 change file11 >file11 &&\n     echo branch1 change file13 >file13 &&\n     echo branch1 sub >subdir/file3 &&\n@@ -50,6 +51,7 @@ test_expect_success 'setup' '\n \tgit checkout -b submod-branch1\n     ) &&\n     git add file1 \"spaced name\" file11 file13 file2 subdir/file3 submod &&\n+    git add both &&\n     git rm file12 &&\n     git commit -m \"branch1 changes\" &&\n \n@@ -58,6 +60,7 @@ test_expect_success 'setup' '\n     echo master updated >file1 &&\n     echo master new >file2 &&\n     echo master updated spaced >\"spaced name\" &&\n+    echo master both added > both &&\n     echo master updated file12 >file12 &&\n     echo master updated file14 >file14 &&\n     echo master new sub >subdir/file3 &&\n@@ -69,18 +72,22 @@ test_expect_success 'setup' '\n \tgit checkout -b submod-master\n     ) &&\n     git add file1 \"spaced name\" file12 file14 file2 subdir/file3 submod &&\n+    git add both &&\n     git rm file11 &&\n     git commit -m \"master updates\" &&\n \n     git config merge.tool mytool &&\n     git config mergetool.mytool.cmd \"cat \\\"\\$REMOTE\\\" >\\\"\\$MERGED\\\"\" &&\n-    git config mergetool.mytool.trustExitCode true\n+    git config mergetool.mytool.trustExitCode true &&\n+    git config mergetool.mybase.cmd \"cat \\\"\\$BASE\\\" >\\\"\\$MERGED\\\"\" &&\n+    git config mergetool.mybase.trustExitCode true\n '\n \n test_expect_success 'custom mergetool' '\n     git checkout -b test1 branch1 &&\n     git submodule update -N &&\n     test_must_fail git merge master >/dev/null 2>&1 &&\n+    ( yes \"\" | git mergetool both >/dev/null 2>&1 ) &&\n     ( yes \"\" | git mergetool file1 file1 ) &&\n     ( yes \"\" | git mergetool file2 \"spaced name\" >/dev/null 2>&1 ) &&\n     ( yes \"\" | git mergetool subdir/file3 >/dev/null 2>&1 ) &&\n@@ -101,6 +108,7 @@ test_expect_success 'mergetool crlf' '\n     ( yes \"\" | git mergetool file1 >/dev/null 2>&1 ) &&\n     ( yes \"\" | git mergetool file2 >/dev/null 2>&1 ) &&\n     ( yes \"\" | git mergetool \"spaced name\" >/dev/null 2>&1 ) &&\n+    ( yes \"\" | git mergetool both >/dev/null 2>&1 ) &&\n     ( yes \"\" | git mergetool subdir/file3 >/dev/null 2>&1 ) &&\n     ( yes \"d\" | git mergetool file11 >/dev/null 2>&1 ) &&\n     ( yes \"d\" | git mergetool file12 >/dev/null 2>&1 ) &&\n@@ -131,6 +139,7 @@ test_expect_success 'mergetool on file in parent dir' '\n \tcd subdir &&\n \t( yes \"\" | git mergetool ../file1 >/dev/null 2>&1 ) &&\n \t( yes \"\" | git mergetool ../file2 ../spaced\\ name >/dev/null 2>&1 ) &&\n+\t( yes \"\" | git mergetool ../both >/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@@ -212,6 +221,7 @@ test_expect_success 'deleted vs modified submodule' '\n     test_must_fail git merge master &&\n     test -n \"$(git ls-files -u)\" &&\n     ( yes \"\" | git mergetool file1 file2 spaced\\ name subdir/file3 >/dev/null 2>&1 ) &&\n+    ( yes \"\" | git mergetool both >/dev/null 2>&1 ) &&\n     ( yes \"d\" | git mergetool file11 file12 >/dev/null 2>&1 ) &&\n     ( yes \"r\" | git mergetool submod ) &&\n     rmdir submod && mv submod-movedaside submod &&\n@@ -228,6 +238,7 @@ test_expect_success 'deleted vs modified submodule' '\n     test_must_fail git merge master &&\n     test -n \"$(git ls-files -u)\" &&\n     ( yes \"\" | git mergetool file1 file2 spaced\\ name subdir/file3 >/dev/null 2>&1 ) &&\n+    ( yes \"\" | git mergetool both >/dev/null 2>&1 ) &&\n     ( yes \"d\" | git mergetool file11 file12 >/dev/null 2>&1 ) &&\n     ( yes \"l\" | git mergetool submod ) &&\n     test ! -e submod &&\n@@ -241,6 +252,7 @@ test_expect_success 'deleted vs modified submodule' '\n     test_must_fail git merge test6 &&\n     test -n \"$(git ls-files -u)\" &&\n     ( yes \"\" | git mergetool file1 file2 spaced\\ name subdir/file3 >/dev/null 2>&1 ) &&\n+    ( yes \"\" | git mergetool both >/dev/null 2>&1 ) &&\n     ( yes \"d\" | git mergetool file11 file12 >/dev/null 2>&1 ) &&\n     ( yes \"r\" | git mergetool submod ) &&\n     test ! -e submod &&\n@@ -256,6 +268,7 @@ test_expect_success 'deleted vs modified submodule' '\n     test_must_fail git merge test6 &&\n     test -n \"$(git ls-files -u)\" &&\n     ( yes \"\" | git mergetool file1 file2 spaced\\ name subdir/file3 >/dev/null 2>&1 ) &&\n+    ( yes \"\" | git mergetool both >/dev/null 2>&1 ) &&\n     ( yes \"d\" | git mergetool file11 file12 >/dev/null 2>&1 ) &&\n     ( yes \"l\" | git mergetool submod ) &&\n     test \"$(cat submod/bar)\" = \"master submodule\" &&\n@@ -279,6 +292,7 @@ test_expect_success 'file vs modified submodule' '\n     test_must_fail git merge master &&\n     test -n \"$(git ls-files -u)\" &&\n     ( yes \"\" | git mergetool file1 file2 spaced\\ name subdir/file3 >/dev/null 2>&1 ) &&\n+    ( yes \"\" | git mergetool both >/dev/null 2>&1 ) &&\n     ( yes \"d\" | git mergetool file11 file12 >/dev/null 2>&1 ) &&\n     ( yes \"r\" | git mergetool submod ) &&\n     rmdir submod && mv submod-movedaside submod &&\n@@ -294,6 +308,7 @@ test_expect_success 'file vs modified submodule' '\n     test_must_fail git merge master &&\n     test -n \"$(git ls-files -u)\" &&\n     ( yes \"\" | git mergetool file1 file2 spaced\\ name subdir/file3 >/dev/null 2>&1 ) &&\n+    ( yes \"\" | git mergetool both >/dev/null 2>&1 ) &&\n     ( yes \"d\" | git mergetool file11 file12 >/dev/null 2>&1 ) &&\n     ( yes \"l\" | git mergetool submod ) &&\n     git submodule update -N &&\n@@ -309,6 +324,7 @@ test_expect_success 'file vs modified submodule' '\n     test_must_fail git merge test7 &&\n     test -n \"$(git ls-files -u)\" &&\n     ( yes \"\" | git mergetool file1 file2 spaced\\ name subdir/file3 >/dev/null 2>&1 ) &&\n+    ( yes \"\" | git mergetool both >/dev/null 2>&1 ) &&\n     ( yes \"d\" | git mergetool file11 file12 >/dev/null 2>&1 ) &&\n     ( yes \"r\" | git mergetool submod ) &&\n     test -d submod.orig &&\n@@ -324,6 +340,7 @@ test_expect_success 'file vs modified submodule' '\n     test_must_fail git merge test7 &&\n     test -n \"$(git ls-files -u)\" &&\n     ( yes \"\" | git mergetool file1 file2 spaced\\ name subdir/file3 >/dev/null 2>&1 ) &&\n+    ( yes \"\" | git mergetool both>/dev/null 2>&1 ) &&\n     ( yes \"d\" | git mergetool file11 file12 >/dev/null 2>&1 ) &&\n     ( yes \"l\" | git mergetool submod ) &&\n     test \"$(cat submod/bar)\" = \"master submodule\" &&\n@@ -445,4 +462,12 @@ test_expect_success 'directory vs modified submodule' '\n     git submodule update -N\n '\n \n+test_expect_success 'file with no base' '\n+    git checkout -b test13 branch1 &&\n+    test_must_fail git merge master &&\n+    git mergetool --no-prompt --tool mybase -- base &&\n+    test \"$(cat \"$MERGED\")\" = \"\" &&\n+    git reset --hard master >/dev/null 2>&1\n+'\n+\n test_done\n-- \n1.7.9.rc2.1.gb566f\n"},{"id":"182829","messageId":"CAJDDKr42Rewono2fvvpk=wi_W3ey4m7GJVQiPgxsctQr-pHDQw@mail.gmail.com","threadId":"29394","inReplyTo":"1327042010-79552-1-git-send-email-davvid@gmail.com","subject":"Re: [PATCH] mergetool: Provide an empty file when no base exists","fromName":"David Aguilar","fromEmail":"davvid@gmail.com","sentAt":"2012-01-20T06:57:43Z","receivedAt":"2012-01-20T06:57:43Z","isPatch":true,"sender":{"key":"davvid@gmail.com","avatar":"https://avatars.githubusercontent.com/u/13196?v=4"},"body":"[apologies for forgetting to cc: you on the patch Jason]\n\nOn Thu, Jan 19, 2012 at 10:46 PM, David Aguilar <davvid@gmail.com> wrote:\n> Some mergetools cannot cope when $BASE is missing.\n> This can happen when two branches add the same file.\n\nThis might be better worded as \"when two branches independently add\nthe same filename\".\nFeel free to squash... or I'll resend if you prefer.\n\nLet me know if this does the trick for you, Jason.  The test case is\nhappy; I hope your mergetool is as well.\n\nCheers,\nDavid\n\n> Provide an empty file to make these tools happy.\n>\n> Reported-by: Jason Wenger <jcwenger@gmail.com>\n> Signed-off-by: David Aguilar <davvid@gmail.com>\n> ---\n>  git-mergetool.sh     |    6 +++++-\n>  t/t7610-mergetool.sh |   27 ++++++++++++++++++++++++++-\n>  2 files changed, 31 insertions(+), 2 deletions(-)\n>\n> diff --git a/git-mergetool.sh b/git-mergetool.sh\n> index 085e213..8521b81 100755\n> --- a/git-mergetool.sh\n> +++ b/git-mergetool.sh\n> @@ -224,7 +224,11 @@ merge_file () {\n>     mv -- \"$MERGED\" \"$BACKUP\"\n>     cp -- \"$BACKUP\" \"$MERGED\"\n>\n> -    base_present   && checkout_staged_file 1 \"$MERGED\" \"$BASE\"\n> +    if base_present; then\n> +       checkout_staged_file 1 \"$MERGED\" \"$BASE\"\n> +    else\n> +       touch \"$BASE\"\n> +    fi\n>     local_present  && checkout_staged_file 2 \"$MERGED\" \"$LOCAL\"\n>     remote_present && checkout_staged_file 3 \"$MERGED\" \"$REMOTE\"\n>\n> diff --git a/t/t7610-mergetool.sh b/t/t7610-mergetool.sh\n> index 4aab2a7..2272743 100755\n> --- a/t/t7610-mergetool.sh\n> +++ b/t/t7610-mergetool.sh\n> @@ -39,6 +39,7 @@ test_expect_success 'setup' '\n>     echo branch1 change >file1 &&\n>     echo branch1 newfile >file2 &&\n>     echo branch1 spaced >\"spaced name\" &&\n> +    echo branch1 both added > both &&\n>     echo branch1 change file11 >file11 &&\n>     echo branch1 change file13 >file13 &&\n>     echo branch1 sub >subdir/file3 &&\n> @@ -50,6 +51,7 @@ test_expect_success 'setup' '\n>        git checkout -b submod-branch1\n>     ) &&\n>     git add file1 \"spaced name\" file11 file13 file2 subdir/file3 submod &&\n> +    git add both &&\n>     git rm file12 &&\n>     git commit -m \"branch1 changes\" &&\n>\n> @@ -58,6 +60,7 @@ test_expect_success 'setup' '\n>     echo master updated >file1 &&\n>     echo master new >file2 &&\n>     echo master updated spaced >\"spaced name\" &&\n> +    echo master both added > both &&\n>     echo master updated file12 >file12 &&\n>     echo master updated file14 >file14 &&\n>     echo master new sub >subdir/file3 &&\n> @@ -69,18 +72,22 @@ test_expect_success 'setup' '\n>        git checkout -b submod-master\n>     ) &&\n>     git add file1 \"spaced name\" file12 file14 file2 subdir/file3 submod &&\n> +    git add both &&\n>     git rm file11 &&\n>     git commit -m \"master updates\" &&\n>\n>     git config merge.tool mytool &&\n>     git config mergetool.mytool.cmd \"cat \\\"\\$REMOTE\\\" >\\\"\\$MERGED\\\"\" &&\n> -    git config mergetool.mytool.trustExitCode true\n> +    git config mergetool.mytool.trustExitCode true &&\n> +    git config mergetool.mybase.cmd \"cat \\\"\\$BASE\\\" >\\\"\\$MERGED\\\"\" &&\n> +    git config mergetool.mybase.trustExitCode true\n>  '\n>\n>  test_expect_success 'custom mergetool' '\n>     git checkout -b test1 branch1 &&\n>     git submodule update -N &&\n>     test_must_fail git merge master >/dev/null 2>&1 &&\n> +    ( yes \"\" | git mergetool both >/dev/null 2>&1 ) &&\n>     ( yes \"\" | git mergetool file1 file1 ) &&\n>     ( yes \"\" | git mergetool file2 \"spaced name\" >/dev/null 2>&1 ) &&\n>     ( yes \"\" | git mergetool subdir/file3 >/dev/null 2>&1 ) &&\n> @@ -101,6 +108,7 @@ test_expect_success 'mergetool crlf' '\n>     ( yes \"\" | git mergetool file1 >/dev/null 2>&1 ) &&\n>     ( yes \"\" | git mergetool file2 >/dev/null 2>&1 ) &&\n>     ( yes \"\" | git mergetool \"spaced name\" >/dev/null 2>&1 ) &&\n> +    ( yes \"\" | git mergetool both >/dev/null 2>&1 ) &&\n>     ( yes \"\" | git mergetool subdir/file3 >/dev/null 2>&1 ) &&\n>     ( yes \"d\" | git mergetool file11 >/dev/null 2>&1 ) &&\n>     ( yes \"d\" | git mergetool file12 >/dev/null 2>&1 ) &&\n> @@ -131,6 +139,7 @@ test_expect_success 'mergetool on file in parent dir' '\n>        cd subdir &&\n>        ( yes \"\" | git mergetool ../file1 >/dev/null 2>&1 ) &&\n>        ( yes \"\" | git mergetool ../file2 ../spaced\\ name >/dev/null 2>&1 ) &&\n> +       ( yes \"\" | git mergetool ../both >/dev/null 2>&1 ) &&\n>        ( yes \"d\" | git mergetool ../file11 >/dev/null 2>&1 ) &&\n>        ( yes \"d\" | git mergetool ../file12 >/dev/null 2>&1 ) &&\n>        ( yes \"l\" | git mergetool ../submod >/dev/null 2>&1 ) &&\n> @@ -212,6 +221,7 @@ test_expect_success 'deleted vs modified submodule' '\n>     test_must_fail git merge master &&\n>     test -n \"$(git ls-files -u)\" &&\n>     ( yes \"\" | git mergetool file1 file2 spaced\\ name subdir/file3 >/dev/null 2>&1 ) &&\n> +    ( yes \"\" | git mergetool both >/dev/null 2>&1 ) &&\n>     ( yes \"d\" | git mergetool file11 file12 >/dev/null 2>&1 ) &&\n>     ( yes \"r\" | git mergetool submod ) &&\n>     rmdir submod && mv submod-movedaside submod &&\n> @@ -228,6 +238,7 @@ test_expect_success 'deleted vs modified submodule' '\n>     test_must_fail git merge master &&\n>     test -n \"$(git ls-files -u)\" &&\n>     ( yes \"\" | git mergetool file1 file2 spaced\\ name subdir/file3 >/dev/null 2>&1 ) &&\n> +    ( yes \"\" | git mergetool both >/dev/null 2>&1 ) &&\n>     ( yes \"d\" | git mergetool file11 file12 >/dev/null 2>&1 ) &&\n>     ( yes \"l\" | git mergetool submod ) &&\n>     test ! -e submod &&\n> @@ -241,6 +252,7 @@ test_expect_success 'deleted vs modified submodule' '\n>     test_must_fail git merge test6 &&\n>     test -n \"$(git ls-files -u)\" &&\n>     ( yes \"\" | git mergetool file1 file2 spaced\\ name subdir/file3 >/dev/null 2>&1 ) &&\n> +    ( yes \"\" | git mergetool both >/dev/null 2>&1 ) &&\n>     ( yes \"d\" | git mergetool file11 file12 >/dev/null 2>&1 ) &&\n>     ( yes \"r\" | git mergetool submod ) &&\n>     test ! -e submod &&\n> @@ -256,6 +268,7 @@ test_expect_success 'deleted vs modified submodule' '\n>     test_must_fail git merge test6 &&\n>     test -n \"$(git ls-files -u)\" &&\n>     ( yes \"\" | git mergetool file1 file2 spaced\\ name subdir/file3 >/dev/null 2>&1 ) &&\n> +    ( yes \"\" | git mergetool both >/dev/null 2>&1 ) &&\n>     ( yes \"d\" | git mergetool file11 file12 >/dev/null 2>&1 ) &&\n>     ( yes \"l\" | git mergetool submod ) &&\n>     test \"$(cat submod/bar)\" = \"master submodule\" &&\n> @@ -279,6 +292,7 @@ test_expect_success 'file vs modified submodule' '\n>     test_must_fail git merge master &&\n>     test -n \"$(git ls-files -u)\" &&\n>     ( yes \"\" | git mergetool file1 file2 spaced\\ name subdir/file3 >/dev/null 2>&1 ) &&\n> +    ( yes \"\" | git mergetool both >/dev/null 2>&1 ) &&\n>     ( yes \"d\" | git mergetool file11 file12 >/dev/null 2>&1 ) &&\n>     ( yes \"r\" | git mergetool submod ) &&\n>     rmdir submod && mv submod-movedaside submod &&\n> @@ -294,6 +308,7 @@ test_expect_success 'file vs modified submodule' '\n>     test_must_fail git merge master &&\n>     test -n \"$(git ls-files -u)\" &&\n>     ( yes \"\" | git mergetool file1 file2 spaced\\ name subdir/file3 >/dev/null 2>&1 ) &&\n> +    ( yes \"\" | git mergetool both >/dev/null 2>&1 ) &&\n>     ( yes \"d\" | git mergetool file11 file12 >/dev/null 2>&1 ) &&\n>     ( yes \"l\" | git mergetool submod ) &&\n>     git submodule update -N &&\n> @@ -309,6 +324,7 @@ test_expect_success 'file vs modified submodule' '\n>     test_must_fail git merge test7 &&\n>     test -n \"$(git ls-files -u)\" &&\n>     ( yes \"\" | git mergetool file1 file2 spaced\\ name subdir/file3 >/dev/null 2>&1 ) &&\n> +    ( yes \"\" | git mergetool both >/dev/null 2>&1 ) &&\n>     ( yes \"d\" | git mergetool file11 file12 >/dev/null 2>&1 ) &&\n>     ( yes \"r\" | git mergetool submod ) &&\n>     test -d submod.orig &&\n> @@ -324,6 +340,7 @@ test_expect_success 'file vs modified submodule' '\n>     test_must_fail git merge test7 &&\n>     test -n \"$(git ls-files -u)\" &&\n>     ( yes \"\" | git mergetool file1 file2 spaced\\ name subdir/file3 >/dev/null 2>&1 ) &&\n> +    ( yes \"\" | git mergetool both>/dev/null 2>&1 ) &&\n>     ( yes \"d\" | git mergetool file11 file12 >/dev/null 2>&1 ) &&\n>     ( yes \"l\" | git mergetool submod ) &&\n>     test \"$(cat submod/bar)\" = \"master submodule\" &&\n> @@ -445,4 +462,12 @@ test_expect_success 'directory vs modified submodule' '\n>     git submodule update -N\n>  '\n>\n> +test_expect_success 'file with no base' '\n> +    git checkout -b test13 branch1 &&\n> +    test_must_fail git merge master &&\n> +    git mergetool --no-prompt --tool mybase -- base &&\n> +    test \"$(cat \"$MERGED\")\" = \"\" &&\n> +    git reset --hard master >/dev/null 2>&1\n> +'\n> +\n>  test_done\n> --\n> 1.7.9.rc2.1.gb566f\n>\n"},{"id":"182830","messageId":"7vhazqhn8u.fsf@alter.siamese.dyndns.org","threadId":"29394","inReplyTo":"1327042010-79552-1-git-send-email-davvid@gmail.com","subject":"Re: [PATCH] mergetool: Provide an empty file when no base exists","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2012-01-20T07:00:33Z","receivedAt":"2012-01-20T07:00:33Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"David Aguilar <davvid@gmail.com> writes:\n\n> Some mergetools cannot cope when $BASE is missing.\n> This can happen when two branches add the same file.\n> Provide an empty file to make these tools happy.\n>\n> Reported-by: Jason Wenger <jcwenger@gmail.com>\n> Signed-off-by: David Aguilar <davvid@gmail.com>\n> ---\n>  git-mergetool.sh     |    6 +++++-\n>  t/t7610-mergetool.sh |   27 ++++++++++++++++++++++++++-\n>  2 files changed, 31 insertions(+), 2 deletions(-)\n>\n> diff --git a/git-mergetool.sh b/git-mergetool.sh\n> index 085e213..8521b81 100755\n> --- a/git-mergetool.sh\n> +++ b/git-mergetool.sh\n> @@ -224,7 +224,11 @@ merge_file () {\n>      mv -- \"$MERGED\" \"$BACKUP\"\n>      cp -- \"$BACKUP\" \"$MERGED\"\n>  \n> -    base_present   && checkout_staged_file 1 \"$MERGED\" \"$BASE\"\n> +    if base_present; then\n> +\tcheckout_staged_file 1 \"$MERGED\" \"$BASE\"\n> +    else\n> +\ttouch \"$BASE\"\n> +    fi\n\nUsing \"touch\" for things like this is a disease.\n\nYou not just want to make sure it exists, but also you want to make sure\nit is empty, so it would make your intention more explicit and clear if\nyou wrote this as\n\n\t>\"$BASE\"\n\ninstead.\n\nI also wonder if it may help mergetools if we come up with a fake base\nimage using the common material between the two files, in a way similar to\nhow git-merge-one-file.sh does it (look for \"Added $4 in both, but\ndifferently\"), but obviously it would belong to a separate patch.\n\nThanks.\n"},{"id":"182831","messageId":"CAJDDKr5Z8JHq7H8ZZVLJvYaR+m4HarYdv2FB7p5ByYbDBemBig@mail.gmail.com","threadId":"29394","inReplyTo":"7vhazqhn8u.fsf@alter.siamese.dyndns.org","subject":"Re: [PATCH] mergetool: Provide an empty file when no base exists","fromName":"David Aguilar","fromEmail":"davvid@gmail.com","sentAt":"2012-01-20T07:07:03Z","receivedAt":"2012-01-20T07:07:03Z","isPatch":true,"sender":{"key":"davvid@gmail.com","avatar":"https://avatars.githubusercontent.com/u/13196?v=4"},"body":"On Thu, Jan 19, 2012 at 11:00 PM, Junio C Hamano <gitster@pobox.com> wrote:\n> David Aguilar <davvid@gmail.com> writes:\n>\n>> Some mergetools cannot cope when $BASE is missing.\n>> This can happen when two branches add the same file.\n>> Provide an empty file to make these tools happy.\n>>\n>> Reported-by: Jason Wenger <jcwenger@gmail.com>\n>> Signed-off-by: David Aguilar <davvid@gmail.com>\n>> ---\n>>  git-mergetool.sh     |    6 +++++-\n>>  t/t7610-mergetool.sh |   27 ++++++++++++++++++++++++++-\n>>  2 files changed, 31 insertions(+), 2 deletions(-)\n>>\n>> diff --git a/git-mergetool.sh b/git-mergetool.sh\n>> index 085e213..8521b81 100755\n>> --- a/git-mergetool.sh\n>> +++ b/git-mergetool.sh\n>> @@ -224,7 +224,11 @@ merge_file () {\n>>      mv -- \"$MERGED\" \"$BACKUP\"\n>>      cp -- \"$BACKUP\" \"$MERGED\"\n>>\n>> -    base_present   && checkout_staged_file 1 \"$MERGED\" \"$BASE\"\n>> +    if base_present; then\n>> +     checkout_staged_file 1 \"$MERGED\" \"$BASE\"\n>> +    else\n>> +     touch \"$BASE\"\n>> +    fi\n>\n> Using \"touch\" for things like this is a disease.\n>\n> You not just want to make sure it exists, but also you want to make sure\n> it is empty, so it would make your intention more explicit and clear if\n> you wrote this as\n>\n>        >\"$BASE\"\n>\n> instead.\n>\n> I also wonder if it may help mergetools if we come up with a fake base\n> image using the common material between the two files, in a way similar to\n> how git-merge-one-file.sh does it (look for \"Added $4 in both, but\n> differently\"), but obviously it would belong to a separate patch.\n>\n> Thanks.\n\nAh, thanks for the pointer.  I'll resend shortly.  A \"fake base\" would\nbe very helpful.\n-- \n            David\n"},{"id":"182832","messageId":"1327043453-80965-1-git-send-email-davvid@gmail.com","threadId":"29394","inReplyTo":"7vhazqhn8u.fsf@alter.siamese.dyndns.org","subject":"[PATCH] mergetool: Provide an empty file when no base exists","fromName":"David Aguilar","fromEmail":"davvid@gmail.com","sentAt":"2012-01-20T07:10:53Z","receivedAt":"2012-01-20T07:10:53Z","isPatch":true,"sender":{"key":"davvid@gmail.com","avatar":"https://avatars.githubusercontent.com/u/13196?v=4"},"body":"Some mergetools cannot cope when $BASE is missing.\nThis can happen when two branches add the same file.\nProvide an empty file to make these tools happy.\n\nReported-by: Jason Wenger <jcwenger@gmail.com>\nSigned-off-by: David Aguilar <davvid@gmail.com>\n---\n git-mergetool.sh     |    6 +++++-\n t/t7610-mergetool.sh |   27 ++++++++++++++++++++++++++-\n 2 files changed, 31 insertions(+), 2 deletions(-)\n\ndiff --git a/git-mergetool.sh b/git-mergetool.sh\nindex 085e213..0131559 100755\n--- a/git-mergetool.sh\n+++ b/git-mergetool.sh\n@@ -224,7 +224,11 @@ merge_file () {\n     mv -- \"$MERGED\" \"$BACKUP\"\n     cp -- \"$BACKUP\" \"$MERGED\"\n \n-    base_present   && checkout_staged_file 1 \"$MERGED\" \"$BASE\"\n+    if base_present; then\n+\tcheckout_staged_file 1 \"$MERGED\" \"$BASE\"\n+    else\n+\t:>\"$BASE\"\n+    fi\n     local_present  && checkout_staged_file 2 \"$MERGED\" \"$LOCAL\"\n     remote_present && checkout_staged_file 3 \"$MERGED\" \"$REMOTE\"\n \ndiff --git a/t/t7610-mergetool.sh b/t/t7610-mergetool.sh\nindex 4aab2a7..2272743 100755\n--- a/t/t7610-mergetool.sh\n+++ b/t/t7610-mergetool.sh\n@@ -39,6 +39,7 @@ test_expect_success 'setup' '\n     echo branch1 change >file1 &&\n     echo branch1 newfile >file2 &&\n     echo branch1 spaced >\"spaced name\" &&\n+    echo branch1 both added > both &&\n     echo branch1 change file11 >file11 &&\n     echo branch1 change file13 >file13 &&\n     echo branch1 sub >subdir/file3 &&\n@@ -50,6 +51,7 @@ test_expect_success 'setup' '\n \tgit checkout -b submod-branch1\n     ) &&\n     git add file1 \"spaced name\" file11 file13 file2 subdir/file3 submod &&\n+    git add both &&\n     git rm file12 &&\n     git commit -m \"branch1 changes\" &&\n \n@@ -58,6 +60,7 @@ test_expect_success 'setup' '\n     echo master updated >file1 &&\n     echo master new >file2 &&\n     echo master updated spaced >\"spaced name\" &&\n+    echo master both added > both &&\n     echo master updated file12 >file12 &&\n     echo master updated file14 >file14 &&\n     echo master new sub >subdir/file3 &&\n@@ -69,18 +72,22 @@ test_expect_success 'setup' '\n \tgit checkout -b submod-master\n     ) &&\n     git add file1 \"spaced name\" file12 file14 file2 subdir/file3 submod &&\n+    git add both &&\n     git rm file11 &&\n     git commit -m \"master updates\" &&\n \n     git config merge.tool mytool &&\n     git config mergetool.mytool.cmd \"cat \\\"\\$REMOTE\\\" >\\\"\\$MERGED\\\"\" &&\n-    git config mergetool.mytool.trustExitCode true\n+    git config mergetool.mytool.trustExitCode true &&\n+    git config mergetool.mybase.cmd \"cat \\\"\\$BASE\\\" >\\\"\\$MERGED\\\"\" &&\n+    git config mergetool.mybase.trustExitCode true\n '\n \n test_expect_success 'custom mergetool' '\n     git checkout -b test1 branch1 &&\n     git submodule update -N &&\n     test_must_fail git merge master >/dev/null 2>&1 &&\n+    ( yes \"\" | git mergetool both >/dev/null 2>&1 ) &&\n     ( yes \"\" | git mergetool file1 file1 ) &&\n     ( yes \"\" | git mergetool file2 \"spaced name\" >/dev/null 2>&1 ) &&\n     ( yes \"\" | git mergetool subdir/file3 >/dev/null 2>&1 ) &&\n@@ -101,6 +108,7 @@ test_expect_success 'mergetool crlf' '\n     ( yes \"\" | git mergetool file1 >/dev/null 2>&1 ) &&\n     ( yes \"\" | git mergetool file2 >/dev/null 2>&1 ) &&\n     ( yes \"\" | git mergetool \"spaced name\" >/dev/null 2>&1 ) &&\n+    ( yes \"\" | git mergetool both >/dev/null 2>&1 ) &&\n     ( yes \"\" | git mergetool subdir/file3 >/dev/null 2>&1 ) &&\n     ( yes \"d\" | git mergetool file11 >/dev/null 2>&1 ) &&\n     ( yes \"d\" | git mergetool file12 >/dev/null 2>&1 ) &&\n@@ -131,6 +139,7 @@ test_expect_success 'mergetool on file in parent dir' '\n \tcd subdir &&\n \t( yes \"\" | git mergetool ../file1 >/dev/null 2>&1 ) &&\n \t( yes \"\" | git mergetool ../file2 ../spaced\\ name >/dev/null 2>&1 ) &&\n+\t( yes \"\" | git mergetool ../both >/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@@ -212,6 +221,7 @@ test_expect_success 'deleted vs modified submodule' '\n     test_must_fail git merge master &&\n     test -n \"$(git ls-files -u)\" &&\n     ( yes \"\" | git mergetool file1 file2 spaced\\ name subdir/file3 >/dev/null 2>&1 ) &&\n+    ( yes \"\" | git mergetool both >/dev/null 2>&1 ) &&\n     ( yes \"d\" | git mergetool file11 file12 >/dev/null 2>&1 ) &&\n     ( yes \"r\" | git mergetool submod ) &&\n     rmdir submod && mv submod-movedaside submod &&\n@@ -228,6 +238,7 @@ test_expect_success 'deleted vs modified submodule' '\n     test_must_fail git merge master &&\n     test -n \"$(git ls-files -u)\" &&\n     ( yes \"\" | git mergetool file1 file2 spaced\\ name subdir/file3 >/dev/null 2>&1 ) &&\n+    ( yes \"\" | git mergetool both >/dev/null 2>&1 ) &&\n     ( yes \"d\" | git mergetool file11 file12 >/dev/null 2>&1 ) &&\n     ( yes \"l\" | git mergetool submod ) &&\n     test ! -e submod &&\n@@ -241,6 +252,7 @@ test_expect_success 'deleted vs modified submodule' '\n     test_must_fail git merge test6 &&\n     test -n \"$(git ls-files -u)\" &&\n     ( yes \"\" | git mergetool file1 file2 spaced\\ name subdir/file3 >/dev/null 2>&1 ) &&\n+    ( yes \"\" | git mergetool both >/dev/null 2>&1 ) &&\n     ( yes \"d\" | git mergetool file11 file12 >/dev/null 2>&1 ) &&\n     ( yes \"r\" | git mergetool submod ) &&\n     test ! -e submod &&\n@@ -256,6 +268,7 @@ test_expect_success 'deleted vs modified submodule' '\n     test_must_fail git merge test6 &&\n     test -n \"$(git ls-files -u)\" &&\n     ( yes \"\" | git mergetool file1 file2 spaced\\ name subdir/file3 >/dev/null 2>&1 ) &&\n+    ( yes \"\" | git mergetool both >/dev/null 2>&1 ) &&\n     ( yes \"d\" | git mergetool file11 file12 >/dev/null 2>&1 ) &&\n     ( yes \"l\" | git mergetool submod ) &&\n     test \"$(cat submod/bar)\" = \"master submodule\" &&\n@@ -279,6 +292,7 @@ test_expect_success 'file vs modified submodule' '\n     test_must_fail git merge master &&\n     test -n \"$(git ls-files -u)\" &&\n     ( yes \"\" | git mergetool file1 file2 spaced\\ name subdir/file3 >/dev/null 2>&1 ) &&\n+    ( yes \"\" | git mergetool both >/dev/null 2>&1 ) &&\n     ( yes \"d\" | git mergetool file11 file12 >/dev/null 2>&1 ) &&\n     ( yes \"r\" | git mergetool submod ) &&\n     rmdir submod && mv submod-movedaside submod &&\n@@ -294,6 +308,7 @@ test_expect_success 'file vs modified submodule' '\n     test_must_fail git merge master &&\n     test -n \"$(git ls-files -u)\" &&\n     ( yes \"\" | git mergetool file1 file2 spaced\\ name subdir/file3 >/dev/null 2>&1 ) &&\n+    ( yes \"\" | git mergetool both >/dev/null 2>&1 ) &&\n     ( yes \"d\" | git mergetool file11 file12 >/dev/null 2>&1 ) &&\n     ( yes \"l\" | git mergetool submod ) &&\n     git submodule update -N &&\n@@ -309,6 +324,7 @@ test_expect_success 'file vs modified submodule' '\n     test_must_fail git merge test7 &&\n     test -n \"$(git ls-files -u)\" &&\n     ( yes \"\" | git mergetool file1 file2 spaced\\ name subdir/file3 >/dev/null 2>&1 ) &&\n+    ( yes \"\" | git mergetool both >/dev/null 2>&1 ) &&\n     ( yes \"d\" | git mergetool file11 file12 >/dev/null 2>&1 ) &&\n     ( yes \"r\" | git mergetool submod ) &&\n     test -d submod.orig &&\n@@ -324,6 +340,7 @@ test_expect_success 'file vs modified submodule' '\n     test_must_fail git merge test7 &&\n     test -n \"$(git ls-files -u)\" &&\n     ( yes \"\" | git mergetool file1 file2 spaced\\ name subdir/file3 >/dev/null 2>&1 ) &&\n+    ( yes \"\" | git mergetool both>/dev/null 2>&1 ) &&\n     ( yes \"d\" | git mergetool file11 file12 >/dev/null 2>&1 ) &&\n     ( yes \"l\" | git mergetool submod ) &&\n     test \"$(cat submod/bar)\" = \"master submodule\" &&\n@@ -445,4 +462,12 @@ test_expect_success 'directory vs modified submodule' '\n     git submodule update -N\n '\n \n+test_expect_success 'file with no base' '\n+    git checkout -b test13 branch1 &&\n+    test_must_fail git merge master &&\n+    git mergetool --no-prompt --tool mybase -- base &&\n+    test \"$(cat \"$MERGED\")\" = \"\" &&\n+    git reset --hard master >/dev/null 2>&1\n+'\n+\n test_done\n-- \n1.7.9.rc2.1.gdcba7\n"},{"id":"182834","messageId":"1327043666-81155-1-git-send-email-davvid@gmail.com","threadId":"29394","inReplyTo":"7vhazqhn8u.fsf@alter.siamese.dyndns.org","subject":"[PATCH v2] mergetool: Provide an empty file when no base exists","fromName":"David Aguilar","fromEmail":"davvid@gmail.com","sentAt":"2012-01-20T07:14:26Z","receivedAt":"2012-01-20T07:14:26Z","isPatch":true,"sender":{"key":"davvid@gmail.com","avatar":"https://avatars.githubusercontent.com/u/13196?v=4"},"body":"Some mergetools cannot cope when $BASE is missing,\nfor example when two branches independently add the same filename.\nProvide an empty file to make these tools happy.\n\nReported-by: Jason Wenger <jcwenger@gmail.com>\nSigned-off-by: David Aguilar <davvid@gmail.com>\n---\nFixed commit message too.\n\n git-mergetool.sh     |    6 +++++-\n t/t7610-mergetool.sh |   27 ++++++++++++++++++++++++++-\n 2 files changed, 31 insertions(+), 2 deletions(-)\n\ndiff --git a/git-mergetool.sh b/git-mergetool.sh\nindex 085e213..0131559 100755\n--- a/git-mergetool.sh\n+++ b/git-mergetool.sh\n@@ -224,7 +224,11 @@ merge_file () {\n     mv -- \"$MERGED\" \"$BACKUP\"\n     cp -- \"$BACKUP\" \"$MERGED\"\n \n-    base_present   && checkout_staged_file 1 \"$MERGED\" \"$BASE\"\n+    if base_present; then\n+\tcheckout_staged_file 1 \"$MERGED\" \"$BASE\"\n+    else\n+\t:>\"$BASE\"\n+    fi\n     local_present  && checkout_staged_file 2 \"$MERGED\" \"$LOCAL\"\n     remote_present && checkout_staged_file 3 \"$MERGED\" \"$REMOTE\"\n \ndiff --git a/t/t7610-mergetool.sh b/t/t7610-mergetool.sh\nindex 4aab2a7..2272743 100755\n--- a/t/t7610-mergetool.sh\n+++ b/t/t7610-mergetool.sh\n@@ -39,6 +39,7 @@ test_expect_success 'setup' '\n     echo branch1 change >file1 &&\n     echo branch1 newfile >file2 &&\n     echo branch1 spaced >\"spaced name\" &&\n+    echo branch1 both added > both &&\n     echo branch1 change file11 >file11 &&\n     echo branch1 change file13 >file13 &&\n     echo branch1 sub >subdir/file3 &&\n@@ -50,6 +51,7 @@ test_expect_success 'setup' '\n \tgit checkout -b submod-branch1\n     ) &&\n     git add file1 \"spaced name\" file11 file13 file2 subdir/file3 submod &&\n+    git add both &&\n     git rm file12 &&\n     git commit -m \"branch1 changes\" &&\n \n@@ -58,6 +60,7 @@ test_expect_success 'setup' '\n     echo master updated >file1 &&\n     echo master new >file2 &&\n     echo master updated spaced >\"spaced name\" &&\n+    echo master both added > both &&\n     echo master updated file12 >file12 &&\n     echo master updated file14 >file14 &&\n     echo master new sub >subdir/file3 &&\n@@ -69,18 +72,22 @@ test_expect_success 'setup' '\n \tgit checkout -b submod-master\n     ) &&\n     git add file1 \"spaced name\" file12 file14 file2 subdir/file3 submod &&\n+    git add both &&\n     git rm file11 &&\n     git commit -m \"master updates\" &&\n \n     git config merge.tool mytool &&\n     git config mergetool.mytool.cmd \"cat \\\"\\$REMOTE\\\" >\\\"\\$MERGED\\\"\" &&\n-    git config mergetool.mytool.trustExitCode true\n+    git config mergetool.mytool.trustExitCode true &&\n+    git config mergetool.mybase.cmd \"cat \\\"\\$BASE\\\" >\\\"\\$MERGED\\\"\" &&\n+    git config mergetool.mybase.trustExitCode true\n '\n \n test_expect_success 'custom mergetool' '\n     git checkout -b test1 branch1 &&\n     git submodule update -N &&\n     test_must_fail git merge master >/dev/null 2>&1 &&\n+    ( yes \"\" | git mergetool both >/dev/null 2>&1 ) &&\n     ( yes \"\" | git mergetool file1 file1 ) &&\n     ( yes \"\" | git mergetool file2 \"spaced name\" >/dev/null 2>&1 ) &&\n     ( yes \"\" | git mergetool subdir/file3 >/dev/null 2>&1 ) &&\n@@ -101,6 +108,7 @@ test_expect_success 'mergetool crlf' '\n     ( yes \"\" | git mergetool file1 >/dev/null 2>&1 ) &&\n     ( yes \"\" | git mergetool file2 >/dev/null 2>&1 ) &&\n     ( yes \"\" | git mergetool \"spaced name\" >/dev/null 2>&1 ) &&\n+    ( yes \"\" | git mergetool both >/dev/null 2>&1 ) &&\n     ( yes \"\" | git mergetool subdir/file3 >/dev/null 2>&1 ) &&\n     ( yes \"d\" | git mergetool file11 >/dev/null 2>&1 ) &&\n     ( yes \"d\" | git mergetool file12 >/dev/null 2>&1 ) &&\n@@ -131,6 +139,7 @@ test_expect_success 'mergetool on file in parent dir' '\n \tcd subdir &&\n \t( yes \"\" | git mergetool ../file1 >/dev/null 2>&1 ) &&\n \t( yes \"\" | git mergetool ../file2 ../spaced\\ name >/dev/null 2>&1 ) &&\n+\t( yes \"\" | git mergetool ../both >/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@@ -212,6 +221,7 @@ test_expect_success 'deleted vs modified submodule' '\n     test_must_fail git merge master &&\n     test -n \"$(git ls-files -u)\" &&\n     ( yes \"\" | git mergetool file1 file2 spaced\\ name subdir/file3 >/dev/null 2>&1 ) &&\n+    ( yes \"\" | git mergetool both >/dev/null 2>&1 ) &&\n     ( yes \"d\" | git mergetool file11 file12 >/dev/null 2>&1 ) &&\n     ( yes \"r\" | git mergetool submod ) &&\n     rmdir submod && mv submod-movedaside submod &&\n@@ -228,6 +238,7 @@ test_expect_success 'deleted vs modified submodule' '\n     test_must_fail git merge master &&\n     test -n \"$(git ls-files -u)\" &&\n     ( yes \"\" | git mergetool file1 file2 spaced\\ name subdir/file3 >/dev/null 2>&1 ) &&\n+    ( yes \"\" | git mergetool both >/dev/null 2>&1 ) &&\n     ( yes \"d\" | git mergetool file11 file12 >/dev/null 2>&1 ) &&\n     ( yes \"l\" | git mergetool submod ) &&\n     test ! -e submod &&\n@@ -241,6 +252,7 @@ test_expect_success 'deleted vs modified submodule' '\n     test_must_fail git merge test6 &&\n     test -n \"$(git ls-files -u)\" &&\n     ( yes \"\" | git mergetool file1 file2 spaced\\ name subdir/file3 >/dev/null 2>&1 ) &&\n+    ( yes \"\" | git mergetool both >/dev/null 2>&1 ) &&\n     ( yes \"d\" | git mergetool file11 file12 >/dev/null 2>&1 ) &&\n     ( yes \"r\" | git mergetool submod ) &&\n     test ! -e submod &&\n@@ -256,6 +268,7 @@ test_expect_success 'deleted vs modified submodule' '\n     test_must_fail git merge test6 &&\n     test -n \"$(git ls-files -u)\" &&\n     ( yes \"\" | git mergetool file1 file2 spaced\\ name subdir/file3 >/dev/null 2>&1 ) &&\n+    ( yes \"\" | git mergetool both >/dev/null 2>&1 ) &&\n     ( yes \"d\" | git mergetool file11 file12 >/dev/null 2>&1 ) &&\n     ( yes \"l\" | git mergetool submod ) &&\n     test \"$(cat submod/bar)\" = \"master submodule\" &&\n@@ -279,6 +292,7 @@ test_expect_success 'file vs modified submodule' '\n     test_must_fail git merge master &&\n     test -n \"$(git ls-files -u)\" &&\n     ( yes \"\" | git mergetool file1 file2 spaced\\ name subdir/file3 >/dev/null 2>&1 ) &&\n+    ( yes \"\" | git mergetool both >/dev/null 2>&1 ) &&\n     ( yes \"d\" | git mergetool file11 file12 >/dev/null 2>&1 ) &&\n     ( yes \"r\" | git mergetool submod ) &&\n     rmdir submod && mv submod-movedaside submod &&\n@@ -294,6 +308,7 @@ test_expect_success 'file vs modified submodule' '\n     test_must_fail git merge master &&\n     test -n \"$(git ls-files -u)\" &&\n     ( yes \"\" | git mergetool file1 file2 spaced\\ name subdir/file3 >/dev/null 2>&1 ) &&\n+    ( yes \"\" | git mergetool both >/dev/null 2>&1 ) &&\n     ( yes \"d\" | git mergetool file11 file12 >/dev/null 2>&1 ) &&\n     ( yes \"l\" | git mergetool submod ) &&\n     git submodule update -N &&\n@@ -309,6 +324,7 @@ test_expect_success 'file vs modified submodule' '\n     test_must_fail git merge test7 &&\n     test -n \"$(git ls-files -u)\" &&\n     ( yes \"\" | git mergetool file1 file2 spaced\\ name subdir/file3 >/dev/null 2>&1 ) &&\n+    ( yes \"\" | git mergetool both >/dev/null 2>&1 ) &&\n     ( yes \"d\" | git mergetool file11 file12 >/dev/null 2>&1 ) &&\n     ( yes \"r\" | git mergetool submod ) &&\n     test -d submod.orig &&\n@@ -324,6 +340,7 @@ test_expect_success 'file vs modified submodule' '\n     test_must_fail git merge test7 &&\n     test -n \"$(git ls-files -u)\" &&\n     ( yes \"\" | git mergetool file1 file2 spaced\\ name subdir/file3 >/dev/null 2>&1 ) &&\n+    ( yes \"\" | git mergetool both>/dev/null 2>&1 ) &&\n     ( yes \"d\" | git mergetool file11 file12 >/dev/null 2>&1 ) &&\n     ( yes \"l\" | git mergetool submod ) &&\n     test \"$(cat submod/bar)\" = \"master submodule\" &&\n@@ -445,4 +462,12 @@ test_expect_success 'directory vs modified submodule' '\n     git submodule update -N\n '\n \n+test_expect_success 'file with no base' '\n+    git checkout -b test13 branch1 &&\n+    test_must_fail git merge master &&\n+    git mergetool --no-prompt --tool mybase -- base &&\n+    test \"$(cat \"$MERGED\")\" = \"\" &&\n+    git reset --hard master >/dev/null 2>&1\n+'\n+\n test_done\n-- \n1.7.9.rc2.1.gdcba7\n"},{"id":"182836","messageId":"7v7h0mhm8g.fsf@alter.siamese.dyndns.org","threadId":"29394","inReplyTo":"1327043453-80965-1-git-send-email-davvid@gmail.com","subject":"Re: [PATCH] mergetool: Provide an empty file when no base exists","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2012-01-20T07:22:23Z","receivedAt":"2012-01-20T07:22:23Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"David Aguilar <davvid@gmail.com> writes:\n\n> +    if base_present; then\n> +\tcheckout_staged_file 1 \"$MERGED\" \"$BASE\"\n> +    else\n> +\t:>\"$BASE\"\n\nJust a style, but please write this as either one of the following:\n\n\t>\"$BASE\"\n        : >\"$BASE\"\n\nI tend to prefer the former, but if you have to write a command, we want\nto see a SP before the redirection (and no SP before the redirect target).\n\n> +    fi\n>      local_present  && checkout_staged_file 2 \"$MERGED\" \"$LOCAL\"\n>      remote_present && checkout_staged_file 3 \"$MERGED\" \"$REMOTE\"\n\nSorry to be ping-pong-ing like this, but wouldn't we have a similar issue\nwhen LOCAL or REMOTE does not exist (e.g. \"they modified, we removed\")?\n"},{"id":"182838","messageId":"CAJDDKr490XFqGe+y1pa7fnNhPMRE3ZR3=A+_XNUrCA1GZv+wkw@mail.gmail.com","threadId":"29394","inReplyTo":"7v7h0mhm8g.fsf@alter.siamese.dyndns.org","subject":"Re: [PATCH] mergetool: Provide an empty file when no base exists","fromName":"David Aguilar","fromEmail":"davvid@gmail.com","sentAt":"2012-01-20T07:26:59Z","receivedAt":"2012-01-20T07:26:59Z","isPatch":true,"sender":{"key":"davvid@gmail.com","avatar":"https://avatars.githubusercontent.com/u/13196?v=4"},"body":"On Thu, Jan 19, 2012 at 11:22 PM, Junio C Hamano <gitster@pobox.com> wrote:\n> David Aguilar <davvid@gmail.com> writes:\n>\n>> +    if base_present; then\n>> +     checkout_staged_file 1 \"$MERGED\" \"$BASE\"\n>> +    else\n>> +     :>\"$BASE\"\n>\n> Just a style, but please write this as either one of the following:\n>\n>        >\"$BASE\"\n>        : >\"$BASE\"\n>\n> I tend to prefer the former, but if you have to write a command, we want\n> to see a SP before the redirection (and no SP before the redirect target).\n>\n>> +    fi\n>>      local_present  && checkout_staged_file 2 \"$MERGED\" \"$LOCAL\"\n>>      remote_present && checkout_staged_file 3 \"$MERGED\" \"$REMOTE\"\n>\n> Sorry to be ping-pong-ing like this, but wouldn't we have a similar issue\n> when LOCAL or REMOTE does not exist (e.g. \"they modified, we removed\")?\n\nYes.  I'll have a [PATCH v3] soon.\n-- \n            David\n"},{"id":"182839","messageId":"7vy5t2g6za.fsf@alter.siamese.dyndns.org","threadId":"29394","inReplyTo":"CAJDDKr490XFqGe+y1pa7fnNhPMRE3ZR3=A+_XNUrCA1GZv+wkw@mail.gmail.com","subject":"Re: [PATCH] mergetool: Provide an empty file when no base exists","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2012-01-20T07:37:13Z","receivedAt":"2012-01-20T07:37:13Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"David Aguilar <davvid@gmail.com> writes:\n\n>>>      local_present  && checkout_staged_file 2 \"$MERGED\" \"$LOCAL\"\n>>>      remote_present && checkout_staged_file 3 \"$MERGED\" \"$REMOTE\"\n>>\n>> Sorry to be ping-pong-ing like this, but wouldn't we have a similar issue\n>> when LOCAL or REMOTE does not exist (e.g. \"they modified, we removed\")?\n>\n> Yes.  I'll have a [PATCH v3] soon.\n\nIt almost makes me wonder if the obviously simplest change to make\ncheckout_staged_file create an empty file when the asked-for stage does\nnot exist, i.e.\n\n\tcheckout_stage ()\n        {\n\t\tif test -n \"$1\"\n                then\n\t\t\t... whatever checkout_staged_file() does ...\n\t\telse\n\t\t\t>\"$4\"\n                fi\n        }\n\n\tcheckout_stage $base_mode 1 \"$MERGED\" \"$BASE\"\n\tcheckout_stage $local_mode 2 \"$MERGED\" \"$LOCAL\"\n\tcheckout_stage $remote_mode 3 \"$MERGED\" \"$REMOTE\"\n\nOr even:\n\n\tcheckout_stage ()\n\t{\n\t\ttmpfile=$(...)\n                if test $? -eq 0 -a ...\n                then\n                \tmv -- \"$(git rev-parse ...)\"\n\t\telse\n\t\t\t>\"$3\"\n\t\tfi\n        }\n\n\tcheckout_stage 1 \"$MERGED\" \"$BASE\"\n\tcheckout_stage 2 \"$MERGED\" \"$LOCAL\"\n\tcheckout_stage 3 \"$MERGED\" \"$REMOTE\"\n\nas the current checkout_staged_file() does not seem to check errors in any\nmeaningful way.\n"},{"id":"182840","messageId":"1327045038-91710-1-git-send-email-davvid@gmail.com","threadId":"29394","inReplyTo":"7v7h0mhm8g.fsf@alter.siamese.dyndns.org","subject":"[PATCH v3] mergetool: Provide an empty file when needed","fromName":"David Aguilar","fromEmail":"davvid@gmail.com","sentAt":"2012-01-20T07:37:18Z","receivedAt":"2012-01-20T07:37:18Z","isPatch":true,"sender":{"key":"davvid@gmail.com","avatar":"https://avatars.githubusercontent.com/u/13196?v=4"},"body":"Some merge tools cannot cope when $LOCAL, $BASE, or $REMOTE\nare missing.  $BASE can be missing when two branches\nindependently add the same filename.  $LOCAL and $REMOTE\ncan be missing when a delete/modify conflict occurs.\n\nProvide an empty file to make these tools happy.\n\nReported-by: Jason Wenger <jcwenger@gmail.com>\nSigned-off-by: David Aguilar <davvid@gmail.com>\n---\n git-mergetool.sh     |   20 +++++++++++++++++---\n t/t7610-mergetool.sh |   27 ++++++++++++++++++++++++++-\n 2 files changed, 43 insertions(+), 4 deletions(-)\n\ndiff --git a/git-mergetool.sh b/git-mergetool.sh\nindex 085e213..8cd70eb 100755\n--- a/git-mergetool.sh\n+++ b/git-mergetool.sh\n@@ -224,9 +224,23 @@ merge_file () {\n     mv -- \"$MERGED\" \"$BACKUP\"\n     cp -- \"$BACKUP\" \"$MERGED\"\n \n-    base_present   && checkout_staged_file 1 \"$MERGED\" \"$BASE\"\n-    local_present  && checkout_staged_file 2 \"$MERGED\" \"$LOCAL\"\n-    remote_present && checkout_staged_file 3 \"$MERGED\" \"$REMOTE\"\n+    if base_present; then\n+\tcheckout_staged_file 1 \"$MERGED\" \"$BASE\"\n+    else\n+\t>\"$BASE\"\n+    fi\n+\n+    if local_present; then\n+\tcheckout_staged_file 2 \"$MERGED\" \"$LOCAL\"\n+    else\n+\t>\"$LOCAL\"\n+    fi\n+\n+    if remote_present; then\n+\tcheckout_staged_file 3 \"$MERGED\" \"$REMOTE\"\n+    else\n+\t>\"$REMOTE\"\n+    fi\n \n     if test -z \"$local_mode\" -o -z \"$remote_mode\"; then\n \techo \"Deleted merge conflict for '$MERGED':\"\ndiff --git a/t/t7610-mergetool.sh b/t/t7610-mergetool.sh\nindex 4aab2a7..2272743 100755\n--- a/t/t7610-mergetool.sh\n+++ b/t/t7610-mergetool.sh\n@@ -39,6 +39,7 @@ test_expect_success 'setup' '\n     echo branch1 change >file1 &&\n     echo branch1 newfile >file2 &&\n     echo branch1 spaced >\"spaced name\" &&\n+    echo branch1 both added > both &&\n     echo branch1 change file11 >file11 &&\n     echo branch1 change file13 >file13 &&\n     echo branch1 sub >subdir/file3 &&\n@@ -50,6 +51,7 @@ test_expect_success 'setup' '\n \tgit checkout -b submod-branch1\n     ) &&\n     git add file1 \"spaced name\" file11 file13 file2 subdir/file3 submod &&\n+    git add both &&\n     git rm file12 &&\n     git commit -m \"branch1 changes\" &&\n \n@@ -58,6 +60,7 @@ test_expect_success 'setup' '\n     echo master updated >file1 &&\n     echo master new >file2 &&\n     echo master updated spaced >\"spaced name\" &&\n+    echo master both added > both &&\n     echo master updated file12 >file12 &&\n     echo master updated file14 >file14 &&\n     echo master new sub >subdir/file3 &&\n@@ -69,18 +72,22 @@ test_expect_success 'setup' '\n \tgit checkout -b submod-master\n     ) &&\n     git add file1 \"spaced name\" file12 file14 file2 subdir/file3 submod &&\n+    git add both &&\n     git rm file11 &&\n     git commit -m \"master updates\" &&\n \n     git config merge.tool mytool &&\n     git config mergetool.mytool.cmd \"cat \\\"\\$REMOTE\\\" >\\\"\\$MERGED\\\"\" &&\n-    git config mergetool.mytool.trustExitCode true\n+    git config mergetool.mytool.trustExitCode true &&\n+    git config mergetool.mybase.cmd \"cat \\\"\\$BASE\\\" >\\\"\\$MERGED\\\"\" &&\n+    git config mergetool.mybase.trustExitCode true\n '\n \n test_expect_success 'custom mergetool' '\n     git checkout -b test1 branch1 &&\n     git submodule update -N &&\n     test_must_fail git merge master >/dev/null 2>&1 &&\n+    ( yes \"\" | git mergetool both >/dev/null 2>&1 ) &&\n     ( yes \"\" | git mergetool file1 file1 ) &&\n     ( yes \"\" | git mergetool file2 \"spaced name\" >/dev/null 2>&1 ) &&\n     ( yes \"\" | git mergetool subdir/file3 >/dev/null 2>&1 ) &&\n@@ -101,6 +108,7 @@ test_expect_success 'mergetool crlf' '\n     ( yes \"\" | git mergetool file1 >/dev/null 2>&1 ) &&\n     ( yes \"\" | git mergetool file2 >/dev/null 2>&1 ) &&\n     ( yes \"\" | git mergetool \"spaced name\" >/dev/null 2>&1 ) &&\n+    ( yes \"\" | git mergetool both >/dev/null 2>&1 ) &&\n     ( yes \"\" | git mergetool subdir/file3 >/dev/null 2>&1 ) &&\n     ( yes \"d\" | git mergetool file11 >/dev/null 2>&1 ) &&\n     ( yes \"d\" | git mergetool file12 >/dev/null 2>&1 ) &&\n@@ -131,6 +139,7 @@ test_expect_success 'mergetool on file in parent dir' '\n \tcd subdir &&\n \t( yes \"\" | git mergetool ../file1 >/dev/null 2>&1 ) &&\n \t( yes \"\" | git mergetool ../file2 ../spaced\\ name >/dev/null 2>&1 ) &&\n+\t( yes \"\" | git mergetool ../both >/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@@ -212,6 +221,7 @@ test_expect_success 'deleted vs modified submodule' '\n     test_must_fail git merge master &&\n     test -n \"$(git ls-files -u)\" &&\n     ( yes \"\" | git mergetool file1 file2 spaced\\ name subdir/file3 >/dev/null 2>&1 ) &&\n+    ( yes \"\" | git mergetool both >/dev/null 2>&1 ) &&\n     ( yes \"d\" | git mergetool file11 file12 >/dev/null 2>&1 ) &&\n     ( yes \"r\" | git mergetool submod ) &&\n     rmdir submod && mv submod-movedaside submod &&\n@@ -228,6 +238,7 @@ test_expect_success 'deleted vs modified submodule' '\n     test_must_fail git merge master &&\n     test -n \"$(git ls-files -u)\" &&\n     ( yes \"\" | git mergetool file1 file2 spaced\\ name subdir/file3 >/dev/null 2>&1 ) &&\n+    ( yes \"\" | git mergetool both >/dev/null 2>&1 ) &&\n     ( yes \"d\" | git mergetool file11 file12 >/dev/null 2>&1 ) &&\n     ( yes \"l\" | git mergetool submod ) &&\n     test ! -e submod &&\n@@ -241,6 +252,7 @@ test_expect_success 'deleted vs modified submodule' '\n     test_must_fail git merge test6 &&\n     test -n \"$(git ls-files -u)\" &&\n     ( yes \"\" | git mergetool file1 file2 spaced\\ name subdir/file3 >/dev/null 2>&1 ) &&\n+    ( yes \"\" | git mergetool both >/dev/null 2>&1 ) &&\n     ( yes \"d\" | git mergetool file11 file12 >/dev/null 2>&1 ) &&\n     ( yes \"r\" | git mergetool submod ) &&\n     test ! -e submod &&\n@@ -256,6 +268,7 @@ test_expect_success 'deleted vs modified submodule' '\n     test_must_fail git merge test6 &&\n     test -n \"$(git ls-files -u)\" &&\n     ( yes \"\" | git mergetool file1 file2 spaced\\ name subdir/file3 >/dev/null 2>&1 ) &&\n+    ( yes \"\" | git mergetool both >/dev/null 2>&1 ) &&\n     ( yes \"d\" | git mergetool file11 file12 >/dev/null 2>&1 ) &&\n     ( yes \"l\" | git mergetool submod ) &&\n     test \"$(cat submod/bar)\" = \"master submodule\" &&\n@@ -279,6 +292,7 @@ test_expect_success 'file vs modified submodule' '\n     test_must_fail git merge master &&\n     test -n \"$(git ls-files -u)\" &&\n     ( yes \"\" | git mergetool file1 file2 spaced\\ name subdir/file3 >/dev/null 2>&1 ) &&\n+    ( yes \"\" | git mergetool both >/dev/null 2>&1 ) &&\n     ( yes \"d\" | git mergetool file11 file12 >/dev/null 2>&1 ) &&\n     ( yes \"r\" | git mergetool submod ) &&\n     rmdir submod && mv submod-movedaside submod &&\n@@ -294,6 +308,7 @@ test_expect_success 'file vs modified submodule' '\n     test_must_fail git merge master &&\n     test -n \"$(git ls-files -u)\" &&\n     ( yes \"\" | git mergetool file1 file2 spaced\\ name subdir/file3 >/dev/null 2>&1 ) &&\n+    ( yes \"\" | git mergetool both >/dev/null 2>&1 ) &&\n     ( yes \"d\" | git mergetool file11 file12 >/dev/null 2>&1 ) &&\n     ( yes \"l\" | git mergetool submod ) &&\n     git submodule update -N &&\n@@ -309,6 +324,7 @@ test_expect_success 'file vs modified submodule' '\n     test_must_fail git merge test7 &&\n     test -n \"$(git ls-files -u)\" &&\n     ( yes \"\" | git mergetool file1 file2 spaced\\ name subdir/file3 >/dev/null 2>&1 ) &&\n+    ( yes \"\" | git mergetool both >/dev/null 2>&1 ) &&\n     ( yes \"d\" | git mergetool file11 file12 >/dev/null 2>&1 ) &&\n     ( yes \"r\" | git mergetool submod ) &&\n     test -d submod.orig &&\n@@ -324,6 +340,7 @@ test_expect_success 'file vs modified submodule' '\n     test_must_fail git merge test7 &&\n     test -n \"$(git ls-files -u)\" &&\n     ( yes \"\" | git mergetool file1 file2 spaced\\ name subdir/file3 >/dev/null 2>&1 ) &&\n+    ( yes \"\" | git mergetool both>/dev/null 2>&1 ) &&\n     ( yes \"d\" | git mergetool file11 file12 >/dev/null 2>&1 ) &&\n     ( yes \"l\" | git mergetool submod ) &&\n     test \"$(cat submod/bar)\" = \"master submodule\" &&\n@@ -445,4 +462,12 @@ test_expect_success 'directory vs modified submodule' '\n     git submodule update -N\n '\n \n+test_expect_success 'file with no base' '\n+    git checkout -b test13 branch1 &&\n+    test_must_fail git merge master &&\n+    git mergetool --no-prompt --tool mybase -- base &&\n+    test \"$(cat \"$MERGED\")\" = \"\" &&\n+    git reset --hard master >/dev/null 2>&1\n+'\n+\n test_done\n-- \n1.7.9.rc2.1.g1c18\n"},{"id":"182841","messageId":"7vty3qg6vv.fsf@alter.siamese.dyndns.org","threadId":"29394","inReplyTo":"7vy5t2g6za.fsf@alter.siamese.dyndns.org","subject":"Re: [PATCH] mergetool: Provide an empty file when no base exists","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2012-01-20T07:39:16Z","receivedAt":"2012-01-20T07:39:16Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Junio C Hamano <gitster@pobox.com> writes:\n\nYuck, sorry for sending out a edit-in-progress copy.\n\n> It almost makes me wonder if the obviously simplest change to make\n> checkout_staged_file create an empty file when the asked-for stage does\n> not exist, i.e.\n\nIt should read\n\nIt almost makes me wonder if the obviously simplest change to make\ncheckout_staged_file create an empty file when the asked-for stage does\nnot exist is good enough, i.e.\n"},{"id":"182842","messageId":"1327045655-3368-1-git-send-email-davvid@gmail.com","threadId":"29394","inReplyTo":"7vy5t2g6za.fsf@alter.siamese.dyndns.org","subject":"[PATCH v3] mergetool: Provide an empty file when needed","fromName":"David Aguilar","fromEmail":"davvid@gmail.com","sentAt":"2012-01-20T07:47:35Z","receivedAt":"2012-01-20T07:47:35Z","isPatch":true,"sender":{"key":"davvid@gmail.com","avatar":"https://avatars.githubusercontent.com/u/13196?v=4"},"body":"Some merge tools cannot cope when $LOCAL, $BASE, or $REMOTE\nare missing.  $BASE can be missing when two branches\nindependently add the same filename.  $LOCAL and $REMOTE\ncan be missing when a delete/modify conflict occurs.\n\nProvide an empty file to make these tools happy.\n\nReported-by: Jason Wenger <jcwenger@gmail.com>\nSigned-off-by: David Aguilar <davvid@gmail.com>\n---\nWe now create the empty file in checkout_staged_file()\nas part of the error checking section.\n\n git-mergetool.sh     |    8 +++++---\n t/t7610-mergetool.sh |   27 ++++++++++++++++++++++++++-\n 2 files changed, 31 insertions(+), 4 deletions(-)\n\ndiff --git a/git-mergetool.sh b/git-mergetool.sh\nindex 085e213..24bedc5 100755\n--- a/git-mergetool.sh\n+++ b/git-mergetool.sh\n@@ -185,6 +185,8 @@ checkout_staged_file () {\n \n     if test $? -eq 0 -a -n \"$tmpfile\" ; then\n \tmv -- \"$(git rev-parse --show-cdup)$tmpfile\" \"$3\"\n+    else\n+\t>\"$3\"\n     fi\n }\n \n@@ -224,9 +226,9 @@ merge_file () {\n     mv -- \"$MERGED\" \"$BACKUP\"\n     cp -- \"$BACKUP\" \"$MERGED\"\n \n-    base_present   && checkout_staged_file 1 \"$MERGED\" \"$BASE\"\n-    local_present  && checkout_staged_file 2 \"$MERGED\" \"$LOCAL\"\n-    remote_present && checkout_staged_file 3 \"$MERGED\" \"$REMOTE\"\n+    checkout_staged_file 1 \"$MERGED\" \"$BASE\"\n+    checkout_staged_file 2 \"$MERGED\" \"$LOCAL\"\n+    checkout_staged_file 3 \"$MERGED\" \"$REMOTE\"\n \n     if test -z \"$local_mode\" -o -z \"$remote_mode\"; then\n \techo \"Deleted merge conflict for '$MERGED':\"\ndiff --git a/t/t7610-mergetool.sh b/t/t7610-mergetool.sh\nindex 4aab2a7..2272743 100755\n--- a/t/t7610-mergetool.sh\n+++ b/t/t7610-mergetool.sh\n@@ -39,6 +39,7 @@ test_expect_success 'setup' '\n     echo branch1 change >file1 &&\n     echo branch1 newfile >file2 &&\n     echo branch1 spaced >\"spaced name\" &&\n+    echo branch1 both added > both &&\n     echo branch1 change file11 >file11 &&\n     echo branch1 change file13 >file13 &&\n     echo branch1 sub >subdir/file3 &&\n@@ -50,6 +51,7 @@ test_expect_success 'setup' '\n \tgit checkout -b submod-branch1\n     ) &&\n     git add file1 \"spaced name\" file11 file13 file2 subdir/file3 submod &&\n+    git add both &&\n     git rm file12 &&\n     git commit -m \"branch1 changes\" &&\n \n@@ -58,6 +60,7 @@ test_expect_success 'setup' '\n     echo master updated >file1 &&\n     echo master new >file2 &&\n     echo master updated spaced >\"spaced name\" &&\n+    echo master both added > both &&\n     echo master updated file12 >file12 &&\n     echo master updated file14 >file14 &&\n     echo master new sub >subdir/file3 &&\n@@ -69,18 +72,22 @@ test_expect_success 'setup' '\n \tgit checkout -b submod-master\n     ) &&\n     git add file1 \"spaced name\" file12 file14 file2 subdir/file3 submod &&\n+    git add both &&\n     git rm file11 &&\n     git commit -m \"master updates\" &&\n \n     git config merge.tool mytool &&\n     git config mergetool.mytool.cmd \"cat \\\"\\$REMOTE\\\" >\\\"\\$MERGED\\\"\" &&\n-    git config mergetool.mytool.trustExitCode true\n+    git config mergetool.mytool.trustExitCode true &&\n+    git config mergetool.mybase.cmd \"cat \\\"\\$BASE\\\" >\\\"\\$MERGED\\\"\" &&\n+    git config mergetool.mybase.trustExitCode true\n '\n \n test_expect_success 'custom mergetool' '\n     git checkout -b test1 branch1 &&\n     git submodule update -N &&\n     test_must_fail git merge master >/dev/null 2>&1 &&\n+    ( yes \"\" | git mergetool both >/dev/null 2>&1 ) &&\n     ( yes \"\" | git mergetool file1 file1 ) &&\n     ( yes \"\" | git mergetool file2 \"spaced name\" >/dev/null 2>&1 ) &&\n     ( yes \"\" | git mergetool subdir/file3 >/dev/null 2>&1 ) &&\n@@ -101,6 +108,7 @@ test_expect_success 'mergetool crlf' '\n     ( yes \"\" | git mergetool file1 >/dev/null 2>&1 ) &&\n     ( yes \"\" | git mergetool file2 >/dev/null 2>&1 ) &&\n     ( yes \"\" | git mergetool \"spaced name\" >/dev/null 2>&1 ) &&\n+    ( yes \"\" | git mergetool both >/dev/null 2>&1 ) &&\n     ( yes \"\" | git mergetool subdir/file3 >/dev/null 2>&1 ) &&\n     ( yes \"d\" | git mergetool file11 >/dev/null 2>&1 ) &&\n     ( yes \"d\" | git mergetool file12 >/dev/null 2>&1 ) &&\n@@ -131,6 +139,7 @@ test_expect_success 'mergetool on file in parent dir' '\n \tcd subdir &&\n \t( yes \"\" | git mergetool ../file1 >/dev/null 2>&1 ) &&\n \t( yes \"\" | git mergetool ../file2 ../spaced\\ name >/dev/null 2>&1 ) &&\n+\t( yes \"\" | git mergetool ../both >/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@@ -212,6 +221,7 @@ test_expect_success 'deleted vs modified submodule' '\n     test_must_fail git merge master &&\n     test -n \"$(git ls-files -u)\" &&\n     ( yes \"\" | git mergetool file1 file2 spaced\\ name subdir/file3 >/dev/null 2>&1 ) &&\n+    ( yes \"\" | git mergetool both >/dev/null 2>&1 ) &&\n     ( yes \"d\" | git mergetool file11 file12 >/dev/null 2>&1 ) &&\n     ( yes \"r\" | git mergetool submod ) &&\n     rmdir submod && mv submod-movedaside submod &&\n@@ -228,6 +238,7 @@ test_expect_success 'deleted vs modified submodule' '\n     test_must_fail git merge master &&\n     test -n \"$(git ls-files -u)\" &&\n     ( yes \"\" | git mergetool file1 file2 spaced\\ name subdir/file3 >/dev/null 2>&1 ) &&\n+    ( yes \"\" | git mergetool both >/dev/null 2>&1 ) &&\n     ( yes \"d\" | git mergetool file11 file12 >/dev/null 2>&1 ) &&\n     ( yes \"l\" | git mergetool submod ) &&\n     test ! -e submod &&\n@@ -241,6 +252,7 @@ test_expect_success 'deleted vs modified submodule' '\n     test_must_fail git merge test6 &&\n     test -n \"$(git ls-files -u)\" &&\n     ( yes \"\" | git mergetool file1 file2 spaced\\ name subdir/file3 >/dev/null 2>&1 ) &&\n+    ( yes \"\" | git mergetool both >/dev/null 2>&1 ) &&\n     ( yes \"d\" | git mergetool file11 file12 >/dev/null 2>&1 ) &&\n     ( yes \"r\" | git mergetool submod ) &&\n     test ! -e submod &&\n@@ -256,6 +268,7 @@ test_expect_success 'deleted vs modified submodule' '\n     test_must_fail git merge test6 &&\n     test -n \"$(git ls-files -u)\" &&\n     ( yes \"\" | git mergetool file1 file2 spaced\\ name subdir/file3 >/dev/null 2>&1 ) &&\n+    ( yes \"\" | git mergetool both >/dev/null 2>&1 ) &&\n     ( yes \"d\" | git mergetool file11 file12 >/dev/null 2>&1 ) &&\n     ( yes \"l\" | git mergetool submod ) &&\n     test \"$(cat submod/bar)\" = \"master submodule\" &&\n@@ -279,6 +292,7 @@ test_expect_success 'file vs modified submodule' '\n     test_must_fail git merge master &&\n     test -n \"$(git ls-files -u)\" &&\n     ( yes \"\" | git mergetool file1 file2 spaced\\ name subdir/file3 >/dev/null 2>&1 ) &&\n+    ( yes \"\" | git mergetool both >/dev/null 2>&1 ) &&\n     ( yes \"d\" | git mergetool file11 file12 >/dev/null 2>&1 ) &&\n     ( yes \"r\" | git mergetool submod ) &&\n     rmdir submod && mv submod-movedaside submod &&\n@@ -294,6 +308,7 @@ test_expect_success 'file vs modified submodule' '\n     test_must_fail git merge master &&\n     test -n \"$(git ls-files -u)\" &&\n     ( yes \"\" | git mergetool file1 file2 spaced\\ name subdir/file3 >/dev/null 2>&1 ) &&\n+    ( yes \"\" | git mergetool both >/dev/null 2>&1 ) &&\n     ( yes \"d\" | git mergetool file11 file12 >/dev/null 2>&1 ) &&\n     ( yes \"l\" | git mergetool submod ) &&\n     git submodule update -N &&\n@@ -309,6 +324,7 @@ test_expect_success 'file vs modified submodule' '\n     test_must_fail git merge test7 &&\n     test -n \"$(git ls-files -u)\" &&\n     ( yes \"\" | git mergetool file1 file2 spaced\\ name subdir/file3 >/dev/null 2>&1 ) &&\n+    ( yes \"\" | git mergetool both >/dev/null 2>&1 ) &&\n     ( yes \"d\" | git mergetool file11 file12 >/dev/null 2>&1 ) &&\n     ( yes \"r\" | git mergetool submod ) &&\n     test -d submod.orig &&\n@@ -324,6 +340,7 @@ test_expect_success 'file vs modified submodule' '\n     test_must_fail git merge test7 &&\n     test -n \"$(git ls-files -u)\" &&\n     ( yes \"\" | git mergetool file1 file2 spaced\\ name subdir/file3 >/dev/null 2>&1 ) &&\n+    ( yes \"\" | git mergetool both>/dev/null 2>&1 ) &&\n     ( yes \"d\" | git mergetool file11 file12 >/dev/null 2>&1 ) &&\n     ( yes \"l\" | git mergetool submod ) &&\n     test \"$(cat submod/bar)\" = \"master submodule\" &&\n@@ -445,4 +462,12 @@ test_expect_success 'directory vs modified submodule' '\n     git submodule update -N\n '\n \n+test_expect_success 'file with no base' '\n+    git checkout -b test13 branch1 &&\n+    test_must_fail git merge master &&\n+    git mergetool --no-prompt --tool mybase -- base &&\n+    test \"$(cat \"$MERGED\")\" = \"\" &&\n+    git reset --hard master >/dev/null 2>&1\n+'\n+\n test_done\n-- \n1.7.9.rc2.1.g36b4c\n"},{"id":"182843","messageId":"CAJDDKr71Q9ihLZdP1Pu=ebpvX0EPvW-9bN6kZz9MeuhYKZzh+Q@mail.gmail.com","threadId":"29394","inReplyTo":"1327045655-3368-1-git-send-email-davvid@gmail.com","subject":"Re: [PATCH v3] mergetool: Provide an empty file when needed","fromName":"David Aguilar","fromEmail":"davvid@gmail.com","sentAt":"2012-01-20T07:53:53Z","receivedAt":"2012-01-20T07:53:53Z","isPatch":true,"sender":{"key":"davvid@gmail.com","avatar":"https://avatars.githubusercontent.com/u/13196?v=4"},"body":"On Thu, Jan 19, 2012 at 11:47 PM, David Aguilar <davvid@gmail.com> wrote:\n> Some merge tools cannot cope when $LOCAL, $BASE, or $REMOTE\n> are missing.  $BASE can be missing when two branches\n> independently add the same filename.  $LOCAL and $REMOTE\n> can be missing when a delete/modify conflict occurs.\n>\n> Provide an empty file to make these tools happy.\n>\n> Reported-by: Jason Wenger <jcwenger@gmail.com>\n> Signed-off-by: David Aguilar <davvid@gmail.com>\n> ---\n> We now create the empty file in checkout_staged_file()\n> as part of the error checking section.\n>\n>  git-mergetool.sh     |    8 +++++---\n>  t/t7610-mergetool.sh |   27 ++++++++++++++++++++++++++-\n>  2 files changed, 31 insertions(+), 4 deletions(-)\n\n\nI certainly like this version the best.  This diff is smaller and it's\nall handled in one place.  It should've been marked PATCH v4 ;-)\n\nThanks for the review.\n\n> diff --git a/git-mergetool.sh b/git-mergetool.sh\n> index 085e213..24bedc5 100755\n> --- a/git-mergetool.sh\n> +++ b/git-mergetool.sh\n> @@ -185,6 +185,8 @@ checkout_staged_file () {\n>\n>     if test $? -eq 0 -a -n \"$tmpfile\" ; then\n>        mv -- \"$(git rev-parse --show-cdup)$tmpfile\" \"$3\"\n> +    else\n> +       >\"$3\"\n>     fi\n>  }\n>\n> @@ -224,9 +226,9 @@ merge_file () {\n>     mv -- \"$MERGED\" \"$BACKUP\"\n>     cp -- \"$BACKUP\" \"$MERGED\"\n>\n> -    base_present   && checkout_staged_file 1 \"$MERGED\" \"$BASE\"\n> -    local_present  && checkout_staged_file 2 \"$MERGED\" \"$LOCAL\"\n> -    remote_present && checkout_staged_file 3 \"$MERGED\" \"$REMOTE\"\n> +    checkout_staged_file 1 \"$MERGED\" \"$BASE\"\n> +    checkout_staged_file 2 \"$MERGED\" \"$LOCAL\"\n> +    checkout_staged_file 3 \"$MERGED\" \"$REMOTE\"\n>\n>     if test -z \"$local_mode\" -o -z \"$remote_mode\"; then\n>        echo \"Deleted merge conflict for '$MERGED':\"\n> diff --git a/t/t7610-mergetool.sh b/t/t7610-mergetool.sh\n> index 4aab2a7..2272743 100755\n> --- a/t/t7610-mergetool.sh\n> +++ b/t/t7610-mergetool.sh\n> @@ -39,6 +39,7 @@ test_expect_success 'setup' '\n>     echo branch1 change >file1 &&\n>     echo branch1 newfile >file2 &&\n>     echo branch1 spaced >\"spaced name\" &&\n> +    echo branch1 both added > both &&\n>     echo branch1 change file11 >file11 &&\n>     echo branch1 change file13 >file13 &&\n>     echo branch1 sub >subdir/file3 &&\n> @@ -50,6 +51,7 @@ test_expect_success 'setup' '\n>        git checkout -b submod-branch1\n>     ) &&\n>     git add file1 \"spaced name\" file11 file13 file2 subdir/file3 submod &&\n> +    git add both &&\n>     git rm file12 &&\n>     git commit -m \"branch1 changes\" &&\n>\n> @@ -58,6 +60,7 @@ test_expect_success 'setup' '\n>     echo master updated >file1 &&\n>     echo master new >file2 &&\n>     echo master updated spaced >\"spaced name\" &&\n> +    echo master both added > both &&\n>     echo master updated file12 >file12 &&\n>     echo master updated file14 >file14 &&\n>     echo master new sub >subdir/file3 &&\n> @@ -69,18 +72,22 @@ test_expect_success 'setup' '\n>        git checkout -b submod-master\n>     ) &&\n>     git add file1 \"spaced name\" file12 file14 file2 subdir/file3 submod &&\n> +    git add both &&\n>     git rm file11 &&\n>     git commit -m \"master updates\" &&\n>\n>     git config merge.tool mytool &&\n>     git config mergetool.mytool.cmd \"cat \\\"\\$REMOTE\\\" >\\\"\\$MERGED\\\"\" &&\n> -    git config mergetool.mytool.trustExitCode true\n> +    git config mergetool.mytool.trustExitCode true &&\n> +    git config mergetool.mybase.cmd \"cat \\\"\\$BASE\\\" >\\\"\\$MERGED\\\"\" &&\n> +    git config mergetool.mybase.trustExitCode true\n>  '\n>\n>  test_expect_success 'custom mergetool' '\n>     git checkout -b test1 branch1 &&\n>     git submodule update -N &&\n>     test_must_fail git merge master >/dev/null 2>&1 &&\n> +    ( yes \"\" | git mergetool both >/dev/null 2>&1 ) &&\n>     ( yes \"\" | git mergetool file1 file1 ) &&\n>     ( yes \"\" | git mergetool file2 \"spaced name\" >/dev/null 2>&1 ) &&\n>     ( yes \"\" | git mergetool subdir/file3 >/dev/null 2>&1 ) &&\n> @@ -101,6 +108,7 @@ test_expect_success 'mergetool crlf' '\n>     ( yes \"\" | git mergetool file1 >/dev/null 2>&1 ) &&\n>     ( yes \"\" | git mergetool file2 >/dev/null 2>&1 ) &&\n>     ( yes \"\" | git mergetool \"spaced name\" >/dev/null 2>&1 ) &&\n> +    ( yes \"\" | git mergetool both >/dev/null 2>&1 ) &&\n>     ( yes \"\" | git mergetool subdir/file3 >/dev/null 2>&1 ) &&\n>     ( yes \"d\" | git mergetool file11 >/dev/null 2>&1 ) &&\n>     ( yes \"d\" | git mergetool file12 >/dev/null 2>&1 ) &&\n> @@ -131,6 +139,7 @@ test_expect_success 'mergetool on file in parent dir' '\n>        cd subdir &&\n>        ( yes \"\" | git mergetool ../file1 >/dev/null 2>&1 ) &&\n>        ( yes \"\" | git mergetool ../file2 ../spaced\\ name >/dev/null 2>&1 ) &&\n> +       ( yes \"\" | git mergetool ../both >/dev/null 2>&1 ) &&\n>        ( yes \"d\" | git mergetool ../file11 >/dev/null 2>&1 ) &&\n>        ( yes \"d\" | git mergetool ../file12 >/dev/null 2>&1 ) &&\n>        ( yes \"l\" | git mergetool ../submod >/dev/null 2>&1 ) &&\n> @@ -212,6 +221,7 @@ test_expect_success 'deleted vs modified submodule' '\n>     test_must_fail git merge master &&\n>     test -n \"$(git ls-files -u)\" &&\n>     ( yes \"\" | git mergetool file1 file2 spaced\\ name subdir/file3 >/dev/null 2>&1 ) &&\n> +    ( yes \"\" | git mergetool both >/dev/null 2>&1 ) &&\n>     ( yes \"d\" | git mergetool file11 file12 >/dev/null 2>&1 ) &&\n>     ( yes \"r\" | git mergetool submod ) &&\n>     rmdir submod && mv submod-movedaside submod &&\n> @@ -228,6 +238,7 @@ test_expect_success 'deleted vs modified submodule' '\n>     test_must_fail git merge master &&\n>     test -n \"$(git ls-files -u)\" &&\n>     ( yes \"\" | git mergetool file1 file2 spaced\\ name subdir/file3 >/dev/null 2>&1 ) &&\n> +    ( yes \"\" | git mergetool both >/dev/null 2>&1 ) &&\n>     ( yes \"d\" | git mergetool file11 file12 >/dev/null 2>&1 ) &&\n>     ( yes \"l\" | git mergetool submod ) &&\n>     test ! -e submod &&\n> @@ -241,6 +252,7 @@ test_expect_success 'deleted vs modified submodule' '\n>     test_must_fail git merge test6 &&\n>     test -n \"$(git ls-files -u)\" &&\n>     ( yes \"\" | git mergetool file1 file2 spaced\\ name subdir/file3 >/dev/null 2>&1 ) &&\n> +    ( yes \"\" | git mergetool both >/dev/null 2>&1 ) &&\n>     ( yes \"d\" | git mergetool file11 file12 >/dev/null 2>&1 ) &&\n>     ( yes \"r\" | git mergetool submod ) &&\n>     test ! -e submod &&\n> @@ -256,6 +268,7 @@ test_expect_success 'deleted vs modified submodule' '\n>     test_must_fail git merge test6 &&\n>     test -n \"$(git ls-files -u)\" &&\n>     ( yes \"\" | git mergetool file1 file2 spaced\\ name subdir/file3 >/dev/null 2>&1 ) &&\n> +    ( yes \"\" | git mergetool both >/dev/null 2>&1 ) &&\n>     ( yes \"d\" | git mergetool file11 file12 >/dev/null 2>&1 ) &&\n>     ( yes \"l\" | git mergetool submod ) &&\n>     test \"$(cat submod/bar)\" = \"master submodule\" &&\n> @@ -279,6 +292,7 @@ test_expect_success 'file vs modified submodule' '\n>     test_must_fail git merge master &&\n>     test -n \"$(git ls-files -u)\" &&\n>     ( yes \"\" | git mergetool file1 file2 spaced\\ name subdir/file3 >/dev/null 2>&1 ) &&\n> +    ( yes \"\" | git mergetool both >/dev/null 2>&1 ) &&\n>     ( yes \"d\" | git mergetool file11 file12 >/dev/null 2>&1 ) &&\n>     ( yes \"r\" | git mergetool submod ) &&\n>     rmdir submod && mv submod-movedaside submod &&\n> @@ -294,6 +308,7 @@ test_expect_success 'file vs modified submodule' '\n>     test_must_fail git merge master &&\n>     test -n \"$(git ls-files -u)\" &&\n>     ( yes \"\" | git mergetool file1 file2 spaced\\ name subdir/file3 >/dev/null 2>&1 ) &&\n> +    ( yes \"\" | git mergetool both >/dev/null 2>&1 ) &&\n>     ( yes \"d\" | git mergetool file11 file12 >/dev/null 2>&1 ) &&\n>     ( yes \"l\" | git mergetool submod ) &&\n>     git submodule update -N &&\n> @@ -309,6 +324,7 @@ test_expect_success 'file vs modified submodule' '\n>     test_must_fail git merge test7 &&\n>     test -n \"$(git ls-files -u)\" &&\n>     ( yes \"\" | git mergetool file1 file2 spaced\\ name subdir/file3 >/dev/null 2>&1 ) &&\n> +    ( yes \"\" | git mergetool both >/dev/null 2>&1 ) &&\n>     ( yes \"d\" | git mergetool file11 file12 >/dev/null 2>&1 ) &&\n>     ( yes \"r\" | git mergetool submod ) &&\n>     test -d submod.orig &&\n> @@ -324,6 +340,7 @@ test_expect_success 'file vs modified submodule' '\n>     test_must_fail git merge test7 &&\n>     test -n \"$(git ls-files -u)\" &&\n>     ( yes \"\" | git mergetool file1 file2 spaced\\ name subdir/file3 >/dev/null 2>&1 ) &&\n> +    ( yes \"\" | git mergetool both>/dev/null 2>&1 ) &&\n>     ( yes \"d\" | git mergetool file11 file12 >/dev/null 2>&1 ) &&\n>     ( yes \"l\" | git mergetool submod ) &&\n>     test \"$(cat submod/bar)\" = \"master submodule\" &&\n> @@ -445,4 +462,12 @@ test_expect_success 'directory vs modified submodule' '\n>     git submodule update -N\n>  '\n>\n> +test_expect_success 'file with no base' '\n> +    git checkout -b test13 branch1 &&\n> +    test_must_fail git merge master &&\n> +    git mergetool --no-prompt --tool mybase -- base &&\n> +    test \"$(cat \"$MERGED\")\" = \"\" &&\n> +    git reset --hard master >/dev/null 2>&1\n> +'\n> +\n>  test_done\n> --\n> 1.7.9.rc2.1.g36b4c\n>\n\n\n\n-- \n            David\n"},{"id":"182854","messageId":"CAM6z=4-HfRAjJjnYqfoiYsYjiZJSsbkCaW-VtLWvoeFM0xsB9g@mail.gmail.com","threadId":"29394","inReplyTo":"CAJDDKr71Q9ihLZdP1Pu=ebpvX0EPvW-9bN6kZz9MeuhYKZzh+Q@mail.gmail.com","subject":"Re: [PATCH v3] mergetool: Provide an empty file when needed","fromName":"Jason Wenger","fromEmail":"jcwenger@gmail.com","sentAt":"2012-01-20T14:03:01Z","receivedAt":"2012-01-20T14:03:01Z","isPatch":true,"sender":{"key":"jcwenger@gmail.com","avatar":null},"body":"On Fri, Jan 20, 2012 at 01:53, David Aguilar <davvid@gmail.com> wrote:\n> On Thu, Jan 19, 2012 at 11:47 PM, David Aguilar <davvid@gmail.com> wrote:\n>> Some merge tools cannot cope when $LOCAL, $BASE, or $REMOTE\n>> are missing.  $BASE can be missing when two branches\n>> independently add the same filename.  $LOCAL and $REMOTE\n>> can be missing when a delete/modify conflict occurs.\n>>\n>> Provide an empty file to make these tools happy.\n\nThis is cleaner, yes -- but is this extra processing on $LOCAL and\n$REMOTE necessary?  Git mergetool doesn't actually call an external\nmergetool during del/mod conflicts -- instead it goes into an\nalternate processing and prompts the user interactively whether to\ntake the deleted or modified file.  Can these changes be reached?\n(command line option I'm not aware of?)\n\n--jcw\n"},{"id":"182867","messageId":"7vbopyfcty.fsf@alter.siamese.dyndns.org","threadId":"29394","inReplyTo":"CAM6z=4-HfRAjJjnYqfoiYsYjiZJSsbkCaW-VtLWvoeFM0xsB9g@mail.gmail.com","subject":"Re: [PATCH v3] mergetool: Provide an empty file when needed","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2012-01-20T18:28:25Z","receivedAt":"2012-01-20T18:28:25Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Jason Wenger <jcwenger@gmail.com> writes:\n\n> On Fri, Jan 20, 2012 at 01:53, David Aguilar <davvid@gmail.com> wrote:\n>> On Thu, Jan 19, 2012 at 11:47 PM, David Aguilar <davvid@gmail.com> wrote:\n>>> Some merge tools cannot cope when $LOCAL, $BASE, or $REMOTE\n>>> are missing.  $BASE can be missing when two branches\n>>> independently add the same filename.  $LOCAL and $REMOTE\n>>> can be missing when a delete/modify conflict occurs.\n>>>\n>>> Provide an empty file to make these tools happy.\n>\n> This is cleaner, yes -- but is this extra processing on $LOCAL and\n> $REMOTE necessary?  Git mergetool doesn't actually call an external\n> mergetool during del/mod conflicts -- instead it goes into an\n> alternate processing and prompts the user interactively whether to\n> take the deleted or modified file.  Can these changes be reached?\n> (command line option I'm not aware of?)\n\nThanks for a careful reading. I did not read outside the context of the\npatch so I didn't know if we had special cases for del/mod.\n\nA bigger question is if the del/mod codepaths are negatively affected by\nthe presense of these superfluous empty $LOCAL/$REMOTE files. If they are,\nthis change will _break_ things. If they are not, I think the change would\nbe OK.\n\nAnother small worry is that this could potentially negatively affect some\nmerge tools that are sufficiently clueful, if it can give different and\nbetter results for a true two-way-merge than a simulated two-way-merge\nthis patch feeds them by using a three-way-merge with an empty file as a\nbase.\n"}]}