From: Denton Liu <liu.denton@gmail.com>
To: git@vger.kernel.org
Cc: davvid@gmail.com, Johannes.Schindelin@gmx.de
Subject: [PATCH 1/3] Add --gui option to mergetool
Date: Fri, 3 Mar 2017 03:57:38 -0800 [thread overview]
Message-ID: <20170303115738.GA13211@arch-attack.localdomain> (raw)
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 +++++++-
contrib/completion/git-completion.bash | 3 ++-
git-mergetool.sh | 5 ++++-
t/t7610-mergetool.sh | 28 +++++++++++++++++++++++++++-
4 files changed, 40 insertions(+), 4 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/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash
index 41ee52991..d5f3b9aeb 100644
--- a/contrib/completion/git-completion.bash
+++ b/contrib/completion/git-completion.bash
@@ -1584,7 +1584,7 @@ _git_mergetool ()
return
;;
--*)
- __gitcomp "--tool= --prompt --no-prompt"
+ __gitcomp "--tool= --prompt --no-prompt --gui"
return
;;
esac
@@ -2308,6 +2308,7 @@ _git_config ()
merge.renormalize
merge.stat
merge.tool
+ merge.guitool
merge.verbosity
mergetool.
mergetool.keepBackup
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 381b7df45..5683907ab 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_must_fail git merge master >/dev/null 2>&1 &&
+ ( yes "" | git mergetool -g both >/dev/null 2>&1 ) &&
+ ( yes "" | git mergetool -g file1 file1 ) &&
+ ( yes "" | git mergetool --gui file2 "spaced name" >/dev/null 2>&1 ) &&
+ ( yes "" | 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.1.g5415fdfc5.dirty
next reply other threads:[~2017-03-03 11:57 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-03-03 11:57 Denton Liu [this message]
2017-03-03 12:39 ` [PATCH 1/3] Add --gui option to mergetool David Aguilar
2017-03-03 18:06 ` Rémi Galan Alfonso
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: http://vger.kernel.org/majordomo-info.html
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20170303115738.GA13211@arch-attack.localdomain \
--to=liu.denton@gmail.com \
--cc=Johannes.Schindelin@gmx.de \
--cc=davvid@gmail.com \
--cc=git@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).