From 4ecc63d7f982aa65038048bcdaf49e99b428b028 Mon Sep 17 00:00:00 2001 From: Felipe Contreras Date: Sun, 20 Apr 2014 19:17:34 -0500 Subject: mergetool: run prompt only if guessed tool 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. Signed-off-by: Felipe Contreras Acked-by: David Aguilar Signed-off-by: Junio C Hamano --- git-mergetool.sh | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/git-mergetool.sh b/git-mergetool.sh index 332528ff45..d08dc92589 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)" -- cgit v1.2.3 From c15bb0cad73e4dad52a6d4869a254baf3a689b6a Mon Sep 17 00:00:00 2001 From: Junio C Hamano Date: Wed, 23 Apr 2014 10:07:20 -0700 Subject: mergetool: document the default for --[no-]prompt The original motivation of using the prompt was to confirm to run a tool on this particular (as opposed to another) path, but the user can also take the prompt as to confirm to run this (as opposed to some other) tool. The latter of which of course is irritating for those who told which exact tool to use, which is the reason why we are flipping the default. During the review discussion of the patch, many people (including the maintainer) missed that a user can find the prompt useful way to skip running the tool on particular paths. Clarify it by adding a brief half-sentence to the description. Signed-off-by: Junio C Hamano --- Documentation/git-mergetool.txt | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/Documentation/git-mergetool.txt b/Documentation/git-mergetool.txt index 07137f252b..e846c2ed7f 100644 --- a/Documentation/git-mergetool.txt +++ b/Documentation/git-mergetool.txt @@ -71,11 +71,13 @@ success of the resolution after the custom tool has exited. --no-prompt:: Don't prompt before each invocation of the merge resolution program. + This is the default if the merge resolution program is + explicitly specified with the `--tool` option or with the + `merge.tool` configuration variable. --prompt:: - Prompt before each invocation of the merge resolution program. - This is the default behaviour; the option is provided to - override any configuration settings. + Prompt before each invocation of the merge resolution program + to give the user a chance to skip the path. TEMPORARY FILES --------------- -- cgit v1.2.3