git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
* [PATCH 1/3] Add --gui option to mergetool
@ 2017-03-03 11:57 Denton Liu
  2017-03-03 12:39 ` David Aguilar
  2017-03-03 18:06 ` Rémi Galan Alfonso
  0 siblings, 2 replies; 3+ messages in thread
From: Denton Liu @ 2017-03-03 11:57 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 +++++++-
 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


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH 1/3] Add --gui option to mergetool
  2017-03-03 11:57 [PATCH 1/3] Add --gui option to mergetool Denton Liu
@ 2017-03-03 12:39 ` David Aguilar
  2017-03-03 18:06 ` Rémi Galan Alfonso
  1 sibling, 0 replies; 3+ messages in thread
From: David Aguilar @ 2017-03-03 12:39 UTC (permalink / raw)
  To: Denton Liu; +Cc: git, Johannes.Schindelin

On Fri, Mar 03, 2017 at 03:57:38AM -0800, Denton Liu wrote:
> 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(-)

Would you mind splitting up this patch so that the
completion part is done separately?


> 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
> @@ -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 &&

It'd probably be better to use test_expect_code instead of
test_must_fail here:

	test_expect_code 1 git merge master ...


> +	( 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 ) &&

I realize that this test is based on an existing one, but I'm curious..
is "yes" used above because it's prompting, and using -y or --no-prompt
here would eliminate the need for the 'yes ""' parts?

Looks good otherwise.

Thanks,
-- 
David

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH 1/3] Add --gui option to mergetool
  2017-03-03 11:57 [PATCH 1/3] Add --gui option to mergetool Denton Liu
  2017-03-03 12:39 ` David Aguilar
@ 2017-03-03 18:06 ` Rémi Galan Alfonso
  1 sibling, 0 replies; 3+ messages in thread
From: Rémi Galan Alfonso @ 2017-03-03 18:06 UTC (permalink / raw)
  To: Denton Liu, git; +Cc: davvid, Johannes.Schindelin

Hi,

Denton Liu <liu.denton@gmail.com> writes:
 > [...]
 >
 > +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 &&

You should be able to squash the lines
   `test_when_finished "git config --unset merge.guitool" &&`
and
   `git config merge.guitool mytool &&`
into
   `test_config merge.guitool mytool`

(It is however not possible with merge.tool since you set it to a
specific value 'when_finished')

Thanks,
Rémi


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2017-03-03 18:07 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-03-03 11:57 [PATCH 1/3] Add --gui option to mergetool Denton Liu
2017-03-03 12:39 ` David Aguilar
2017-03-03 18:06 ` Rémi Galan Alfonso

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).