@matheusbsbs / matheus-bagliano / commits / 682b451f84
Fork 0

Add -y/--no-prompt option to mergetool

This option lets git mergetool invoke the conflict resolution program without waiting for a user prompt each time. Also added a mergetool.prompt (default true) configuration variable controlling the same behaviour Signed-off-by: Charles Bailey <charles@hashpling.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Charles Bailey committed Nov 13, 2008 at 12:41 UTC 682b451f84c046aa5b082e89e3db62950cb6261a
3 files changed +26 -4
Documentation/config.txt
+3
@@ -976,6 +976,9 @@ mergetool.keepBackup::
976 is set to `false` then this file is not preserved. Defaults to
977 `true` (i.e. keep the backup files).
978
979 +mergetool.prompt::
980 + Prompt before each invocation of the merge resolution program.
981 +
982 pack.window::
983 The size of the window used by linkgit:git-pack-objects[1] when no
984 window size is given on the command line. Defaults to 10.
Documentation/git-mergetool.txt
+10 -1
@@ -7,7 +7,7 @@ git-mergetool - Run merge conflict resolution tools to resolve merge conflicts
7
8 SYNOPSIS
9 --------
10 -'git mergetool' [--tool=<tool>] [<file>]...
10 +'git mergetool' [--tool=<tool>] [-y|--no-prompt|--prompt] [<file>]...
11
12 DESCRIPTION
13 -----------
@@ -60,6 +60,15 @@ variable `mergetool.<tool>.trustExitCode` can be set to `true`.
60 Otherwise, 'git-mergetool' will prompt the user to indicate the
61 success of the resolution after the custom tool has exited.
62
63 +-y or --no-prompt::
64 + Don't prompt before each invocation of the merge resolution
65 + program.
66 +
67 +--prompt::
68 + Prompt before each invocation of the merge resolution program.
69 + This is the default behaviour; the option is provided to
70 + override any configuration settings.
71 +
72 Author
73 ------
74 Written by Theodore Y Ts'o <tytso@mit.edu>
git-mergetool.sh
+13 -3
@@ -8,7 +8,7 @@
8 # at the discretion of Junio C Hamano.
9 #
10
11 -USAGE='[--tool=tool] [file to merge] ...'
11 +USAGE='[--tool=tool] [-y|--no-prompt|--prompt] [file to merge] ...'
12 SUBDIRECTORY_OK=Yes
13 OPTIONS_SPEC=
14 . git-sh-setup
@@ -176,8 +176,10 @@ merge_file () {
176 echo "Normal merge conflict for '$MERGED':"
177 describe_file "$local_mode" "local" "$LOCAL"
178 describe_file "$remote_mode" "remote" "$REMOTE"
179 - printf "Hit return to start merge resolution tool (%s): " "$merge_tool"
180 - read ans
179 + if "$prompt" = true; then
180 + printf "Hit return to start merge resolution tool (%s): " "$merge_tool"
181 + read ans
182 + fi
183
184 case "$merge_tool" in
185 kdiff3)
@@ -280,6 +282,8 @@ merge_file () {
282 cleanup_temp_files
283 }
284
285 +prompt=$(git config --bool mergetool.prompt || echo true)
286 +
287 while test $# != 0
288 do
289 case "$1" in
@@ -295,6 +299,12 @@ do
299 shift ;;
300 esac
301 ;;
302 + -y|--no-prompt)
303 + prompt=false
304 + ;;
305 + --prompt)
306 + prompt=true
307 + ;;
308 --)
309 break
310 ;;