Skip to content

Commit

Permalink
mergetool: run prompt only if guessed tool
Browse files Browse the repository at this point in the history
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 <felipe.contreras@gmail.com>
Acked-by: David Aguilar <davvid@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
  • Loading branch information
Felipe Contreras authored and Junio C Hamano committed Apr 22, 2014
1 parent 779792a commit 4ecc63d
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions git-mergetool.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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)"
Expand Down

0 comments on commit 4ecc63d

Please sign in to comment.