* [PATCH v2 3/5] Add --gui option to mergetool
@ 2017-03-03 13:40 Denton Liu
0 siblings, 0 replies; only message in thread
From: Denton Liu @ 2017-03-03 13:40 UTC (permalink / raw)
To: git; +Cc: davvid, Johannes.Schindelin
This fixes the discrepancy between difftool and mergetool where the
former has the --gui flag and the latter does not by adding the
functionality to mergetool.
Signed-off-by: Denton Liu <liu.denton@gmail.com>
---
Documentation/git-mergetool.txt | 8 +++++++-
git-mergetool.sh | 5 ++++-
t/t7610-mergetool.sh | 28 +++++++++++++++++++++++++++-
3 files changed, 38 insertions(+), 3 deletions(-)
diff --git a/Documentation/git-mergetool.txt b/Documentation/git-mergetool.txt
index 3622d6648..2ab56efcf 100644
--- a/Documentation/git-mergetool.txt
+++ b/Documentation/git-mergetool.txt
@@ -8,7 +8,7 @@ git-mergetool - Run merge conflict resolution tools to resolve merge conflicts
SYNOPSIS
--------
[verse]
-'git mergetool' [--tool=<tool>] [-y | --[no-]prompt] [<file>...]
+'git mergetool' [--tool=<tool>] [-g|--gui] [-y | --[no-]prompt] [<file>...]
DESCRIPTION
-----------
@@ -64,6 +64,12 @@ variable `mergetool.<tool>.trustExitCode` can be set to `true`.
Otherwise, 'git mergetool' will prompt the user to indicate the
success of the resolution after the custom tool has exited.
+-g::
+--gui::
+ When 'git-mergetool' is invoked with the `-g` or `--gui` option
+ the default diff tool will be read from the configured
+ `merge.guitool` variable instead of `merge.tool`.
+
--tool-help::
Print a list of merge tools that may be used with `--tool`.
diff --git a/git-mergetool.sh b/git-mergetool.sh
index c062e3de3..f3fce528b 100755
--- a/git-mergetool.sh
+++ b/git-mergetool.sh
@@ -9,7 +9,7 @@
# at the discretion of Junio C Hamano.
#
-USAGE='[--tool=tool] [--tool-help] [-y|--no-prompt|--prompt] [-O<orderfile>] [file to merge] ...'
+USAGE='[--tool=tool] [-g|--gui] [--tool-help] [-y|--no-prompt|--prompt] [-O<orderfile>] [file to merge] ...'
SUBDIRECTORY_OK=Yes
NONGIT_OK=Yes
OPTIONS_SPEC=
@@ -414,6 +414,9 @@ main () {
shift ;;
esac
;;
+ -g|--gui)
+ merge_tool=$(git config merge.guitool)
+ ;;
-y|--no-prompt)
prompt=false
;;
diff --git a/t/t7610-mergetool.sh b/t/t7610-mergetool.sh
index 01c1d44a9..31610f3b0 100755
--- a/t/t7610-mergetool.sh
+++ b/t/t7610-mergetool.sh
@@ -123,7 +123,9 @@ test_expect_success 'setup' '
git config mergetool.mytool.cmd "cat \"\$REMOTE\" >\"\$MERGED\"" &&
git config mergetool.mytool.trustExitCode true &&
git config mergetool.mybase.cmd "cat \"\$BASE\" >\"\$MERGED\"" &&
- git config mergetool.mybase.trustExitCode true
+ git config mergetool.mybase.trustExitCode true &&
+ git config mergetool.badtool.cmd false &&
+ git config mergetool.badtool.trustExitCode true
'
test_expect_success 'custom mergetool' '
@@ -145,6 +147,30 @@ test_expect_success 'custom mergetool' '
git commit -m "branch1 resolved with mergetool"
'
+test_expect_success 'gui mergetool' '
+ test_when_finished "git reset --hard" &&
+ test_when_finished "git config merge.tool mytool" &&
+ test_when_finished "git config --unset merge.guitool" &&
+ git config merge.tool badtool &&
+ git config merge.guitool mytool &&
+ git checkout -b test$test_count branch1 &&
+ git submodule update -N &&
+ test_expect_code 1 git merge master >/dev/null 2>&1 &&
+ git mergetool -g both >/dev/null 2>&1 &&
+ git mergetool -g file1 file1 &&
+ git mergetool --gui file2 "spaced name" >/dev/null 2>&1 &&
+ git mergetool --gui subdir/file3 >/dev/null 2>&1 &&
+ ( yes "d" | git mergetool -g file11 >/dev/null 2>&1 ) &&
+ ( yes "d" | git mergetool --gui file12 >/dev/null 2>&1 ) &&
+ ( yes "l" | git mergetool --gui submod >/dev/null 2>&1 ) &&
+ cat file1 &&
+ test "$(cat file1)" = "master updated" &&
+ test "$(cat file2)" = "master new" &&
+ test "$(cat subdir/file3)" = "master new sub" &&
+ test "$(cat submod/bar)" = "branch1 submodule" &&
+ git commit -m "branch1 resolved with gui mergetool"
+'
+
test_expect_success 'mergetool crlf' '
test_when_finished "git reset --hard" &&
# This test_config line must go after the above reset line so that
--
2.12.0.5.gfbc750a84
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2017-03-03 13:48 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-03-03 13:40 [PATCH v2 3/5] Add --gui option to mergetool Denton Liu
Code repositories for project(s) associated with this public inbox
https://80x24.org/mirrors/git.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).