{"thread":{"id":"45272","subject":"[PATCH 1/3] Add --gui option to mergetool","startedAt":"2017-03-03T11:57:54Z","lastAt":"2017-03-03T18:07:47Z","messageCount":3,"participants":["Denton Liu","David Aguilar","Rémi Galan Alfonso"],"isPatch":true,"patchVersion":1,"patchTotal":3},"messages":[{"id":"313164","messageId":"20170303115738.GA13211@arch-attack.localdomain","threadId":"45272","inReplyTo":null,"subject":"[PATCH 1/3] Add --gui option to mergetool","fromName":"Denton Liu","fromEmail":"liu.denton@gmail.com","sentAt":"2017-03-03T11:57:38Z","receivedAt":"2017-03-03T11:57:54Z","isPatch":true,"sender":{"key":"liu.denton@gmail.com","avatar":"https://avatars.githubusercontent.com/u/9620836?v=4"},"body":"This fixes the discrepancy between difftool and mergetool where the\nformer has the --gui flag and the latter does not by adding the\nfunctionality to mergetool.\n\nSigned-off-by: Denton Liu <liu.denton@gmail.com>\n---\n Documentation/git-mergetool.txt        |  8 +++++++-\n contrib/completion/git-completion.bash |  3 ++-\n git-mergetool.sh                       |  5 ++++-\n t/t7610-mergetool.sh                   | 28 +++++++++++++++++++++++++++-\n 4 files changed, 40 insertions(+), 4 deletions(-)\n\ndiff --git a/Documentation/git-mergetool.txt b/Documentation/git-mergetool.txt\nindex 3622d6648..2ab56efcf 100644\n--- a/Documentation/git-mergetool.txt\n+++ b/Documentation/git-mergetool.txt\n@@ -8,7 +8,7 @@ git-mergetool - Run merge conflict resolution tools to resolve merge conflicts\n SYNOPSIS\n --------\n [verse]\n-'git mergetool' [--tool=<tool>] [-y | --[no-]prompt] [<file>...]\n+'git mergetool' [--tool=<tool>] [-g|--gui] [-y | --[no-]prompt] [<file>...]\n \n DESCRIPTION\n -----------\n@@ -64,6 +64,12 @@ variable `mergetool.<tool>.trustExitCode` can be set to `true`.\n Otherwise, 'git mergetool' will prompt the user to indicate the\n success of the resolution after the custom tool has exited.\n \n+-g::\n+--gui::\n+\tWhen 'git-mergetool' is invoked with the `-g` or `--gui` option\n+\tthe default diff tool will be read from the configured\n+\t`merge.guitool` variable instead of `merge.tool`.\n+\n --tool-help::\n \tPrint a list of merge tools that may be used with `--tool`.\n \ndiff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash\nindex 41ee52991..d5f3b9aeb 100644\n--- a/contrib/completion/git-completion.bash\n+++ b/contrib/completion/git-completion.bash\n@@ -1584,7 +1584,7 @@ _git_mergetool ()\n \t\treturn\n \t\t;;\n \t--*)\n-\t\t__gitcomp \"--tool= --prompt --no-prompt\"\n+\t\t__gitcomp \"--tool= --prompt --no-prompt --gui\"\n \t\treturn\n \t\t;;\n \tesac\n@@ -2308,6 +2308,7 @@ _git_config ()\n \t\tmerge.renormalize\n \t\tmerge.stat\n \t\tmerge.tool\n+\t\tmerge.guitool\n \t\tmerge.verbosity\n \t\tmergetool.\n \t\tmergetool.keepBackup\ndiff --git a/git-mergetool.sh b/git-mergetool.sh\nindex c062e3de3..f3fce528b 100755\n--- a/git-mergetool.sh\n+++ b/git-mergetool.sh\n@@ -9,7 +9,7 @@\n # at the discretion of Junio C Hamano.\n #\n \n-USAGE='[--tool=tool] [--tool-help] [-y|--no-prompt|--prompt] [-O<orderfile>] [file to merge] ...'\n+USAGE='[--tool=tool] [-g|--gui] [--tool-help] [-y|--no-prompt|--prompt] [-O<orderfile>] [file to merge] ...'\n SUBDIRECTORY_OK=Yes\n NONGIT_OK=Yes\n OPTIONS_SPEC=\n@@ -414,6 +414,9 @@ main () {\n \t\t\t\tshift ;;\n \t\t\tesac\n \t\t\t;;\n+\t\t-g|--gui)\n+\t\t\tmerge_tool=$(git config merge.guitool)\n+\t\t\t;;\n \t\t-y|--no-prompt)\n \t\t\tprompt=false\n \t\t\t;;\ndiff --git a/t/t7610-mergetool.sh b/t/t7610-mergetool.sh\nindex 381b7df45..5683907ab 100755\n--- a/t/t7610-mergetool.sh\n+++ b/t/t7610-mergetool.sh\n@@ -123,7 +123,9 @@ test_expect_success 'setup' '\n \tgit config mergetool.mytool.cmd \"cat \\\"\\$REMOTE\\\" >\\\"\\$MERGED\\\"\" &&\n \tgit config mergetool.mytool.trustExitCode true &&\n \tgit config mergetool.mybase.cmd \"cat \\\"\\$BASE\\\" >\\\"\\$MERGED\\\"\" &&\n-\tgit config mergetool.mybase.trustExitCode true\n+\tgit config mergetool.mybase.trustExitCode true &&\n+\tgit config mergetool.badtool.cmd false &&\n+\tgit config mergetool.badtool.trustExitCode true\n '\n \n test_expect_success 'custom mergetool' '\n@@ -145,6 +147,30 @@ test_expect_success 'custom mergetool' '\n \tgit commit -m \"branch1 resolved with mergetool\"\n '\n \n+test_expect_success 'gui mergetool' '\n+\ttest_when_finished \"git reset --hard\" &&\n+\ttest_when_finished \"git config merge.tool mytool\" &&\n+\ttest_when_finished \"git config --unset merge.guitool\" &&\n+\tgit config merge.tool badtool &&\n+\tgit config merge.guitool mytool &&\n+\tgit checkout -b test$test_count branch1 &&\n+\tgit submodule update -N &&\n+\ttest_must_fail git merge master >/dev/null 2>&1 &&\n+\t( yes \"\" | git mergetool -g both >/dev/null 2>&1 ) &&\n+\t( yes \"\" | git mergetool -g file1 file1 ) &&\n+\t( yes \"\" | git mergetool --gui file2 \"spaced name\" >/dev/null 2>&1 ) &&\n+\t( yes \"\" | git mergetool --gui subdir/file3 >/dev/null 2>&1 ) &&\n+\t( yes \"d\" | git mergetool -g file11 >/dev/null 2>&1 ) &&\n+\t( yes \"d\" | git mergetool --gui file12 >/dev/null 2>&1 ) &&\n+\t( yes \"l\" | git mergetool --gui submod >/dev/null 2>&1 ) &&\n+\tcat file1 &&\n+\ttest \"$(cat file1)\" = \"master updated\" &&\n+\ttest \"$(cat file2)\" = \"master new\" &&\n+\ttest \"$(cat subdir/file3)\" = \"master new sub\" &&\n+\ttest \"$(cat submod/bar)\" = \"branch1 submodule\" &&\n+\tgit commit -m \"branch1 resolved with gui mergetool\"\n+'\n+\n test_expect_success 'mergetool crlf' '\n \ttest_when_finished \"git reset --hard\" &&\n \t# This test_config line must go after the above reset line so that\n-- \n2.12.0.1.g5415fdfc5.dirty\n\n"},{"id":"313170","messageId":"20170303123934.4cau7ansprx2xpc7@gmail.com","threadId":"45272","inReplyTo":"20170303115738.GA13211@arch-attack.localdomain","subject":"Re: [PATCH 1/3] Add --gui option to mergetool","fromName":"David Aguilar","fromEmail":"davvid@gmail.com","sentAt":"2017-03-03T12:39:34Z","receivedAt":"2017-03-03T13:04:44Z","isPatch":true,"sender":{"key":"davvid@gmail.com","avatar":"https://avatars.githubusercontent.com/u/13196?v=4"},"body":"On Fri, Mar 03, 2017 at 03:57:38AM -0800, Denton Liu wrote:\n> This fixes the discrepancy between difftool and mergetool where the\n> former has the --gui flag and the latter does not by adding the\n> functionality to mergetool.\n> \n> Signed-off-by: Denton Liu <liu.denton@gmail.com>\n> ---\n>  Documentation/git-mergetool.txt        |  8 +++++++-\n>  contrib/completion/git-completion.bash |  3 ++-\n>  git-mergetool.sh                       |  5 ++++-\n>  t/t7610-mergetool.sh                   | 28 +++++++++++++++++++++++++++-\n>  4 files changed, 40 insertions(+), 4 deletions(-)\n\nWould you mind splitting up this patch so that the\ncompletion part is done separately?\n\n\n> diff --git a/t/t7610-mergetool.sh b/t/t7610-mergetool.sh\n> index 381b7df45..5683907ab 100755\n> --- a/t/t7610-mergetool.sh\n> +++ b/t/t7610-mergetool.sh\n> @@ -145,6 +147,30 @@ test_expect_success 'custom mergetool' '\n>  \tgit commit -m \"branch1 resolved with mergetool\"\n>  '\n>  \n> +test_expect_success 'gui mergetool' '\n> +\ttest_when_finished \"git reset --hard\" &&\n> +\ttest_when_finished \"git config merge.tool mytool\" &&\n> +\ttest_when_finished \"git config --unset merge.guitool\" &&\n> +\tgit config merge.tool badtool &&\n> +\tgit config merge.guitool mytool &&\n> +\tgit checkout -b test$test_count branch1 &&\n> +\tgit submodule update -N &&\n> +\ttest_must_fail git merge master >/dev/null 2>&1 &&\n\nIt'd probably be better to use test_expect_code instead of\ntest_must_fail here:\n\n\ttest_expect_code 1 git merge master ...\n\n\n> +\t( yes \"\" | git mergetool -g both >/dev/null 2>&1 ) &&\n> +\t( yes \"\" | git mergetool -g file1 file1 ) &&\n> +\t( yes \"\" | git mergetool --gui file2 \"spaced name\" >/dev/null 2>&1 ) &&\n> +\t( yes \"\" | git mergetool --gui subdir/file3 >/dev/null 2>&1 ) &&\n\nI realize that this test is based on an existing one, but I'm curious..\nis \"yes\" used above because it's prompting, and using -y or --no-prompt\nhere would eliminate the need for the 'yes \"\"' parts?\n\nLooks good otherwise.\n\nThanks,\n-- \nDavid\n"},{"id":"313212","messageId":"cc53dc5b-4f3a-bb7f-4f4f-876ba6adb31f@gmail.com","threadId":"45272","inReplyTo":"20170303115738.GA13211@arch-attack.localdomain","subject":"Re: [PATCH 1/3] Add --gui option to mergetool","fromName":"Rémi Galan Alfonso","fromEmail":"remi.galanalfonso@gmail.com","sentAt":"2017-03-03T18:06:30Z","receivedAt":"2017-03-03T18:07:47Z","isPatch":true,"sender":{"key":"remi.galanalfonso@gmail.com","avatar":null},"body":"Hi,\n\nDenton Liu <liu.denton@gmail.com> writes:\n > [...]\n >\n > +test_expect_success 'gui mergetool' '\n > +\ttest_when_finished \"git reset --hard\" &&\n > +\ttest_when_finished \"git config merge.tool mytool\" &&\n > +\ttest_when_finished \"git config --unset merge.guitool\" &&\n > +\tgit config merge.tool badtool &&\n > +\tgit config merge.guitool mytool &&\n\nYou should be able to squash the lines\n   `test_when_finished \"git config --unset merge.guitool\" &&`\nand\n   `git config merge.guitool mytool &&`\ninto\n   `test_config merge.guitool mytool`\n\n(It is however not possible with merge.tool since you set it to a\nspecific value 'when_finished')\n\nThanks,\nRémi\n\n"}]}