Interesting behavior in git mergetool with no BASE revision
Doing a git merge on 1.7.4.3, on a case where both branches have a file created, and the base does not. Per git-mergetool:
"the configured command line will be invoked with $BASE set to the name of a temporary file containing the common base for the merge, if available;"
So testing in this case, I set my mergetool cmd as "echo $MERGED $LOCAL $REMOTE $BASE", and I get the following:
cio/.cproject ./cio/.cproject.LOCAL.9029.cproject
./cio/.cproject.REMOTE.9029.cproject
./cio/.cproject.BASE.9029.cproject
ls -a cio shows the following files:
.cproject
.cproject.LOCAL.9325.cproject
.cproject.BACKUP.9325.cproject
.cproject.REMOTE.9325.cproject
So the lack of base file makes sense -- There is no base to start from. However, $BASE evaluates to ./cio/.cproject.BASE.9029.cproject, which is a nonexistent file. This makes my actual mergetool upset to no end. Intuitively from documents, I would expect $BASE to evaluate to an empty string in this case.
Is this intended behavior?
--Jason C. Wenger
Quoted 9 lines · Jason Wenger
Doing a git merge on 1.7.4.3, on a case where both branches have a file created, and the base does not. Per git-mergetool:
"the configured command line will be invoked with $BASE set to the name of a temporary file containing the common base for the merge, if available;"
So testing in this case, I set my mergetool cmd as "echo $MERGED $LOCAL $REMOTE $BASE", and I get the following:
I have not seen this in practice. Maybe escape the variables?
In any case, I added a test case to cover this case. I think we should at least provide an empty file in place of a missing $BASE.
Quoted 11 lines
cio/.cproject ./cio/.cproject.LOCAL.9029.cproject
./cio/.cproject.REMOTE.9029.cproject
./cio/.cproject.BASE.9029.cprojectls -a cio shows the following files:
.cproject
.cproject.LOCAL.9325.cproject
.cproject.BACKUP.9325.cproject
.cproject.REMOTE.9325.cproject
Quoted 7 lines
So the lack of base file makes sense -- There is no base to start from. However, $BASE evaluates to ./cio/.cproject.BASE.9029.cproject, which is a nonexistent file. This makes my actual mergetool upset to no end. Intuitively from documents, I would expect $BASE to evaluate to an empty string in this case.
Is this intended behavior?
Not really. I'll send a patch shortly.
Signature · 1 line
David
PATCH 1/1 mergetool: Provide an empty file when no base exists
Some mergetools cannot cope when $BASE is missing. This can happen when two branches add the same file. Provide an empty file to make these tools happy.
--- git-mergetool.sh | 6 +++++- t/t7610-mergetool.sh | 27 ++++++++++++++++++++++++++- 2 files changed, 31 insertions(+), 2 deletions(-)
git-mergetool.sh +5 -1
@@ -224,7 +224,11 @@ merge_file () { mv -- "$MERGED" "$BACKUP" cp -- "$BACKUP" "$MERGED" - base_present && checkout_staged_file 1 "$MERGED" "$BASE" + if base_present; then + checkout_staged_file 1 "$MERGED" "$BASE" + else + touch "$BASE" + fi local_present && checkout_staged_file 2 "$MERGED" "$LOCAL" remote_present && checkout_staged_file 3 "$MERGED" "$REMOTE"
t/t7610-mergetool.sh +26 -1
@@ -39,6 +39,7 @@ test_expect_success 'setup' ' echo branch1 change >file1 && echo branch1 newfile >file2 && echo branch1 spaced >"spaced name" && + echo branch1 both added > both && echo branch1 change file11 >file11 && echo branch1 change file13 >file13 && echo branch1 sub >subdir/file3 &&
@@ -50,6 +51,7 @@ test_expect_success 'setup' ' git checkout -b submod-branch1 ) && git add file1 "spaced name" file11 file13 file2 subdir/file3 submod && + git add both && git rm file12 && git commit -m "branch1 changes" &&
@@ -58,6 +60,7 @@ test_expect_success 'setup' ' echo master updated >file1 && echo master new >file2 && echo master updated spaced >"spaced name" && + echo master both added > both && echo master updated file12 >file12 && echo master updated file14 >file14 && echo master new sub >subdir/file3 &&
@@ -69,18 +72,22 @@ test_expect_success 'setup' ' git checkout -b submod-master ) && git add file1 "spaced name" file12 file14 file2 subdir/file3 submod && + git add both && git rm file11 && git commit -m "master updates" && git config merge.tool mytool && git config mergetool.mytool.cmd "cat \"\$REMOTE\" >\"\$MERGED\"" && - git config mergetool.mytool.trustExitCode true + git config mergetool.mytool.trustExitCode true && + git config mergetool.mybase.cmd "cat \"\$BASE\" >\"\$MERGED\"" && + git config mergetool.mybase.trustExitCode true ' test_expect_success 'custom mergetool' ' git checkout -b test1 branch1 && git submodule update -N && test_must_fail git merge master >/dev/null 2>&1 && + ( yes "" | git mergetool both >/dev/null 2>&1 ) && ( yes "" | git mergetool file1 file1 ) && ( yes "" | git mergetool file2 "spaced name" >/dev/null 2>&1 ) && ( yes "" | git mergetool subdir/file3 >/dev/null 2>&1 ) &&
@@ -101,6 +108,7 @@ test_expect_success 'mergetool crlf' ' ( yes "" | git mergetool file1 >/dev/null 2>&1 ) && ( yes "" | git mergetool file2 >/dev/null 2>&1 ) && ( yes "" | git mergetool "spaced name" >/dev/null 2>&1 ) && + ( yes "" | git mergetool both >/dev/null 2>&1 ) && ( yes "" | git mergetool subdir/file3 >/dev/null 2>&1 ) && ( yes "d" | git mergetool file11 >/dev/null 2>&1 ) && ( yes "d" | git mergetool file12 >/dev/null 2>&1 ) &&
@@ -131,6 +139,7 @@ test_expect_success 'mergetool on file in parent dir' ' cd subdir && ( yes "" | git mergetool ../file1 >/dev/null 2>&1 ) && ( yes "" | git mergetool ../file2 ../spaced\ name >/dev/null 2>&1 ) && + ( yes "" | git mergetool ../both >/dev/null 2>&1 ) && ( yes "d" | git mergetool ../file11 >/dev/null 2>&1 ) && ( yes "d" | git mergetool ../file12 >/dev/null 2>&1 ) && ( yes "l" | git mergetool ../submod >/dev/null 2>&1 ) &&
@@ -212,6 +221,7 @@ test_expect_success 'deleted vs modified submodule' ' test_must_fail git merge master && test -n "$(git ls-files -u)" && ( yes "" | git mergetool file1 file2 spaced\ name subdir/file3 >/dev/null 2>&1 ) && + ( yes "" | git mergetool both >/dev/null 2>&1 ) && ( yes "d" | git mergetool file11 file12 >/dev/null 2>&1 ) && ( yes "r" | git mergetool submod ) && rmdir submod && mv submod-movedaside submod &&
@@ -228,6 +238,7 @@ test_expect_success 'deleted vs modified submodule' ' test_must_fail git merge master && test -n "$(git ls-files -u)" && ( yes "" | git mergetool file1 file2 spaced\ name subdir/file3 >/dev/null 2>&1 ) && + ( yes "" | git mergetool both >/dev/null 2>&1 ) && ( yes "d" | git mergetool file11 file12 >/dev/null 2>&1 ) && ( yes "l" | git mergetool submod ) && test ! -e submod &&
@@ -241,6 +252,7 @@ test_expect_success 'deleted vs modified submodule' ' test_must_fail git merge test6 && test -n "$(git ls-files -u)" && ( yes "" | git mergetool file1 file2 spaced\ name subdir/file3 >/dev/null 2>&1 ) && + ( yes "" | git mergetool both >/dev/null 2>&1 ) && ( yes "d" | git mergetool file11 file12 >/dev/null 2>&1 ) && ( yes "r" | git mergetool submod ) && test ! -e submod &&
@@ -256,6 +268,7 @@ test_expect_success 'deleted vs modified submodule' ' test_must_fail git merge test6 && test -n "$(git ls-files -u)" && ( yes "" | git mergetool file1 file2 spaced\ name subdir/file3 >/dev/null 2>&1 ) && + ( yes "" | git mergetool both >/dev/null 2>&1 ) && ( yes "d" | git mergetool file11 file12 >/dev/null 2>&1 ) && ( yes "l" | git mergetool submod ) && test "$(cat submod/bar)" = "master submodule" &&
@@ -279,6 +292,7 @@ test_expect_success 'file vs modified submodule' ' test_must_fail git merge master && test -n "$(git ls-files -u)" && ( yes "" | git mergetool file1 file2 spaced\ name subdir/file3 >/dev/null 2>&1 ) && + ( yes "" | git mergetool both >/dev/null 2>&1 ) && ( yes "d" | git mergetool file11 file12 >/dev/null 2>&1 ) && ( yes "r" | git mergetool submod ) && rmdir submod && mv submod-movedaside submod &&
@@ -294,6 +308,7 @@ test_expect_success 'file vs modified submodule' ' test_must_fail git merge master && test -n "$(git ls-files -u)" && ( yes "" | git mergetool file1 file2 spaced\ name subdir/file3 >/dev/null 2>&1 ) && + ( yes "" | git mergetool both >/dev/null 2>&1 ) && ( yes "d" | git mergetool file11 file12 >/dev/null 2>&1 ) && ( yes "l" | git mergetool submod ) && git submodule update -N &&
@@ -309,6 +324,7 @@ test_expect_success 'file vs modified submodule' ' test_must_fail git merge test7 && test -n "$(git ls-files -u)" && ( yes "" | git mergetool file1 file2 spaced\ name subdir/file3 >/dev/null 2>&1 ) && + ( yes "" | git mergetool both >/dev/null 2>&1 ) && ( yes "d" | git mergetool file11 file12 >/dev/null 2>&1 ) && ( yes "r" | git mergetool submod ) && test -d submod.orig &&
@@ -324,6 +340,7 @@ test_expect_success 'file vs modified submodule' ' test_must_fail git merge test7 && test -n "$(git ls-files -u)" && ( yes "" | git mergetool file1 file2 spaced\ name subdir/file3 >/dev/null 2>&1 ) && + ( yes "" | git mergetool both>/dev/null 2>&1 ) && ( yes "d" | git mergetool file11 file12 >/dev/null 2>&1 ) && ( yes "l" | git mergetool submod ) && test "$(cat submod/bar)" = "master submodule" &&
@@ -445,4 +462,12 @@ test_expect_success 'directory vs modified submodule' ' git submodule update -N ' +test_expect_success 'file with no base' ' + git checkout -b test13 branch1 && + test_must_fail git merge master && + git mergetool --no-prompt --tool mybase -- base && + test "$(cat "$MERGED")" = "" && + git reset --hard master >/dev/null 2>&1 +' + test_done
Signature · 1 line
1.7.9.rc2.1.gb566f
Re: [PATCH] mergetool: Provide an empty file when no base exists
Quoted 16 lines · David Aguilar
Some mergetools cannot cope when $BASE is missing. This can happen when two branches add the same file. Provide an empty file to make these tools happy.
Reported-by Jason Wenger <[email protected]>Signed-off-by David Aguilar <[email protected]>--- git-mergetool.sh | 6 +++++- t/t7610-mergetool.sh | 27 ++++++++++++++++++++++++++- 2 files changed, 31 insertions(+), 2 deletions(-)git-mergetool.sh +0
-0
git-mergetool.sh merge_file () { · line 231
Quoted 9 lines
git-mergetool.sh +5
-1@@ -224,7 +224,11 @@ merge_file () { mv -- "$MERGED" "$BACKUP" cp -- "$BACKUP" "$MERGED" - base_present && checkout_staged_file 1 "$MERGED" "$BASE" + if base_present; then + checkout_staged_file 1 "$MERGED" "$BASE" + else + touch "$BASE" + fi
Using "touch" for things like this is a disease.
You not just want to make sure it exists, but also you want to make sure it is empty, so it would make your intention more explicit and clear if you wrote this as
>"$BASE"
instead.
I also wonder if it may help mergetools if we come up with a fake base image using the common material between the two files, in a way similar to how git-merge-one-file.sh does it (look for "Added $4 in both, but differently"), but obviously it would belong to a separate patch.
Thanks.
PATCH 1/1 mergetool: Provide an empty file when no base exists
Some mergetools cannot cope when $BASE is missing. This can happen when two branches add the same file. Provide an empty file to make these tools happy.
--- git-mergetool.sh | 6 +++++- t/t7610-mergetool.sh | 27 ++++++++++++++++++++++++++- 2 files changed, 31 insertions(+), 2 deletions(-)
git-mergetool.sh +5 -1
@@ -224,7 +224,11 @@ merge_file () { mv -- "$MERGED" "$BACKUP" cp -- "$BACKUP" "$MERGED" - base_present && checkout_staged_file 1 "$MERGED" "$BASE" + if base_present; then + checkout_staged_file 1 "$MERGED" "$BASE" + else + :>"$BASE" + fi local_present && checkout_staged_file 2 "$MERGED" "$LOCAL" remote_present && checkout_staged_file 3 "$MERGED" "$REMOTE"
t/t7610-mergetool.sh +26 -1
@@ -39,6 +39,7 @@ test_expect_success 'setup' ' echo branch1 change >file1 && echo branch1 newfile >file2 && echo branch1 spaced >"spaced name" && + echo branch1 both added > both && echo branch1 change file11 >file11 && echo branch1 change file13 >file13 && echo branch1 sub >subdir/file3 &&
@@ -50,6 +51,7 @@ test_expect_success 'setup' ' git checkout -b submod-branch1 ) && git add file1 "spaced name" file11 file13 file2 subdir/file3 submod && + git add both && git rm file12 && git commit -m "branch1 changes" &&
@@ -58,6 +60,7 @@ test_expect_success 'setup' ' echo master updated >file1 && echo master new >file2 && echo master updated spaced >"spaced name" && + echo master both added > both && echo master updated file12 >file12 && echo master updated file14 >file14 && echo master new sub >subdir/file3 &&
@@ -69,18 +72,22 @@ test_expect_success 'setup' ' git checkout -b submod-master ) && git add file1 "spaced name" file12 file14 file2 subdir/file3 submod && + git add both && git rm file11 && git commit -m "master updates" && git config merge.tool mytool && git config mergetool.mytool.cmd "cat \"\$REMOTE\" >\"\$MERGED\"" && - git config mergetool.mytool.trustExitCode true + git config mergetool.mytool.trustExitCode true && + git config mergetool.mybase.cmd "cat \"\$BASE\" >\"\$MERGED\"" && + git config mergetool.mybase.trustExitCode true ' test_expect_success 'custom mergetool' ' git checkout -b test1 branch1 && git submodule update -N && test_must_fail git merge master >/dev/null 2>&1 && + ( yes "" | git mergetool both >/dev/null 2>&1 ) && ( yes "" | git mergetool file1 file1 ) && ( yes "" | git mergetool file2 "spaced name" >/dev/null 2>&1 ) && ( yes "" | git mergetool subdir/file3 >/dev/null 2>&1 ) &&
@@ -101,6 +108,7 @@ test_expect_success 'mergetool crlf' ' ( yes "" | git mergetool file1 >/dev/null 2>&1 ) && ( yes "" | git mergetool file2 >/dev/null 2>&1 ) && ( yes "" | git mergetool "spaced name" >/dev/null 2>&1 ) && + ( yes "" | git mergetool both >/dev/null 2>&1 ) && ( yes "" | git mergetool subdir/file3 >/dev/null 2>&1 ) && ( yes "d" | git mergetool file11 >/dev/null 2>&1 ) && ( yes "d" | git mergetool file12 >/dev/null 2>&1 ) &&
@@ -131,6 +139,7 @@ test_expect_success 'mergetool on file in parent dir' ' cd subdir && ( yes "" | git mergetool ../file1 >/dev/null 2>&1 ) && ( yes "" | git mergetool ../file2 ../spaced\ name >/dev/null 2>&1 ) && + ( yes "" | git mergetool ../both >/dev/null 2>&1 ) && ( yes "d" | git mergetool ../file11 >/dev/null 2>&1 ) && ( yes "d" | git mergetool ../file12 >/dev/null 2>&1 ) && ( yes "l" | git mergetool ../submod >/dev/null 2>&1 ) &&
@@ -212,6 +221,7 @@ test_expect_success 'deleted vs modified submodule' ' test_must_fail git merge master && test -n "$(git ls-files -u)" && ( yes "" | git mergetool file1 file2 spaced\ name subdir/file3 >/dev/null 2>&1 ) && + ( yes "" | git mergetool both >/dev/null 2>&1 ) && ( yes "d" | git mergetool file11 file12 >/dev/null 2>&1 ) && ( yes "r" | git mergetool submod ) && rmdir submod && mv submod-movedaside submod &&
@@ -228,6 +238,7 @@ test_expect_success 'deleted vs modified submodule' ' test_must_fail git merge master && test -n "$(git ls-files -u)" && ( yes "" | git mergetool file1 file2 spaced\ name subdir/file3 >/dev/null 2>&1 ) && + ( yes "" | git mergetool both >/dev/null 2>&1 ) && ( yes "d" | git mergetool file11 file12 >/dev/null 2>&1 ) && ( yes "l" | git mergetool submod ) && test ! -e submod &&
@@ -241,6 +252,7 @@ test_expect_success 'deleted vs modified submodule' ' test_must_fail git merge test6 && test -n "$(git ls-files -u)" && ( yes "" | git mergetool file1 file2 spaced\ name subdir/file3 >/dev/null 2>&1 ) && + ( yes "" | git mergetool both >/dev/null 2>&1 ) && ( yes "d" | git mergetool file11 file12 >/dev/null 2>&1 ) && ( yes "r" | git mergetool submod ) && test ! -e submod &&
@@ -256,6 +268,7 @@ test_expect_success 'deleted vs modified submodule' ' test_must_fail git merge test6 && test -n "$(git ls-files -u)" && ( yes "" | git mergetool file1 file2 spaced\ name subdir/file3 >/dev/null 2>&1 ) && + ( yes "" | git mergetool both >/dev/null 2>&1 ) && ( yes "d" | git mergetool file11 file12 >/dev/null 2>&1 ) && ( yes "l" | git mergetool submod ) && test "$(cat submod/bar)" = "master submodule" &&
@@ -279,6 +292,7 @@ test_expect_success 'file vs modified submodule' ' test_must_fail git merge master && test -n "$(git ls-files -u)" && ( yes "" | git mergetool file1 file2 spaced\ name subdir/file3 >/dev/null 2>&1 ) && + ( yes "" | git mergetool both >/dev/null 2>&1 ) && ( yes "d" | git mergetool file11 file12 >/dev/null 2>&1 ) && ( yes "r" | git mergetool submod ) && rmdir submod && mv submod-movedaside submod &&
@@ -294,6 +308,7 @@ test_expect_success 'file vs modified submodule' ' test_must_fail git merge master && test -n "$(git ls-files -u)" && ( yes "" | git mergetool file1 file2 spaced\ name subdir/file3 >/dev/null 2>&1 ) && + ( yes "" | git mergetool both >/dev/null 2>&1 ) && ( yes "d" | git mergetool file11 file12 >/dev/null 2>&1 ) && ( yes "l" | git mergetool submod ) && git submodule update -N &&
@@ -309,6 +324,7 @@ test_expect_success 'file vs modified submodule' ' test_must_fail git merge test7 && test -n "$(git ls-files -u)" && ( yes "" | git mergetool file1 file2 spaced\ name subdir/file3 >/dev/null 2>&1 ) && + ( yes "" | git mergetool both >/dev/null 2>&1 ) && ( yes "d" | git mergetool file11 file12 >/dev/null 2>&1 ) && ( yes "r" | git mergetool submod ) && test -d submod.orig &&
@@ -324,6 +340,7 @@ test_expect_success 'file vs modified submodule' ' test_must_fail git merge test7 && test -n "$(git ls-files -u)" && ( yes "" | git mergetool file1 file2 spaced\ name subdir/file3 >/dev/null 2>&1 ) && + ( yes "" | git mergetool both>/dev/null 2>&1 ) && ( yes "d" | git mergetool file11 file12 >/dev/null 2>&1 ) && ( yes "l" | git mergetool submod ) && test "$(cat submod/bar)" = "master submodule" &&
@@ -445,4 +462,12 @@ test_expect_success 'directory vs modified submodule' ' git submodule update -N ' +test_expect_success 'file with no base' ' + git checkout -b test13 branch1 && + test_must_fail git merge master && + git mergetool --no-prompt --tool mybase -- base && + test "$(cat "$MERGED")" = "" && + git reset --hard master >/dev/null 2>&1 +' + test_done
Signature · 1 line
1.7.9.rc2.1.gdcba7
Re: [PATCH] mergetool: Provide an empty file when no base exists
git-mergetool.sh merge_file () { · line 230
Quoted 4 lines · David Aguilar
git-mergetool.sh +4
-0+ if base_present; then + checkout_staged_file 1 "$MERGED" "$BASE" + else + :>"$BASE"
Just a style, but please write this as either one of the following:
>"$BASE"
: >"$BASE"I tend to prefer the former, but if you have to write a command, we want to see a SP before the redirection (and no SP before the redirect target).
Quoted 3 lines
+ fi
local_present && checkout_staged_file 2 "$MERGED" "$LOCAL" remote_present && checkout_staged_file 3 "$MERGED" "$REMOTE"
Sorry to be ping-pong-ing like this, but wouldn't we have a similar issue when LOCAL or REMOTE does not exist (e.g. "they modified, we removed")?
PATCH v3 1/1 mergetool: Provide an empty file when needed
Some merge tools cannot cope when $LOCAL, $BASE, or $REMOTE are missing. $BASE can be missing when two branches independently add the same filename. $LOCAL and $REMOTE can be missing when a delete/modify conflict occurs.
Provide an empty file to make these tools happy.
--- git-mergetool.sh | 20 +++++++++++++++++--- t/t7610-mergetool.sh | 27 ++++++++++++++++++++++++++- 2 files changed, 43 insertions(+), 4 deletions(-)
git-mergetool.sh +17 -3
@@ -224,9 +224,23 @@ merge_file () { mv -- "$MERGED" "$BACKUP" cp -- "$BACKUP" "$MERGED" - base_present && checkout_staged_file 1 "$MERGED" "$BASE" - local_present && checkout_staged_file 2 "$MERGED" "$LOCAL" - remote_present && checkout_staged_file 3 "$MERGED" "$REMOTE" + if base_present; then + checkout_staged_file 1 "$MERGED" "$BASE" + else + >"$BASE" + fi + + if local_present; then + checkout_staged_file 2 "$MERGED" "$LOCAL" + else + >"$LOCAL" + fi + + if remote_present; then + checkout_staged_file 3 "$MERGED" "$REMOTE" + else + >"$REMOTE" + fi if test -z "$local_mode" -o -z "$remote_mode"; then echo "Deleted merge conflict for '$MERGED':"
t/t7610-mergetool.sh +26 -1
@@ -39,6 +39,7 @@ test_expect_success 'setup' ' echo branch1 change >file1 && echo branch1 newfile >file2 && echo branch1 spaced >"spaced name" && + echo branch1 both added > both && echo branch1 change file11 >file11 && echo branch1 change file13 >file13 && echo branch1 sub >subdir/file3 &&
@@ -50,6 +51,7 @@ test_expect_success 'setup' ' git checkout -b submod-branch1 ) && git add file1 "spaced name" file11 file13 file2 subdir/file3 submod && + git add both && git rm file12 && git commit -m "branch1 changes" &&
@@ -58,6 +60,7 @@ test_expect_success 'setup' ' echo master updated >file1 && echo master new >file2 && echo master updated spaced >"spaced name" && + echo master both added > both && echo master updated file12 >file12 && echo master updated file14 >file14 && echo master new sub >subdir/file3 &&
@@ -69,18 +72,22 @@ test_expect_success 'setup' ' git checkout -b submod-master ) && git add file1 "spaced name" file12 file14 file2 subdir/file3 submod && + git add both && git rm file11 && git commit -m "master updates" && git config merge.tool mytool && git config mergetool.mytool.cmd "cat \"\$REMOTE\" >\"\$MERGED\"" && - git config mergetool.mytool.trustExitCode true + git config mergetool.mytool.trustExitCode true && + git config mergetool.mybase.cmd "cat \"\$BASE\" >\"\$MERGED\"" && + git config mergetool.mybase.trustExitCode true ' test_expect_success 'custom mergetool' ' git checkout -b test1 branch1 && git submodule update -N && test_must_fail git merge master >/dev/null 2>&1 && + ( yes "" | git mergetool both >/dev/null 2>&1 ) && ( yes "" | git mergetool file1 file1 ) && ( yes "" | git mergetool file2 "spaced name" >/dev/null 2>&1 ) && ( yes "" | git mergetool subdir/file3 >/dev/null 2>&1 ) &&
@@ -101,6 +108,7 @@ test_expect_success 'mergetool crlf' ' ( yes "" | git mergetool file1 >/dev/null 2>&1 ) && ( yes "" | git mergetool file2 >/dev/null 2>&1 ) && ( yes "" | git mergetool "spaced name" >/dev/null 2>&1 ) && + ( yes "" | git mergetool both >/dev/null 2>&1 ) && ( yes "" | git mergetool subdir/file3 >/dev/null 2>&1 ) && ( yes "d" | git mergetool file11 >/dev/null 2>&1 ) && ( yes "d" | git mergetool file12 >/dev/null 2>&1 ) &&
@@ -131,6 +139,7 @@ test_expect_success 'mergetool on file in parent dir' ' cd subdir && ( yes "" | git mergetool ../file1 >/dev/null 2>&1 ) && ( yes "" | git mergetool ../file2 ../spaced\ name >/dev/null 2>&1 ) && + ( yes "" | git mergetool ../both >/dev/null 2>&1 ) && ( yes "d" | git mergetool ../file11 >/dev/null 2>&1 ) && ( yes "d" | git mergetool ../file12 >/dev/null 2>&1 ) && ( yes "l" | git mergetool ../submod >/dev/null 2>&1 ) &&
@@ -212,6 +221,7 @@ test_expect_success 'deleted vs modified submodule' ' test_must_fail git merge master && test -n "$(git ls-files -u)" && ( yes "" | git mergetool file1 file2 spaced\ name subdir/file3 >/dev/null 2>&1 ) && + ( yes "" | git mergetool both >/dev/null 2>&1 ) && ( yes "d" | git mergetool file11 file12 >/dev/null 2>&1 ) && ( yes "r" | git mergetool submod ) && rmdir submod && mv submod-movedaside submod &&
@@ -228,6 +238,7 @@ test_expect_success 'deleted vs modified submodule' ' test_must_fail git merge master && test -n "$(git ls-files -u)" && ( yes "" | git mergetool file1 file2 spaced\ name subdir/file3 >/dev/null 2>&1 ) && + ( yes "" | git mergetool both >/dev/null 2>&1 ) && ( yes "d" | git mergetool file11 file12 >/dev/null 2>&1 ) && ( yes "l" | git mergetool submod ) && test ! -e submod &&
@@ -241,6 +252,7 @@ test_expect_success 'deleted vs modified submodule' ' test_must_fail git merge test6 && test -n "$(git ls-files -u)" && ( yes "" | git mergetool file1 file2 spaced\ name subdir/file3 >/dev/null 2>&1 ) && + ( yes "" | git mergetool both >/dev/null 2>&1 ) && ( yes "d" | git mergetool file11 file12 >/dev/null 2>&1 ) && ( yes "r" | git mergetool submod ) && test ! -e submod &&
@@ -256,6 +268,7 @@ test_expect_success 'deleted vs modified submodule' ' test_must_fail git merge test6 && test -n "$(git ls-files -u)" && ( yes "" | git mergetool file1 file2 spaced\ name subdir/file3 >/dev/null 2>&1 ) && + ( yes "" | git mergetool both >/dev/null 2>&1 ) && ( yes "d" | git mergetool file11 file12 >/dev/null 2>&1 ) && ( yes "l" | git mergetool submod ) && test "$(cat submod/bar)" = "master submodule" &&
@@ -279,6 +292,7 @@ test_expect_success 'file vs modified submodule' ' test_must_fail git merge master && test -n "$(git ls-files -u)" && ( yes "" | git mergetool file1 file2 spaced\ name subdir/file3 >/dev/null 2>&1 ) && + ( yes "" | git mergetool both >/dev/null 2>&1 ) && ( yes "d" | git mergetool file11 file12 >/dev/null 2>&1 ) && ( yes "r" | git mergetool submod ) && rmdir submod && mv submod-movedaside submod &&
@@ -294,6 +308,7 @@ test_expect_success 'file vs modified submodule' ' test_must_fail git merge master && test -n "$(git ls-files -u)" && ( yes "" | git mergetool file1 file2 spaced\ name subdir/file3 >/dev/null 2>&1 ) && + ( yes "" | git mergetool both >/dev/null 2>&1 ) && ( yes "d" | git mergetool file11 file12 >/dev/null 2>&1 ) && ( yes "l" | git mergetool submod ) && git submodule update -N &&
@@ -309,6 +324,7 @@ test_expect_success 'file vs modified submodule' ' test_must_fail git merge test7 && test -n "$(git ls-files -u)" && ( yes "" | git mergetool file1 file2 spaced\ name subdir/file3 >/dev/null 2>&1 ) && + ( yes "" | git mergetool both >/dev/null 2>&1 ) && ( yes "d" | git mergetool file11 file12 >/dev/null 2>&1 ) && ( yes "r" | git mergetool submod ) && test -d submod.orig &&
@@ -324,6 +340,7 @@ test_expect_success 'file vs modified submodule' ' test_must_fail git merge test7 && test -n "$(git ls-files -u)" && ( yes "" | git mergetool file1 file2 spaced\ name subdir/file3 >/dev/null 2>&1 ) && + ( yes "" | git mergetool both>/dev/null 2>&1 ) && ( yes "d" | git mergetool file11 file12 >/dev/null 2>&1 ) && ( yes "l" | git mergetool submod ) && test "$(cat submod/bar)" = "master submodule" &&
@@ -445,4 +462,12 @@ test_expect_success 'directory vs modified submodule' ' git submodule update -N ' +test_expect_success 'file with no base' ' + git checkout -b test13 branch1 && + test_must_fail git merge master && + git mergetool --no-prompt --tool mybase -- base && + test "$(cat "$MERGED")" = "" && + git reset --hard master >/dev/null 2>&1 +' + test_done
Signature · 1 line
1.7.9.rc2.1.g1c18
Re: [PATCH] mergetool: Provide an empty file when no base exists
In reply to Junio C HamanoQuoted 15 lines · Junio C Hamano
Quoted 4 lines · David Aguilar
+ if
base_present; then
+checkout_staged_file1 "$MERGED" "$BASE"
+ else
+ :>"$BASE"Just a style, but please write this as either one of the following:
>"$BASE"
: >"$BASE"I tend to prefer the former, but if you have to write a command, we want to see a SP before the redirection (and no SP before the redirect target).
Quoted 6 lines
Quoted 3 lines
+ fi
local_present &&checkout_staged_file2 "$MERGED" "$LOCAL"remote_present&&checkout_staged_file3 "$MERGED" "$REMOTE"Sorry to be ping-pong-ing like this, but wouldn't we have a similar issue when LOCAL or REMOTE does not exist (e.g. "they modified, we removed")?
Yes. I'll have a [PATCH v3] soon.
Signature · 1 line
David
Re: [PATCH] mergetool: Provide an empty file when no base exists
Quoted 7 lines · David Aguilar
Quoted 5 lines
Quoted 2 lines
local_present &&
checkout_staged_file2 "$MERGED" "$LOCAL"remote_present&&checkout_staged_file3 "$MERGED" "$REMOTE"Sorry to be ping-pong-ing like this, but wouldn't we have a similar issue when LOCAL or REMOTE does not exist (e.g. "they modified, we removed")?
Yes. I'll have a [PATCH v3] soon.
It almost makes me wonder if the obviously simplest change to make checkout_staged_file create an empty file when the asked-for stage does not exist, i.e.
checkout_stage ()
{
if test -n "$1"
then
... whatever checkout_staged_file() does ...
else
>"$4"
fi
}
checkout_stage $base_mode 1 "$MERGED" "$BASE"
checkout_stage $local_mode 2 "$MERGED" "$LOCAL"
checkout_stage $remote_mode 3 "$MERGED" "$REMOTE"Or even:
checkout_stage ()
{
tmpfile=$(...)
if test $? -eq 0 -a ...
then
mv -- "$(git rev-parse ...)"
else
>"$3"
fi
}
checkout_stage 1 "$MERGED" "$BASE"
checkout_stage 2 "$MERGED" "$LOCAL"
checkout_stage 3 "$MERGED" "$REMOTE"as the current checkout_staged_file() does not seem to check errors in any meaningful way.
PATCH v3 1/1 mergetool: Provide an empty file when needed
Some merge tools cannot cope when $LOCAL, $BASE, or $REMOTE are missing. $BASE can be missing when two branches independently add the same filename. $LOCAL and $REMOTE can be missing when a delete/modify conflict occurs.
Provide an empty file to make these tools happy.
---
We now create the empty file in checkout_staged_file() as part of the error checking section.
git-mergetool.sh | 8 +++++--- t/t7610-mergetool.sh | 27 ++++++++++++++++++++++++++- 2 files changed, 31 insertions(+), 4 deletions(-)
git-mergetool.sh +5 -3
@@ -185,6 +185,8 @@ checkout_staged_file () { if test $? -eq 0 -a -n "$tmpfile" ; then mv -- "$(git rev-parse --show-cdup)$tmpfile" "$3" + else + >"$3" fi }
@@ -224,9 +226,9 @@ merge_file () { mv -- "$MERGED" "$BACKUP" cp -- "$BACKUP" "$MERGED" - base_present && checkout_staged_file 1 "$MERGED" "$BASE" - local_present && checkout_staged_file 2 "$MERGED" "$LOCAL" - remote_present && checkout_staged_file 3 "$MERGED" "$REMOTE" + checkout_staged_file 1 "$MERGED" "$BASE" + checkout_staged_file 2 "$MERGED" "$LOCAL" + checkout_staged_file 3 "$MERGED" "$REMOTE" if test -z "$local_mode" -o -z "$remote_mode"; then echo "Deleted merge conflict for '$MERGED':"
t/t7610-mergetool.sh +26 -1
@@ -39,6 +39,7 @@ test_expect_success 'setup' ' echo branch1 change >file1 && echo branch1 newfile >file2 && echo branch1 spaced >"spaced name" && + echo branch1 both added > both && echo branch1 change file11 >file11 && echo branch1 change file13 >file13 && echo branch1 sub >subdir/file3 &&
@@ -50,6 +51,7 @@ test_expect_success 'setup' ' git checkout -b submod-branch1 ) && git add file1 "spaced name" file11 file13 file2 subdir/file3 submod && + git add both && git rm file12 && git commit -m "branch1 changes" &&
@@ -58,6 +60,7 @@ test_expect_success 'setup' ' echo master updated >file1 && echo master new >file2 && echo master updated spaced >"spaced name" && + echo master both added > both && echo master updated file12 >file12 && echo master updated file14 >file14 && echo master new sub >subdir/file3 &&
@@ -69,18 +72,22 @@ test_expect_success 'setup' ' git checkout -b submod-master ) && git add file1 "spaced name" file12 file14 file2 subdir/file3 submod && + git add both && git rm file11 && git commit -m "master updates" && git config merge.tool mytool && git config mergetool.mytool.cmd "cat \"\$REMOTE\" >\"\$MERGED\"" && - git config mergetool.mytool.trustExitCode true + git config mergetool.mytool.trustExitCode true && + git config mergetool.mybase.cmd "cat \"\$BASE\" >\"\$MERGED\"" && + git config mergetool.mybase.trustExitCode true ' test_expect_success 'custom mergetool' ' git checkout -b test1 branch1 && git submodule update -N && test_must_fail git merge master >/dev/null 2>&1 && + ( yes "" | git mergetool both >/dev/null 2>&1 ) && ( yes "" | git mergetool file1 file1 ) && ( yes "" | git mergetool file2 "spaced name" >/dev/null 2>&1 ) && ( yes "" | git mergetool subdir/file3 >/dev/null 2>&1 ) &&
@@ -101,6 +108,7 @@ test_expect_success 'mergetool crlf' ' ( yes "" | git mergetool file1 >/dev/null 2>&1 ) && ( yes "" | git mergetool file2 >/dev/null 2>&1 ) && ( yes "" | git mergetool "spaced name" >/dev/null 2>&1 ) && + ( yes "" | git mergetool both >/dev/null 2>&1 ) && ( yes "" | git mergetool subdir/file3 >/dev/null 2>&1 ) && ( yes "d" | git mergetool file11 >/dev/null 2>&1 ) && ( yes "d" | git mergetool file12 >/dev/null 2>&1 ) &&
@@ -131,6 +139,7 @@ test_expect_success 'mergetool on file in parent dir' ' cd subdir && ( yes "" | git mergetool ../file1 >/dev/null 2>&1 ) && ( yes "" | git mergetool ../file2 ../spaced\ name >/dev/null 2>&1 ) && + ( yes "" | git mergetool ../both >/dev/null 2>&1 ) && ( yes "d" | git mergetool ../file11 >/dev/null 2>&1 ) && ( yes "d" | git mergetool ../file12 >/dev/null 2>&1 ) && ( yes "l" | git mergetool ../submod >/dev/null 2>&1 ) &&
@@ -212,6 +221,7 @@ test_expect_success 'deleted vs modified submodule' ' test_must_fail git merge master && test -n "$(git ls-files -u)" && ( yes "" | git mergetool file1 file2 spaced\ name subdir/file3 >/dev/null 2>&1 ) && + ( yes "" | git mergetool both >/dev/null 2>&1 ) && ( yes "d" | git mergetool file11 file12 >/dev/null 2>&1 ) && ( yes "r" | git mergetool submod ) && rmdir submod && mv submod-movedaside submod &&
@@ -228,6 +238,7 @@ test_expect_success 'deleted vs modified submodule' ' test_must_fail git merge master && test -n "$(git ls-files -u)" && ( yes "" | git mergetool file1 file2 spaced\ name subdir/file3 >/dev/null 2>&1 ) && + ( yes "" | git mergetool both >/dev/null 2>&1 ) && ( yes "d" | git mergetool file11 file12 >/dev/null 2>&1 ) && ( yes "l" | git mergetool submod ) && test ! -e submod &&
@@ -241,6 +252,7 @@ test_expect_success 'deleted vs modified submodule' ' test_must_fail git merge test6 && test -n "$(git ls-files -u)" && ( yes "" | git mergetool file1 file2 spaced\ name subdir/file3 >/dev/null 2>&1 ) && + ( yes "" | git mergetool both >/dev/null 2>&1 ) && ( yes "d" | git mergetool file11 file12 >/dev/null 2>&1 ) && ( yes "r" | git mergetool submod ) && test ! -e submod &&
@@ -256,6 +268,7 @@ test_expect_success 'deleted vs modified submodule' ' test_must_fail git merge test6 && test -n "$(git ls-files -u)" && ( yes "" | git mergetool file1 file2 spaced\ name subdir/file3 >/dev/null 2>&1 ) && + ( yes "" | git mergetool both >/dev/null 2>&1 ) && ( yes "d" | git mergetool file11 file12 >/dev/null 2>&1 ) && ( yes "l" | git mergetool submod ) && test "$(cat submod/bar)" = "master submodule" &&
@@ -279,6 +292,7 @@ test_expect_success 'file vs modified submodule' ' test_must_fail git merge master && test -n "$(git ls-files -u)" && ( yes "" | git mergetool file1 file2 spaced\ name subdir/file3 >/dev/null 2>&1 ) && + ( yes "" | git mergetool both >/dev/null 2>&1 ) && ( yes "d" | git mergetool file11 file12 >/dev/null 2>&1 ) && ( yes "r" | git mergetool submod ) && rmdir submod && mv submod-movedaside submod &&
@@ -294,6 +308,7 @@ test_expect_success 'file vs modified submodule' ' test_must_fail git merge master && test -n "$(git ls-files -u)" && ( yes "" | git mergetool file1 file2 spaced\ name subdir/file3 >/dev/null 2>&1 ) && + ( yes "" | git mergetool both >/dev/null 2>&1 ) && ( yes "d" | git mergetool file11 file12 >/dev/null 2>&1 ) && ( yes "l" | git mergetool submod ) && git submodule update -N &&
@@ -309,6 +324,7 @@ test_expect_success 'file vs modified submodule' ' test_must_fail git merge test7 && test -n "$(git ls-files -u)" && ( yes "" | git mergetool file1 file2 spaced\ name subdir/file3 >/dev/null 2>&1 ) && + ( yes "" | git mergetool both >/dev/null 2>&1 ) && ( yes "d" | git mergetool file11 file12 >/dev/null 2>&1 ) && ( yes "r" | git mergetool submod ) && test -d submod.orig &&
@@ -324,6 +340,7 @@ test_expect_success 'file vs modified submodule' ' test_must_fail git merge test7 && test -n "$(git ls-files -u)" && ( yes "" | git mergetool file1 file2 spaced\ name subdir/file3 >/dev/null 2>&1 ) && + ( yes "" | git mergetool both>/dev/null 2>&1 ) && ( yes "d" | git mergetool file11 file12 >/dev/null 2>&1 ) && ( yes "l" | git mergetool submod ) && test "$(cat submod/bar)" = "master submodule" &&
@@ -445,4 +462,12 @@ test_expect_success 'directory vs modified submodule' ' git submodule update -N ' +test_expect_success 'file with no base' ' + git checkout -b test13 branch1 && + test_must_fail git merge master && + git mergetool --no-prompt --tool mybase -- base && + test "$(cat "$MERGED")" = "" && + git reset --hard master >/dev/null 2>&1 +' + test_done
Signature · 1 line
1.7.9.rc2.1.g36b4c
Re: [PATCH v3] mergetool: Provide an empty file when needed
Quoted 9 lines · David Aguilar
Some merge tools cannot cope when $LOCAL, $BASE, or $REMOTE are missing. $BASE can be missing when two branches independently add the same filename. $LOCAL and $REMOTE can be missing when a delete/modify conflict occurs.
Provide an empty file to make these tools happy.
Reported-by Jason Wenger <[email protected]>Signed-off-by David Aguilar <[email protected]>
Quoted 7 lines
---
We now create the empty file incheckout_staged_file()as part of the error checking section.git-mergetool.sh | 8 +++++---
t/t7610-mergetool.sh| 27 ++++++++++++++++++++++++++-2 files changed, 31 insertions(+), 4 deletions(-)
I certainly like this version the best. This diff is smaller and it's all handled in one place. It should've been marked PATCH v4 ;-)
Thanks for the review.
Quoted 174 lines
git-mergetool.sh +0
-0@@ -185,6 +185,8 @@ checkout_staged_file () {if test $? -eq 0 -a -n "$tmpfile" ; then
mv -- "$(git rev-parse --show-cdup)$tmpfile" "$3"
+ else
+ >"$3"
fi
}git-mergetool.sh +0
-0@@ -224,9 +226,9 @@ merge_file () {mv -- "$MERGED" "$BACKUP"
cp -- "$BACKUP" "$MERGED"- base_present &&
checkout_staged_file1 "$MERGED" "$BASE"
- local_present &&checkout_staged_file2 "$MERGED" "$LOCAL"
- remote_present &&checkout_staged_file3 "$MERGED" "$REMOTE"
+ checkout_staged_file 1 "$MERGED" "$BASE"
+ checkout_staged_file 2 "$MERGED" "$LOCAL"
+ checkout_staged_file 3 "$MERGED" "$REMOTE"if test -z "$local_mode" -o -z "$remote_mode"; then echo "Deleted merge conflict for '$MERGED':"
t/t7610-mergetool.sh +0
-0@@ -39,6 +39,7 @@ test_expect_success 'setup' 'echo branch1 change >file1 &&
echo branch1 newfile >file2 &&
echo branch1 spaced >"spaced name" &&
+ echo branch1 both added > both &&
echo branch1 change file11 >file11 &&
echo branch1 change file13 >file13 &&
echo branch1 sub >subdir/file3 &&t/t7610-mergetool.sh +0
-0@@ -50,6 +51,7 @@ test_expect_success 'setup' 'git checkout -b submod-branch1
) &&
git add file1 "spaced name" file11 file13 file2 subdir/file3 submod &&
+ git add both &&
git rm file12 &&
git commit -m "branch1 changes" &&t/t7610-mergetool.sh +0
-0@@ -58,6 +60,7 @@ test_expect_success 'setup' 'echo master updated >file1 &&
echo master new >file2 &&
echo master updated spaced >"spaced name" &&
+ echo master both added > both &&
echo master updated file12 >file12 &&
echo master updated file14 >file14 &&
echo master new sub >subdir/file3 &&t/t7610-mergetool.sh +0
-0@@ -69,18 +72,22 @@ test_expect_success 'setup' 'git checkout -b submod-master
) &&
git add file1 "spaced name" file12 file14 file2 subdir/file3 submod &&
+ git add both &&
git rm file11 &&
git commit -m "master updates" &&git config merge.tool mytool &&
git config mergetool.mytool.cmd "cat \"\$REMOTE\" >\"\$MERGED\"" &&
- git config mergetool.mytool.trustExitCode true
+ git config mergetool.mytool.trustExitCode true &&
+ git config mergetool.mybase.cmd "cat \"\$BASE\" >\"\$MERGED\"" &&
+ git config mergetool.mybase.trustExitCode true
'test_expect_success 'custom mergetool' '
git checkout -b test1 branch1 &&
git submodule update -N &&
test_must_failgit merge master >/dev/null 2>&1 &&
+ ( yes "" | git mergetool both >/dev/null 2>&1 ) &&( yes "" | git mergetool file1 file1 ) && ( yes "" | git mergetool file2 "spaced name" >/dev/null 2>&1 ) && ( yes "" | git mergetool subdir/file3 >/dev/null 2>&1 ) &&t/t7610-mergetool.sh +0
-0@@ -101,6 +108,7 @@ test_expect_success 'mergetool crlf' '( yes "" | git mergetool file1 >/dev/null 2>&1 ) && ( yes "" | git mergetool file2 >/dev/null 2>&1 ) && ( yes "" | git mergetool "spaced name" >/dev/null 2>&1 ) &&+ ( yes "" | git mergetool both >/dev/null 2>&1 ) && ( yes "" | git mergetool subdir/file3 >/dev/null 2>&1 ) && ( yes "d" | git mergetool file11 >/dev/null 2>&1 ) && ( yes "d" | git mergetool file12 >/dev/null 2>&1 ) &&
t/t7610-mergetool.sh +0
-0@@ -131,6 +139,7 @@ test_expect_success 'mergetool on file in parent dir' 'cd subdir &&
( yes "" | git mergetool ../file1 >/dev/null 2>&1 ) && ( yes "" | git mergetool ../file2 ../spaced\ name >/dev/null 2>&1 ) && + ( yes "" | git mergetool ../both >/dev/null 2>&1 ) && ( yes "d" | git mergetool ../file11 >/dev/null 2>&1 ) && ( yes "d" | git mergetool ../file12 >/dev/null 2>&1 ) && ( yes "l" | git mergetool ../submod >/dev/null 2>&1 ) &&t/t7610-mergetool.sh +0
-0@@ -212,6 +221,7 @@ test_expect_success 'deleted vs modified submodule' '
test_must_failgit merge master &&
test -n "$(git ls-files -u)" &&
( yes "" | git mergetool file1 file2 spaced\ name subdir/file3 >/dev/null 2>&1 ) &&+ ( yes "" | git mergetool both >/dev/null 2>&1 ) && ( yes "d" | git mergetool file11 file12 >/dev/null 2>&1 ) && ( yes "r" | git mergetool submod ) &&rmdir submod && mv submod-movedaside submod &&
t/t7610-mergetool.sh +0
-0@@ -228,6 +238,7 @@ test_expect_success 'deleted vs modified submodule' '
test_must_failgit merge master &&
test -n "$(git ls-files -u)" &&
( yes "" | git mergetool file1 file2 spaced\ name subdir/file3 >/dev/null 2>&1 ) &&+ ( yes "" | git mergetool both >/dev/null 2>&1 ) && ( yes "d" | git mergetool file11 file12 >/dev/null 2>&1 ) && ( yes "l" | git mergetool submod ) &&test ! -e submod &&
t/t7610-mergetool.sh +0
-0@@ -241,6 +252,7 @@ test_expect_success 'deleted vs modified submodule' '
test_must_failgit merge test6 &&
test -n "$(git ls-files -u)" &&
( yes "" | git mergetool file1 file2 spaced\ name subdir/file3 >/dev/null 2>&1 ) &&+ ( yes "" | git mergetool both >/dev/null 2>&1 ) && ( yes "d" | git mergetool file11 file12 >/dev/null 2>&1 ) && ( yes "r" | git mergetool submod ) &&test ! -e submod &&
t/t7610-mergetool.sh +0
-0@@ -256,6 +268,7 @@ test_expect_success 'deleted vs modified submodule' '
test_must_failgit merge test6 &&
test -n "$(git ls-files -u)" &&
( yes "" | git mergetool file1 file2 spaced\ name subdir/file3 >/dev/null 2>&1 ) &&+ ( yes "" | git mergetool both >/dev/null 2>&1 ) && ( yes "d" | git mergetool file11 file12 >/dev/null 2>&1 ) && ( yes "l" | git mergetool submod ) &&test "$(cat submod/bar)" = "master submodule" &&
t/t7610-mergetool.sh +0
-0@@ -279,6 +292,7 @@ test_expect_success 'file vs modified submodule' '
test_must_failgit merge master &&
test -n "$(git ls-files -u)" &&
( yes "" | git mergetool file1 file2 spaced\ name subdir/file3 >/dev/null 2>&1 ) &&+ ( yes "" | git mergetool both >/dev/null 2>&1 ) && ( yes "d" | git mergetool file11 file12 >/dev/null 2>&1 ) && ( yes "r" | git mergetool submod ) &&rmdir submod && mv submod-movedaside submod &&
t/t7610-mergetool.sh +0
-0@@ -294,6 +308,7 @@ test_expect_success 'file vs modified submodule' '
test_must_failgit merge master &&
test -n "$(git ls-files -u)" &&
( yes "" | git mergetool file1 file2 spaced\ name subdir/file3 >/dev/null 2>&1 ) &&+ ( yes "" | git mergetool both >/dev/null 2>&1 ) && ( yes "d" | git mergetool file11 file12 >/dev/null 2>&1 ) && ( yes "l" | git mergetool submod ) &&git submodule update -N &&
t/t7610-mergetool.sh +0
-0@@ -309,6 +324,7 @@ test_expect_success 'file vs modified submodule' '
test_must_failgit merge test7 &&
test -n "$(git ls-files -u)" &&
( yes "" | git mergetool file1 file2 spaced\ name subdir/file3 >/dev/null 2>&1 ) &&+ ( yes "" | git mergetool both >/dev/null 2>&1 ) && ( yes "d" | git mergetool file11 file12 >/dev/null 2>&1 ) && ( yes "r" | git mergetool submod ) &&test -d submod.orig &&
t/t7610-mergetool.sh +0
-0@@ -324,6 +340,7 @@ test_expect_success 'file vs modified submodule' '
test_must_failgit merge test7 &&
test -n "$(git ls-files -u)" &&
( yes "" | git mergetool file1 file2 spaced\ name subdir/file3 >/dev/null 2>&1 ) &&+ ( yes "" | git mergetool both>/dev/null 2>&1 ) && ( yes "d" | git mergetool file11 file12 >/dev/null 2>&1 ) && ( yes "l" | git mergetool submod ) &&test "$(cat submod/bar)" = "master submodule" &&
t/t7610-mergetool.sh +0
-0@@ -445,4 +462,12 @@ test_expect_success 'directory vs modified submodule' 'git submodule update -N
't/t7610-mergetool.sh +8
-0+test_expect_success 'file with no base' ' + git checkout -b test13 branch1 && + test_must_fail git merge master && + git mergetool --no-prompt --tool mybase -- base && + test "$(cat "$MERGED")" = "" && + git reset --hard master >/dev/null 2>&1 +' +test_done
--
1.7.9.rc2.1.g36b4c
Signature · 1 line
David
Re: [PATCH v3] mergetool: Provide an empty file when needed
Quoted 7 lines · David Aguilar
Quoted 6 lines · David Aguilar
Some merge tools cannot cope when $LOCAL, $BASE, or $REMOTE are missing. $BASE can be missing when two branches independently add the same filename. $LOCAL and $REMOTE can be missing when a delete/modify conflict occurs.
Provide an empty file to make these tools happy.
This is cleaner, yes -- but is this extra processing on $LOCAL and $REMOTE necessary? Git mergetool doesn't actually call an external mergetool during del/mod conflicts -- instead it goes into an alternate processing and prompts the user interactively whether to take the deleted or modified file. Can these changes be reached? (command line option I'm not aware of?)
--jcw
Re: [PATCH v3] mergetool: Provide an empty file when needed
Quoted 7 lines · Jason Wenger
Quoted 6 lines · David Aguilar
Quoted 5 lines · David Aguilar
Some merge tools cannot cope when $LOCAL, $BASE, or $REMOTE are missing. $BASE can be missing when two branches independently add the same filename. $LOCAL and $REMOTE can be missing when a delete/modify conflict occurs.
Quoted 8 lines
Quoted 1 line
Quoted 1 line
Provide an empty file to make these tools happy.
This is cleaner, yes -- but is this extra processing on $LOCAL and $REMOTE necessary? Git mergetool doesn't actually call an external mergetool during del/mod conflicts -- instead it goes into an alternate processing and prompts the user interactively whether to take the deleted or modified file. Can these changes be reached? (command line option I'm not aware of?)
Thanks for a careful reading. I did not read outside the context of the patch so I didn't know if we had special cases for del/mod.
A bigger question is if the del/mod codepaths are negatively affected by the presense of these superfluous empty $LOCAL/$REMOTE files. If they are, this change will _break_ things. If they are not, I think the change would be OK.
Another small worry is that this could potentially negatively affect some merge tools that are sufficiently clueful, if it can give different and better results for a true two-way-merge than a simulated two-way-merge this patch feeds them by using a three-way-merge with an empty file as a base.
Re: [PATCH] mergetool: Provide an empty file when no base exists
In reply to Junio C HamanoJunio C Hamano <[email protected]> writes:
Yuck, sorry for sending out a edit-in-progress copy.
Quoted 3 lines
It almost makes me wonder if the obviously simplest change to make
checkout_staged_filecreate an empty file when the asked-for stage does not exist, i.e.
It should read
It almost makes me wonder if the obviously simplest change to make checkout_staged_file create an empty file when the asked-for stage does not exist is good enough, i.e.
PATCH v2 1/1 mergetool: Provide an empty file when no base exists
In reply to Junio C HamanoSome mergetools cannot cope when $BASE is missing,
for example when two branches independently add the same filename. Provide an empty file to make these tools happy.
---
Fixed commit message too.
git-mergetool.sh | 6 +++++- t/t7610-mergetool.sh | 27 ++++++++++++++++++++++++++- 2 files changed, 31 insertions(+), 2 deletions(-)
git-mergetool.sh +5 -1
@@ -224,7 +224,11 @@ merge_file () { mv -- "$MERGED" "$BACKUP" cp -- "$BACKUP" "$MERGED" - base_present && checkout_staged_file 1 "$MERGED" "$BASE" + if base_present; then + checkout_staged_file 1 "$MERGED" "$BASE" + else + :>"$BASE" + fi local_present && checkout_staged_file 2 "$MERGED" "$LOCAL" remote_present && checkout_staged_file 3 "$MERGED" "$REMOTE"
t/t7610-mergetool.sh +26 -1
@@ -39,6 +39,7 @@ test_expect_success 'setup' ' echo branch1 change >file1 && echo branch1 newfile >file2 && echo branch1 spaced >"spaced name" && + echo branch1 both added > both && echo branch1 change file11 >file11 && echo branch1 change file13 >file13 && echo branch1 sub >subdir/file3 &&
@@ -50,6 +51,7 @@ test_expect_success 'setup' ' git checkout -b submod-branch1 ) && git add file1 "spaced name" file11 file13 file2 subdir/file3 submod && + git add both && git rm file12 && git commit -m "branch1 changes" &&
@@ -58,6 +60,7 @@ test_expect_success 'setup' ' echo master updated >file1 && echo master new >file2 && echo master updated spaced >"spaced name" && + echo master both added > both && echo master updated file12 >file12 && echo master updated file14 >file14 && echo master new sub >subdir/file3 &&
@@ -69,18 +72,22 @@ test_expect_success 'setup' ' git checkout -b submod-master ) && git add file1 "spaced name" file12 file14 file2 subdir/file3 submod && + git add both && git rm file11 && git commit -m "master updates" && git config merge.tool mytool && git config mergetool.mytool.cmd "cat \"\$REMOTE\" >\"\$MERGED\"" && - git config mergetool.mytool.trustExitCode true + git config mergetool.mytool.trustExitCode true && + git config mergetool.mybase.cmd "cat \"\$BASE\" >\"\$MERGED\"" && + git config mergetool.mybase.trustExitCode true ' test_expect_success 'custom mergetool' ' git checkout -b test1 branch1 && git submodule update -N && test_must_fail git merge master >/dev/null 2>&1 && + ( yes "" | git mergetool both >/dev/null 2>&1 ) && ( yes "" | git mergetool file1 file1 ) && ( yes "" | git mergetool file2 "spaced name" >/dev/null 2>&1 ) && ( yes "" | git mergetool subdir/file3 >/dev/null 2>&1 ) &&
@@ -101,6 +108,7 @@ test_expect_success 'mergetool crlf' ' ( yes "" | git mergetool file1 >/dev/null 2>&1 ) && ( yes "" | git mergetool file2 >/dev/null 2>&1 ) && ( yes "" | git mergetool "spaced name" >/dev/null 2>&1 ) && + ( yes "" | git mergetool both >/dev/null 2>&1 ) && ( yes "" | git mergetool subdir/file3 >/dev/null 2>&1 ) && ( yes "d" | git mergetool file11 >/dev/null 2>&1 ) && ( yes "d" | git mergetool file12 >/dev/null 2>&1 ) &&
@@ -131,6 +139,7 @@ test_expect_success 'mergetool on file in parent dir' ' cd subdir && ( yes "" | git mergetool ../file1 >/dev/null 2>&1 ) && ( yes "" | git mergetool ../file2 ../spaced\ name >/dev/null 2>&1 ) && + ( yes "" | git mergetool ../both >/dev/null 2>&1 ) && ( yes "d" | git mergetool ../file11 >/dev/null 2>&1 ) && ( yes "d" | git mergetool ../file12 >/dev/null 2>&1 ) && ( yes "l" | git mergetool ../submod >/dev/null 2>&1 ) &&
@@ -212,6 +221,7 @@ test_expect_success 'deleted vs modified submodule' ' test_must_fail git merge master && test -n "$(git ls-files -u)" && ( yes "" | git mergetool file1 file2 spaced\ name subdir/file3 >/dev/null 2>&1 ) && + ( yes "" | git mergetool both >/dev/null 2>&1 ) && ( yes "d" | git mergetool file11 file12 >/dev/null 2>&1 ) && ( yes "r" | git mergetool submod ) && rmdir submod && mv submod-movedaside submod &&
@@ -228,6 +238,7 @@ test_expect_success 'deleted vs modified submodule' ' test_must_fail git merge master && test -n "$(git ls-files -u)" && ( yes "" | git mergetool file1 file2 spaced\ name subdir/file3 >/dev/null 2>&1 ) && + ( yes "" | git mergetool both >/dev/null 2>&1 ) && ( yes "d" | git mergetool file11 file12 >/dev/null 2>&1 ) && ( yes "l" | git mergetool submod ) && test ! -e submod &&
@@ -241,6 +252,7 @@ test_expect_success 'deleted vs modified submodule' ' test_must_fail git merge test6 && test -n "$(git ls-files -u)" && ( yes "" | git mergetool file1 file2 spaced\ name subdir/file3 >/dev/null 2>&1 ) && + ( yes "" | git mergetool both >/dev/null 2>&1 ) && ( yes "d" | git mergetool file11 file12 >/dev/null 2>&1 ) && ( yes "r" | git mergetool submod ) && test ! -e submod &&
@@ -256,6 +268,7 @@ test_expect_success 'deleted vs modified submodule' ' test_must_fail git merge test6 && test -n "$(git ls-files -u)" && ( yes "" | git mergetool file1 file2 spaced\ name subdir/file3 >/dev/null 2>&1 ) && + ( yes "" | git mergetool both >/dev/null 2>&1 ) && ( yes "d" | git mergetool file11 file12 >/dev/null 2>&1 ) && ( yes "l" | git mergetool submod ) && test "$(cat submod/bar)" = "master submodule" &&
@@ -279,6 +292,7 @@ test_expect_success 'file vs modified submodule' ' test_must_fail git merge master && test -n "$(git ls-files -u)" && ( yes "" | git mergetool file1 file2 spaced\ name subdir/file3 >/dev/null 2>&1 ) && + ( yes "" | git mergetool both >/dev/null 2>&1 ) && ( yes "d" | git mergetool file11 file12 >/dev/null 2>&1 ) && ( yes "r" | git mergetool submod ) && rmdir submod && mv submod-movedaside submod &&
@@ -294,6 +308,7 @@ test_expect_success 'file vs modified submodule' ' test_must_fail git merge master && test -n "$(git ls-files -u)" && ( yes "" | git mergetool file1 file2 spaced\ name subdir/file3 >/dev/null 2>&1 ) && + ( yes "" | git mergetool both >/dev/null 2>&1 ) && ( yes "d" | git mergetool file11 file12 >/dev/null 2>&1 ) && ( yes "l" | git mergetool submod ) && git submodule update -N &&
@@ -309,6 +324,7 @@ test_expect_success 'file vs modified submodule' ' test_must_fail git merge test7 && test -n "$(git ls-files -u)" && ( yes "" | git mergetool file1 file2 spaced\ name subdir/file3 >/dev/null 2>&1 ) && + ( yes "" | git mergetool both >/dev/null 2>&1 ) && ( yes "d" | git mergetool file11 file12 >/dev/null 2>&1 ) && ( yes "r" | git mergetool submod ) && test -d submod.orig &&
@@ -324,6 +340,7 @@ test_expect_success 'file vs modified submodule' ' test_must_fail git merge test7 && test -n "$(git ls-files -u)" && ( yes "" | git mergetool file1 file2 spaced\ name subdir/file3 >/dev/null 2>&1 ) && + ( yes "" | git mergetool both>/dev/null 2>&1 ) && ( yes "d" | git mergetool file11 file12 >/dev/null 2>&1 ) && ( yes "l" | git mergetool submod ) && test "$(cat submod/bar)" = "master submodule" &&
@@ -445,4 +462,12 @@ test_expect_success 'directory vs modified submodule' ' git submodule update -N ' +test_expect_success 'file with no base' ' + git checkout -b test13 branch1 && + test_must_fail git merge master && + git mergetool --no-prompt --tool mybase -- base && + test "$(cat "$MERGED")" = "" && + git reset --hard master >/dev/null 2>&1 +' + test_done
Signature · 1 line
1.7.9.rc2.1.gdcba7
Re: [PATCH] mergetool: Provide an empty file when no base exists
In reply to Junio C HamanoQuoted 36 lines · Junio C Hamano
Quoted 19 lines · David Aguilar
Some mergetools cannot cope when $BASE is missing. This can happen when two branches add the same file. Provide an empty file to make these tools happy.
Reported-by Jason Wenger <[email protected]>Signed-off-by David Aguilar <[email protected]>---
git-mergetool.sh | 6 +++++-t/t7610-mergetool.sh| 27 ++++++++++++++++++++++++++-2 files changed, 31 insertions(+), 2 deletions(-)git-mergetool.sh +0
-0@@ -224,7 +224,11 @@ merge_file () {mv -- "$MERGED" "$BACKUP"
cp -- "$BACKUP" "$MERGED"Quoted 6 lines
- base_present &&
checkout_staged_file1 "$MERGED" "$BASE"
+ ifbase_present; then
+checkout_staged_file1 "$MERGED" "$BASE"
+ else
+ touch "$BASE"
+ fiUsing "touch" for things like this is a disease.
You not just want to make sure it exists, but also you want to make sure it is empty, so it would make your intention more explicit and clear if you wrote this as
>"$BASE"
Quoted 8 lines
instead.
I also wonder if it may help mergetools if we come up with a fake base image using the common material between the two files, in a way similar to how
git-merge-one-file.shdoes it (look for "Added $4 in both, but differently"), but obviously it would belong to a separate patch.Thanks.
Ah, thanks for the pointer. I'll resend shortly. A "fake base" would be very helpful.
Signature · 1 line
David
Re: [PATCH] mergetool: Provide an empty file when no base exists
In reply to David Aguilar[apologies for forgetting to cc: you on the patch Jason]
Quoted 2 lines · David Aguilar
Some mergetools cannot cope when $BASE is missing. This can happen when two branches add the same file.
This might be better worded as "when two branches independently add the same filename".
Feel free to squash... or I'll resend if you prefer.
Let me know if this does the trick for you, Jason. The test case is happy; I hope your mergetool is as well.
Cheers,
David
Quoted 174 lines
Provide an empty file to make these tools happy.
Reported-by Jason Wenger <[email protected]>Signed-off-by David Aguilar <[email protected]>---
git-mergetool.sh | 6 +++++-t/t7610-mergetool.sh| 27 ++++++++++++++++++++++++++-2 files changed, 31 insertions(+), 2 deletions(-)git-mergetool.sh +0
-0@@ -224,7 +224,11 @@ merge_file () {mv -- "$MERGED" "$BACKUP"
cp -- "$BACKUP" "$MERGED"- base_present &&
checkout_staged_file1 "$MERGED" "$BASE"
+ ifbase_present; then
+checkout_staged_file1 "$MERGED" "$BASE"
+ else
+ touch "$BASE"
+ fi
local_present&&checkout_staged_file2 "$MERGED" "$LOCAL"remote_present&&checkout_staged_file3 "$MERGED" "$REMOTE"t/t7610-mergetool.sh +0
-0@@ -39,6 +39,7 @@ test_expect_success 'setup' 'echo branch1 change >file1 &&
echo branch1 newfile >file2 &&
echo branch1 spaced >"spaced name" &&
+ echo branch1 both added > both &&
echo branch1 change file11 >file11 &&
echo branch1 change file13 >file13 &&
echo branch1 sub >subdir/file3 &&t/t7610-mergetool.sh +0
-0@@ -50,6 +51,7 @@ test_expect_success 'setup' 'git checkout -b submod-branch1
) &&
git add file1 "spaced name" file11 file13 file2 subdir/file3 submod &&
+ git add both &&
git rm file12 &&
git commit -m "branch1 changes" &&t/t7610-mergetool.sh +0
-0@@ -58,6 +60,7 @@ test_expect_success 'setup' 'echo master updated >file1 &&
echo master new >file2 &&
echo master updated spaced >"spaced name" &&
+ echo master both added > both &&
echo master updated file12 >file12 &&
echo master updated file14 >file14 &&
echo master new sub >subdir/file3 &&t/t7610-mergetool.sh +0
-0@@ -69,18 +72,22 @@ test_expect_success 'setup' 'git checkout -b submod-master
) &&
git add file1 "spaced name" file12 file14 file2 subdir/file3 submod &&
+ git add both &&
git rm file11 &&
git commit -m "master updates" &&git config merge.tool mytool &&
git config mergetool.mytool.cmd "cat \"\$REMOTE\" >\"\$MERGED\"" &&
- git config mergetool.mytool.trustExitCode true
+ git config mergetool.mytool.trustExitCode true &&
+ git config mergetool.mybase.cmd "cat \"\$BASE\" >\"\$MERGED\"" &&
+ git config mergetool.mybase.trustExitCode true
'test_expect_success 'custom mergetool' '
git checkout -b test1 branch1 &&
git submodule update -N &&
test_must_failgit merge master >/dev/null 2>&1 &&
+ ( yes "" | git mergetool both >/dev/null 2>&1 ) &&( yes "" | git mergetool file1 file1 ) && ( yes "" | git mergetool file2 "spaced name" >/dev/null 2>&1 ) && ( yes "" | git mergetool subdir/file3 >/dev/null 2>&1 ) &&t/t7610-mergetool.sh +0
-0@@ -101,6 +108,7 @@ test_expect_success 'mergetool crlf' '( yes "" | git mergetool file1 >/dev/null 2>&1 ) && ( yes "" | git mergetool file2 >/dev/null 2>&1 ) && ( yes "" | git mergetool "spaced name" >/dev/null 2>&1 ) &&+ ( yes "" | git mergetool both >/dev/null 2>&1 ) && ( yes "" | git mergetool subdir/file3 >/dev/null 2>&1 ) && ( yes "d" | git mergetool file11 >/dev/null 2>&1 ) && ( yes "d" | git mergetool file12 >/dev/null 2>&1 ) &&
t/t7610-mergetool.sh +0
-0@@ -131,6 +139,7 @@ test_expect_success 'mergetool on file in parent dir' 'cd subdir &&
( yes "" | git mergetool ../file1 >/dev/null 2>&1 ) && ( yes "" | git mergetool ../file2 ../spaced\ name >/dev/null 2>&1 ) && + ( yes "" | git mergetool ../both >/dev/null 2>&1 ) && ( yes "d" | git mergetool ../file11 >/dev/null 2>&1 ) && ( yes "d" | git mergetool ../file12 >/dev/null 2>&1 ) && ( yes "l" | git mergetool ../submod >/dev/null 2>&1 ) &&t/t7610-mergetool.sh +0
-0@@ -212,6 +221,7 @@ test_expect_success 'deleted vs modified submodule' '
test_must_failgit merge master &&
test -n "$(git ls-files -u)" &&
( yes "" | git mergetool file1 file2 spaced\ name subdir/file3 >/dev/null 2>&1 ) &&+ ( yes "" | git mergetool both >/dev/null 2>&1 ) && ( yes "d" | git mergetool file11 file12 >/dev/null 2>&1 ) && ( yes "r" | git mergetool submod ) &&rmdir submod && mv submod-movedaside submod &&
t/t7610-mergetool.sh +0
-0@@ -228,6 +238,7 @@ test_expect_success 'deleted vs modified submodule' '
test_must_failgit merge master &&
test -n "$(git ls-files -u)" &&
( yes "" | git mergetool file1 file2 spaced\ name subdir/file3 >/dev/null 2>&1 ) &&+ ( yes "" | git mergetool both >/dev/null 2>&1 ) && ( yes "d" | git mergetool file11 file12 >/dev/null 2>&1 ) && ( yes "l" | git mergetool submod ) &&test ! -e submod &&
t/t7610-mergetool.sh +0
-0@@ -241,6 +252,7 @@ test_expect_success 'deleted vs modified submodule' '
test_must_failgit merge test6 &&
test -n "$(git ls-files -u)" &&
( yes "" | git mergetool file1 file2 spaced\ name subdir/file3 >/dev/null 2>&1 ) &&+ ( yes "" | git mergetool both >/dev/null 2>&1 ) && ( yes "d" | git mergetool file11 file12 >/dev/null 2>&1 ) && ( yes "r" | git mergetool submod ) &&test ! -e submod &&
t/t7610-mergetool.sh +0
-0@@ -256,6 +268,7 @@ test_expect_success 'deleted vs modified submodule' '
test_must_failgit merge test6 &&
test -n "$(git ls-files -u)" &&
( yes "" | git mergetool file1 file2 spaced\ name subdir/file3 >/dev/null 2>&1 ) &&+ ( yes "" | git mergetool both >/dev/null 2>&1 ) && ( yes "d" | git mergetool file11 file12 >/dev/null 2>&1 ) && ( yes "l" | git mergetool submod ) &&test "$(cat submod/bar)" = "master submodule" &&
t/t7610-mergetool.sh +0
-0@@ -279,6 +292,7 @@ test_expect_success 'file vs modified submodule' '
test_must_failgit merge master &&
test -n "$(git ls-files -u)" &&
( yes "" | git mergetool file1 file2 spaced\ name subdir/file3 >/dev/null 2>&1 ) &&+ ( yes "" | git mergetool both >/dev/null 2>&1 ) && ( yes "d" | git mergetool file11 file12 >/dev/null 2>&1 ) && ( yes "r" | git mergetool submod ) &&rmdir submod && mv submod-movedaside submod &&
t/t7610-mergetool.sh +0
-0@@ -294,6 +308,7 @@ test_expect_success 'file vs modified submodule' '
test_must_failgit merge master &&
test -n "$(git ls-files -u)" &&
( yes "" | git mergetool file1 file2 spaced\ name subdir/file3 >/dev/null 2>&1 ) &&+ ( yes "" | git mergetool both >/dev/null 2>&1 ) && ( yes "d" | git mergetool file11 file12 >/dev/null 2>&1 ) && ( yes "l" | git mergetool submod ) &&git submodule update -N &&
t/t7610-mergetool.sh +0
-0@@ -309,6 +324,7 @@ test_expect_success 'file vs modified submodule' '
test_must_failgit merge test7 &&
test -n "$(git ls-files -u)" &&
( yes "" | git mergetool file1 file2 spaced\ name subdir/file3 >/dev/null 2>&1 ) &&+ ( yes "" | git mergetool both >/dev/null 2>&1 ) && ( yes "d" | git mergetool file11 file12 >/dev/null 2>&1 ) && ( yes "r" | git mergetool submod ) &&test -d submod.orig &&
t/t7610-mergetool.sh +0
-0@@ -324,6 +340,7 @@ test_expect_success 'file vs modified submodule' '
test_must_failgit merge test7 &&
test -n "$(git ls-files -u)" &&
( yes "" | git mergetool file1 file2 spaced\ name subdir/file3 >/dev/null 2>&1 ) &&+ ( yes "" | git mergetool both>/dev/null 2>&1 ) && ( yes "d" | git mergetool file11 file12 >/dev/null 2>&1 ) && ( yes "l" | git mergetool submod ) &&test "$(cat submod/bar)" = "master submodule" &&
t/t7610-mergetool.sh +0
-0@@ -445,4 +462,12 @@ test_expect_success 'directory vs modified submodule' 'git submodule update -N
't/t7610-mergetool.sh +8
-0+test_expect_success 'file with no base' ' + git checkout -b test13 branch1 && + test_must_fail git merge master && + git mergetool --no-prompt --tool mybase -- base && + test "$(cat "$MERGED")" = "" && + git reset --hard master >/dev/null 2>&1 +' +test_done
--
1.7.9.rc2.1.gb566f