Skip to content

Commit 4ecc63d

Browse files
felipecgitster
authored andcommitted
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 <[email protected]> Acked-by: David Aguilar <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 779792a commit 4ecc63d

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

git-mergetool.sh

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -277,7 +277,7 @@ merge_file () {
277277
echo "Normal merge conflict for '$MERGED':"
278278
describe_file "$local_mode" "local" "$LOCAL"
279279
describe_file "$remote_mode" "remote" "$REMOTE"
280-
if "$prompt" = true
280+
if test "$guessed_merge_tool" = true || test "$prompt" = true
281281
then
282282
printf "Hit return to start merge resolution tool (%s): " "$merge_tool"
283283
read ans || return 1
@@ -315,7 +315,8 @@ merge_file () {
315315
return 0
316316
}
317317

318-
prompt=$(git config --bool mergetool.prompt || echo true)
318+
prompt=$(git config --bool mergetool.prompt)
319+
guessed_merge_tool=false
319320

320321
while test $# != 0
321322
do
@@ -373,7 +374,14 @@ prompt_after_failed_merge () {
373374

374375
if test -z "$merge_tool"
375376
then
376-
merge_tool=$(get_merge_tool "$merge_tool") || exit
377+
# Check if a merge tool has been configured
378+
merge_tool=$(get_configured_merge_tool)
379+
# Try to guess an appropriate merge tool if no tool has been set.
380+
if test -z "$merge_tool"
381+
then
382+
merge_tool=$(guess_merge_tool) || exit
383+
guessed_merge_tool=true
384+
fi
377385
fi
378386
merge_keep_backup="$(git config --bool mergetool.keepBackup || echo true)"
379387
merge_keep_temporaries="$(git config --bool mergetool.keepTemporaries || echo false)"

0 commit comments

Comments
 (0)