{"thread":{"id":"45278","subject":"[PATCH v2 3/5] Add --gui option to mergetool","startedAt":"2017-03-03T13:48:24Z","lastAt":"2017-03-03T13:48:24Z","messageCount":1,"participants":["Denton Liu"],"isPatch":true,"patchVersion":2,"patchTotal":5},"messages":[{"id":"313173","messageId":"20170303134030.GA6267@arch-attack.localdomain","threadId":"45278","inReplyTo":null,"subject":"[PATCH v2 3/5] Add --gui option to mergetool","fromName":"Denton Liu","fromEmail":"liu.denton@gmail.com","sentAt":"2017-03-03T13:40:30Z","receivedAt":"2017-03-03T13:48:24Z","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 git-mergetool.sh                |  5 ++++-\n t/t7610-mergetool.sh            | 28 +++++++++++++++++++++++++++-\n 3 files changed, 38 insertions(+), 3 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/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 01c1d44a9..31610f3b0 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_expect_code 1 git merge master >/dev/null 2>&1 &&\n+\tgit mergetool -g both >/dev/null 2>&1 &&\n+\tgit mergetool -g file1 file1 &&\n+\tgit mergetool --gui file2 \"spaced name\" >/dev/null 2>&1 &&\n+\tgit 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.5.gfbc750a84\n\n"}]}