Skip to content

Commit 7ea60c1

Browse files
committed
Merge branch 'fc/mergetool-prompt'
mergetool.prompt used to default to 'true', always causing a confirmation "do you really want to run the tool on this path" to be shown. Among the two purposes the prompt serves, ignore the use case to confirm that the user wants to view particular path with the named tool, and make the prompt only to confirm the choice of the tool made by autodetection and defaulting. For those who configured the tool explicitly, the prompt shown for the latter purpose is simply annoying. Strictly speaking, this is a backward incompatible change and the users need to explicitly set the variable to 'true' if they want to resurrect the now-ignored use case. * fc/mergetool-prompt: mergetool: document the default for --[no-]prompt mergetool: run prompt only if guessed tool
2 parents e379831 + c15bb0c commit 7ea60c1

File tree

2 files changed

+16
-6
lines changed

2 files changed

+16
-6
lines changed

Documentation/git-mergetool.txt

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -71,11 +71,13 @@ success of the resolution after the custom tool has exited.
7171
--no-prompt::
7272
Don't prompt before each invocation of the merge resolution
7373
program.
74+
This is the default if the merge resolution program is
75+
explicitly specified with the `--tool` option or with the
76+
`merge.tool` configuration variable.
7477

7578
--prompt::
76-
Prompt before each invocation of the merge resolution program.
77-
This is the default behaviour; the option is provided to
78-
override any configuration settings.
79+
Prompt before each invocation of the merge resolution program
80+
to give the user a chance to skip the path.
7981

8082
TEMPORARY FILES
8183
---------------

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)