Thread (1 message) 1 message, 1 author, 2016-06-15

Re: [PATCH 2/2] mergetool: run prompt only if guessed tool

From: Junio C Hamano <hidden>
Date: 2016-06-15 23:00:47

David Aguilar [off-list ref] writes:
[Cc:ing Charles in case he has an opinion, this behavior dates back to the original MT]

On Sun, Apr 20, 2014 at 07:17:34PM -0500, Felipe Contreras wrote:
quoted
It's annoying to see the prompt:

  Hit return to start merge resolution tool (foo):

Every time the user does 'git mergetool' even if the user already
configured 'foo' as the wanted tool.

Display this prompt only when the user hasn't explicitly configured a
tool.
I agree this is probably helpful.
Most users I've met end up configuring mergetool.prompt=false.

Thanks
Do you have reaction to the other one "[PATCH 1/2] merge: enable
defaulttoupstream by default"?

As I do not think (note: I am not saying "I do not know" here) it is
sensible to do these "flip the default" in 2.0, I am hoping that we
can queue them (if the area maintainer, you, agree they are good
changes) to 'next' and cook them for the remainder of this cycle.
2.0 is a place where we execute the "flip the default" that we have
already disussed, designed and agreed since around 1.8.x timeframe,
and I would like to exclude any user visible change that just got
started being discussed to avoid unnecessary fallouts.

Thanks.
quoted
Signed-off-by: Felipe Contreras <redacted>
---
 git-mergetool.sh | 14 +++++++++++---
 1 file changed, 11 insertions(+), 3 deletions(-)
diff --git a/git-mergetool.sh b/git-mergetool.sh
index 332528f..d08dc92 100755
--- a/git-mergetool.sh
+++ b/git-mergetool.sh
@@ -277,7 +277,7 @@ merge_file () {
 	echo "Normal merge conflict for '$MERGED':"
 	describe_file "$local_mode" "local" "$LOCAL"
 	describe_file "$remote_mode" "remote" "$REMOTE"
-	if "$prompt" = true
+	if test "$guessed_merge_tool" = true || test "$prompt" = true
 	then
 		printf "Hit return to start merge resolution tool (%s): " "$merge_tool"
 		read ans || return 1
@@ -315,7 +315,8 @@ merge_file () {
 	return 0
 }
 
-prompt=$(git config --bool mergetool.prompt || echo true)
+prompt=$(git config --bool mergetool.prompt)
+guessed_merge_tool=false
 
 while test $# != 0
 do
@@ -373,7 +374,14 @@ prompt_after_failed_merge () {
 
 if test -z "$merge_tool"
 then
-	merge_tool=$(get_merge_tool "$merge_tool") || exit
+	# Check if a merge tool has been configured
+	merge_tool=$(get_configured_merge_tool)
+	# Try to guess an appropriate merge tool if no tool has been set.
+	if test -z "$merge_tool"
+	then
+		merge_tool=$(guess_merge_tool) || exit
+		guessed_merge_tool=true
+	fi
 fi
 merge_keep_backup="$(git config --bool mergetool.keepBackup || echo true)"
 merge_keep_temporaries="$(git config --bool mergetool.keepTemporaries || echo false)"
-- 
1.9.2+fc1.1.g5c924db

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help