{"thread":{"id":"44240","subject":"[PATCH 1/4] mergetool: add copyright","startedAt":"2016-10-06T23:48:10Z","lastAt":"2016-10-07T17:16:47Z","messageCount":7,"participants":["David Aguilar","Johannes Sixt"],"isPatch":true,"patchVersion":1,"patchTotal":4},"messages":[{"id":"303541","messageId":"1475797679-32712-1-git-send-email-davvid@gmail.com","threadId":"44240","inReplyTo":null,"subject":"[PATCH 1/4] mergetool: add copyright","fromName":"David Aguilar","fromEmail":"davvid@gmail.com","sentAt":"2016-10-06T23:47:56Z","receivedAt":"2016-10-06T23:48:10Z","isPatch":true,"sender":{"key":"davvid@gmail.com","avatar":"https://avatars.githubusercontent.com/u/13196?v=4"},"body":"Signed-off-by: David Aguilar <davvid@gmail.com>\n---\n git-mergetool.sh | 1 +\n 1 file changed, 1 insertion(+)\n\ndiff --git a/git-mergetool.sh b/git-mergetool.sh\nindex bf86270..300ce7f 100755\n--- a/git-mergetool.sh\n+++ b/git-mergetool.sh\n@@ -3,6 +3,7 @@\n # This program resolves merge conflicts in git\n #\n # Copyright (c) 2006 Theodore Y. Ts'o\n+# Copyright (c) 2009-2016 David Aguilar\n #\n # This file is licensed under the GPL v2, or a later version\n # at the discretion of Junio C Hamano.\n-- \n2.10.1.355.g33afd83.dirty\n\n"},{"id":"303542","messageId":"1475797679-32712-2-git-send-email-davvid@gmail.com","threadId":"44240","inReplyTo":"1475797679-32712-1-git-send-email-davvid@gmail.com","subject":"[PATCH 2/4] mergetool: move main program flow into a main() function","fromName":"David Aguilar","fromEmail":"davvid@gmail.com","sentAt":"2016-10-06T23:47:57Z","receivedAt":"2016-10-06T23:48:14Z","isPatch":true,"sender":{"key":"davvid@gmail.com","avatar":"https://avatars.githubusercontent.com/u/13196?v=4"},"body":"Signed-off-by: David Aguilar <davvid@gmail.com>\n---\n git-mergetool.sh | 180 ++++++++++++++++++++++++++++---------------------------\n 1 file changed, 93 insertions(+), 87 deletions(-)\n\ndiff --git a/git-mergetool.sh b/git-mergetool.sh\nindex 300ce7f..b2cd0a4 100755\n--- a/git-mergetool.sh\n+++ b/git-mergetool.sh\n@@ -366,51 +366,6 @@ merge_file () {\n \treturn 0\n }\n \n-prompt=$(git config --bool mergetool.prompt)\n-guessed_merge_tool=false\n-\n-while test $# != 0\n-do\n-\tcase \"$1\" in\n-\t--tool-help=*)\n-\t\tTOOL_MODE=${1#--tool-help=}\n-\t\tshow_tool_help\n-\t\t;;\n-\t--tool-help)\n-\t\tshow_tool_help\n-\t\t;;\n-\t-t|--tool*)\n-\t\tcase \"$#,$1\" in\n-\t\t*,*=*)\n-\t\t\tmerge_tool=$(expr \"z$1\" : 'z-[^=]*=\\(.*\\)')\n-\t\t\t;;\n-\t\t1,*)\n-\t\t\tusage ;;\n-\t\t*)\n-\t\t\tmerge_tool=\"$2\"\n-\t\t\tshift ;;\n-\t\tesac\n-\t\t;;\n-\t-y|--no-prompt)\n-\t\tprompt=false\n-\t\t;;\n-\t--prompt)\n-\t\tprompt=true\n-\t\t;;\n-\t--)\n-\t\tshift\n-\t\tbreak\n-\t\t;;\n-\t-*)\n-\t\tusage\n-\t\t;;\n-\t*)\n-\t\tbreak\n-\t\t;;\n-\tesac\n-\tshift\n-done\n-\n prompt_after_failed_merge () {\n \twhile true\n \tdo\n@@ -427,57 +382,108 @@ prompt_after_failed_merge () {\n \tdone\n }\n \n-git_dir_init\n-require_work_tree\n+main () {\n+\tprompt=$(git config --bool mergetool.prompt)\n+\tguessed_merge_tool=false\n+\n+\twhile test $# != 0\n+\tdo\n+\t\tcase \"$1\" in\n+\t\t--tool-help=*)\n+\t\t\tTOOL_MODE=${1#--tool-help=}\n+\t\t\tshow_tool_help\n+\t\t\t;;\n+\t\t--tool-help)\n+\t\t\tshow_tool_help\n+\t\t\t;;\n+\t\t-t|--tool*)\n+\t\t\tcase \"$#,$1\" in\n+\t\t\t*,*=*)\n+\t\t\t\tmerge_tool=$(expr \"z$1\" : 'z-[^=]*=\\(.*\\)')\n+\t\t\t\t;;\n+\t\t\t1,*)\n+\t\t\t\tusage ;;\n+\t\t\t*)\n+\t\t\t\tmerge_tool=\"$2\"\n+\t\t\t\tshift ;;\n+\t\t\tesac\n+\t\t\t;;\n+\t\t-y|--no-prompt)\n+\t\t\tprompt=false\n+\t\t\t;;\n+\t\t--prompt)\n+\t\t\tprompt=true\n+\t\t\t;;\n+\t\t--)\n+\t\t\tshift\n+\t\t\tbreak\n+\t\t\t;;\n+\t\t-*)\n+\t\t\tusage\n+\t\t\t;;\n+\t\t*)\n+\t\t\tbreak\n+\t\t\t;;\n+\t\tesac\n+\t\tshift\n+\tdone\n+\n+\tgit_dir_init\n+\trequire_work_tree\n \n-if test -z \"$merge_tool\"\n-then\n-\t# Check if a merge tool has been configured\n-\tmerge_tool=$(get_configured_merge_tool)\n-\t# Try to guess an appropriate merge tool if no tool has been set.\n \tif test -z \"$merge_tool\"\n \tthen\n-\t\tmerge_tool=$(guess_merge_tool) || exit\n-\t\tguessed_merge_tool=true\n+\t\t# Check if a merge tool has been configured\n+\t\tmerge_tool=$(get_configured_merge_tool)\n+\t\t# Try to guess an appropriate merge tool if no tool has been set.\n+\t\tif test -z \"$merge_tool\"\n+\t\tthen\n+\t\t\tmerge_tool=$(guess_merge_tool) || exit\n+\t\t\tguessed_merge_tool=true\n+\t\tfi\n \tfi\n-fi\n-merge_keep_backup=\"$(git config --bool mergetool.keepBackup || echo true)\"\n-merge_keep_temporaries=\"$(git config --bool mergetool.keepTemporaries || echo false)\"\n-\n-files=\n+\tmerge_keep_backup=\"$(git config --bool mergetool.keepBackup || echo true)\"\n+\tmerge_keep_temporaries=\"$(git config --bool mergetool.keepTemporaries || echo false)\"\n \n-if test $# -eq 0\n-then\n-\tcd_to_toplevel\n+\tfiles=\n \n-\tif test -e \"$GIT_DIR/MERGE_RR\"\n+\tif test $# -eq 0\n \tthen\n-\t\tfiles=$(git rerere remaining)\n+\t\tcd_to_toplevel\n+\n+\t\tif test -e \"$GIT_DIR/MERGE_RR\"\n+\t\tthen\n+\t\t\tfiles=$(git rerere remaining)\n+\t\telse\n+\t\t\tfiles=$(git ls-files -u |\n+\t\t\t\tsed -e 's/^[^\t]*\t//' | sort -u)\n+\t\tfi\n \telse\n-\t\tfiles=$(git ls-files -u | sed -e 's/^[^\t]*\t//' | sort -u)\n+\t\tfiles=$(git ls-files -u -- \"$@\" |\n+\t\t\tsed -e 's/^[^\t]*\t//' | sort -u)\n \tfi\n-else\n-\tfiles=$(git ls-files -u -- \"$@\" | sed -e 's/^[^\t]*\t//' | sort -u)\n-fi\n-\n-if test -z \"$files\"\n-then\n-\techo \"No files need merging\"\n-\texit 0\n-fi\n-\n-printf \"Merging:\\n\"\n-printf \"%s\\n\" \"$files\"\n-\n-rc=0\n-for i in $files\n-do\n-\tprintf \"\\n\"\n-\tif ! merge_file \"$i\"\n+\n+\tif test -z \"$files\"\n \tthen\n-\t\trc=1\n-\t\tprompt_after_failed_merge || exit 1\n+\t\techo \"No files need merging\"\n+\t\texit 0\n \tfi\n-done\n \n-exit $rc\n+\tprintf \"Merging:\\n\"\n+\tprintf \"%s\\n\" \"$files\"\n+\n+\trc=0\n+\tfor i in $files\n+\tdo\n+\t\tprintf \"\\n\"\n+\t\tif ! merge_file \"$i\"\n+\t\tthen\n+\t\t\trc=1\n+\t\t\tprompt_after_failed_merge || exit 1\n+\t\tfi\n+\tdone\n+\n+\texit $rc\n+}\n+\n+main \"$@\"\n-- \n2.10.1.355.g33afd83.dirty\n\n"},{"id":"303543","messageId":"1475797679-32712-3-git-send-email-davvid@gmail.com","threadId":"44240","inReplyTo":"1475797679-32712-1-git-send-email-davvid@gmail.com","subject":"[PATCH 3/4] mergetool: honor diff.orderFile","fromName":"David Aguilar","fromEmail":"davvid@gmail.com","sentAt":"2016-10-06T23:47:58Z","receivedAt":"2016-10-06T23:48:19Z","isPatch":true,"sender":{"key":"davvid@gmail.com","avatar":"https://avatars.githubusercontent.com/u/13196?v=4"},"body":"Teach mergetool to get the list of files to edit via `diff` so that we\ngain support for diff.orderFile.\n\nSuggested-by: Luis Gutierrez <luisgutz@gmail.com>\nHelped-by: Johannes Sixt <j6t@kdbg.org>\nSigned-off-by: David Aguilar <davvid@gmail.com>\n---\n Documentation/git-mergetool.txt |  5 +++++\n git-mergetool.sh                | 30 +++++++++++++++---------------\n t/t7610-mergetool.sh            | 33 +++++++++++++++++++++++++++++++++\n 3 files changed, 53 insertions(+), 15 deletions(-)\n\ndiff --git a/Documentation/git-mergetool.txt b/Documentation/git-mergetool.txt\nindex e846c2e..c4c1a9b 100644\n--- a/Documentation/git-mergetool.txt\n+++ b/Documentation/git-mergetool.txt\n@@ -79,6 +79,11 @@ success of the resolution after the custom tool has exited.\n \tPrompt before each invocation of the merge resolution program\n \tto give the user a chance to skip the path.\n \n+DIFF ORDER FILES\n+----------------\n+`git mergetool` honors the `diff.orderFile` configuration variable\n+used by `git diff`.  See linkgit:git-config[1] for more details.\n+\n TEMPORARY FILES\n ---------------\n `git mergetool` creates `*.orig` backup files while resolving merges.\ndiff --git a/git-mergetool.sh b/git-mergetool.sh\nindex b2cd0a4..65696d8 100755\n--- a/git-mergetool.sh\n+++ b/git-mergetool.sh\n@@ -382,6 +382,11 @@ prompt_after_failed_merge () {\n \tdone\n }\n \n+print_noop_and_exit () {\n+\techo \"No files need merging\"\n+\texit 0\n+}\n+\n main () {\n \tprompt=$(git config --bool mergetool.prompt)\n \tguessed_merge_tool=false\n@@ -445,28 +450,23 @@ main () {\n \tmerge_keep_backup=\"$(git config --bool mergetool.keepBackup || echo true)\"\n \tmerge_keep_temporaries=\"$(git config --bool mergetool.keepTemporaries || echo false)\"\n \n-\tfiles=\n-\n-\tif test $# -eq 0\n+\tif test $# -eq 0 && test -e \"$GIT_DIR/MERGE_RR\"\n \tthen\n-\t\tcd_to_toplevel\n-\n-\t\tif test -e \"$GIT_DIR/MERGE_RR\"\n+\t\tset -- $(git rerere remaining)\n+\t\tif test $# -eq 0\n \t\tthen\n-\t\t\tfiles=$(git rerere remaining)\n-\t\telse\n-\t\t\tfiles=$(git ls-files -u |\n-\t\t\t\tsed -e 's/^[^\t]*\t//' | sort -u)\n+\t\t\tprint_noop_and_exit\n \t\tfi\n-\telse\n-\t\tfiles=$(git ls-files -u -- \"$@\" |\n-\t\t\tsed -e 's/^[^\t]*\t//' | sort -u)\n \tfi\n \n+\tfiles=$(git -c core.quotePath=false \\\n+\t\tdiff --name-only --diff-filter=U -- \"$@\")\n+\n+\tcd_to_toplevel\n+\n \tif test -z \"$files\"\n \tthen\n-\t\techo \"No files need merging\"\n-\t\texit 0\n+\t\tprint_noop_and_exit\n \tfi\n \n \tprintf \"Merging:\\n\"\ndiff --git a/t/t7610-mergetool.sh b/t/t7610-mergetool.sh\nindex 7217f39..fb2aeef 100755\n--- a/t/t7610-mergetool.sh\n+++ b/t/t7610-mergetool.sh\n@@ -606,4 +606,37 @@ test_expect_success MKTEMP 'temporary filenames are used with mergetool.writeToT\n \tgit reset --hard master >/dev/null 2>&1\n '\n \n+test_expect_success 'diff.orderFile configuration is honored' '\n+\ttest_config diff.orderFile order-file &&\n+\ttest_config mergetool.myecho.cmd \"echo \\\"\\$LOCAL\\\"\" &&\n+\ttest_config mergetool.myecho.trustExitCode true &&\n+\techo b >order-file &&\n+\techo a >>order-file &&\n+\tgit checkout -b order-file-start master &&\n+\techo start >a &&\n+\techo start >b &&\n+\tgit add a b &&\n+\tgit commit -m start &&\n+\tgit checkout -b order-file-side1 order-file-start &&\n+\techo side1 >a &&\n+\techo side1 >b &&\n+\tgit add a b &&\n+\tgit commit -m side1 &&\n+\tgit checkout -b order-file-side2 order-file-start &&\n+\techo side2 >a &&\n+\techo side2 >b &&\n+\tgit add a b &&\n+\tgit commit -m side2 &&\n+\ttest_must_fail git merge order-file-side1 &&\n+\tcat >expect <<-\\EOF &&\n+\t\tMerging:\n+\t\tb\n+\t\ta\n+\tEOF\n+\tgit mergetool --no-prompt --tool myecho | grep -A 2 Merging: >actual &&\n+\ttest_cmp expect actual &&\n+\tgit reset --hard >/dev/null\n+'\n+'\n+\n test_done\n-- \n2.10.1.355.g33afd83.dirty\n\n"},{"id":"303544","messageId":"1475797679-32712-4-git-send-email-davvid@gmail.com","threadId":"44240","inReplyTo":"1475797679-32712-1-git-send-email-davvid@gmail.com","subject":"[PATCH 4/4] mergetool: honor -O<order-file>","fromName":"David Aguilar","fromEmail":"davvid@gmail.com","sentAt":"2016-10-06T23:47:59Z","receivedAt":"2016-10-06T23:48:22Z","isPatch":true,"sender":{"key":"davvid@gmail.com","avatar":"https://avatars.githubusercontent.com/u/13196?v=4"},"body":"Teach mergetool to pass \"-O<order-file>\" down to `git diff` when\nspecified on the command-line.\n\nSigned-off-by: David Aguilar <davvid@gmail.com>\n---\n Documentation/git-mergetool.txt | 10 ++++++----\n git-mergetool.sh                | 14 ++++++++++++--\n t/t7610-mergetool.sh            | 27 +++++++++++++++++++++++++++\n 3 files changed, 45 insertions(+), 6 deletions(-)\n\ndiff --git a/Documentation/git-mergetool.txt b/Documentation/git-mergetool.txt\nindex c4c1a9b..3622d66 100644\n--- a/Documentation/git-mergetool.txt\n+++ b/Documentation/git-mergetool.txt\n@@ -79,10 +79,12 @@ success of the resolution after the custom tool has exited.\n \tPrompt before each invocation of the merge resolution program\n \tto give the user a chance to skip the path.\n \n-DIFF ORDER FILES\n-----------------\n-`git mergetool` honors the `diff.orderFile` configuration variable\n-used by `git diff`.  See linkgit:git-config[1] for more details.\n+-O<orderfile>::\n+\tProcess files in the order specified in the\n+\t<orderfile>, which has one shell glob pattern per line.\n+\tThis overrides the `diff.orderFile` configuration variable\n+\t(see linkgit:git-config[1]).  To cancel `diff.orderFile`,\n+\tuse `-O/dev/null`.\n \n TEMPORARY FILES\n ---------------\ndiff --git a/git-mergetool.sh b/git-mergetool.sh\nindex 65696d8..9dca58b 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] [file to merge] ...'\n+USAGE='[--tool=tool] [--tool-help] [-y|--no-prompt|--prompt] [-O<order-file>] [file to merge] ...'\n SUBDIRECTORY_OK=Yes\n NONGIT_OK=Yes\n OPTIONS_SPEC=\n@@ -390,6 +390,7 @@ print_noop_and_exit () {\n main () {\n \tprompt=$(git config --bool mergetool.prompt)\n \tguessed_merge_tool=false\n+\torder_file=\n \n \twhile test $# != 0\n \tdo\n@@ -419,6 +420,9 @@ main () {\n \t\t--prompt)\n \t\t\tprompt=true\n \t\t\t;;\n+\t\t-O*)\n+\t\t\torder_file=\"$1\"\n+\t\t\t;;\n \t\t--)\n \t\t\tshift\n \t\t\tbreak\n@@ -459,8 +463,14 @@ main () {\n \t\tfi\n \tfi\n \n+\tif test -n \"$order_file\"\n+\tthen\n+\t\tset -- \"$order_file\" -- \"$@\"\n+\telse\n+\t\tset -- -- \"$@\"\n+\tfi\n \tfiles=$(git -c core.quotePath=false \\\n-\t\tdiff --name-only --diff-filter=U -- \"$@\")\n+\t\tdiff --name-only --diff-filter=U \"$@\")\n \n \tcd_to_toplevel\n \ndiff --git a/t/t7610-mergetool.sh b/t/t7610-mergetool.sh\nindex fb2aeef..0f9869a 100755\n--- a/t/t7610-mergetool.sh\n+++ b/t/t7610-mergetool.sh\n@@ -637,6 +637,33 @@ test_expect_success 'diff.orderFile configuration is honored' '\n \ttest_cmp expect actual &&\n \tgit reset --hard >/dev/null\n '\n+\n+test_expect_success 'mergetool -Oorder-file is honored' '\n+\ttest_config diff.orderFile order-file &&\n+\ttest_config mergetool.myecho.cmd \"echo \\\"\\$LOCAL\\\"\" &&\n+\ttest_config mergetool.myecho.trustExitCode true &&\n+\ttest_must_fail git merge order-file-side1 &&\n+\tcat >expect <<-\\EOF &&\n+\t\tMerging:\n+\t\ta\n+\t\tb\n+\tEOF\n+\tgit mergetool -O/dev/null --no-prompt --tool myecho |\n+\tgrep -A 2 Merging: >actual &&\n+\ttest_cmp expect actual &&\n+\tgit reset --hard >/dev/null 2>&1 &&\n+\n+\tgit config --unset diff.orderFile &&\n+\ttest_must_fail git merge order-file-side1 &&\n+\tcat >expect <<-\\EOF &&\n+\t\tMerging:\n+\t\tb\n+\t\ta\n+\tEOF\n+\tgit mergetool -Oorder-file --no-prompt --tool myecho |\n+\tgrep -A 2 Merging: >actual &&\n+\ttest_cmp expect actual &&\n+\tgit reset --hard >/dev/null 2>&1\n '\n \n test_done\n-- \n2.10.1.355.g33afd83.dirty\n\n"},{"id":"303549","messageId":"49cabceb-fdff-3ccb-b25d-ade9b08bdda2@kdbg.org","threadId":"44240","inReplyTo":"1475797679-32712-2-git-send-email-davvid@gmail.com","subject":"Re: [PATCH 2/4] mergetool: move main program flow into a main() function","fromName":"Johannes Sixt","fromEmail":"j6t@kdbg.org","sentAt":"2016-10-07T05:51:56Z","receivedAt":"2016-10-07T05:52:13Z","isPatch":true,"sender":{"key":"j6t@kdbg.org","avatar":"https://avatars.githubusercontent.com/u/14810926?v=4"},"body":"Am 07.10.2016 um 01:47 schrieb David Aguilar:\n> Signed-off-by: David Aguilar <davvid@gmail.com>\n> ---\n\nAn answer to \"why?\" is missing here. I guess it is just so that \neverything happens in functions, and that there is only the invocation \nof main at the top-level of the script. I am unsure whether this is \nsufficient justification; you are adding a level of indentation after all.\n\n-- Hannes\n\n"},{"id":"303587","messageId":"b75fce03-644b-cc27-a61a-aad5ab2d4b50@kdbg.org","threadId":"44240","inReplyTo":"1475797679-32712-3-git-send-email-davvid@gmail.com","subject":"Re: [PATCH 3/4] mergetool: honor diff.orderFile","fromName":"Johannes Sixt","fromEmail":"j6t@kdbg.org","sentAt":"2016-10-07T17:08:06Z","receivedAt":"2016-10-07T17:08:14Z","isPatch":true,"sender":{"key":"j6t@kdbg.org","avatar":"https://avatars.githubusercontent.com/u/14810926?v=4"},"body":"Am 07.10.2016 um 01:47 schrieb David Aguilar:\n> @@ -606,4 +606,37 @@ test_expect_success MKTEMP 'temporary filenames are used with mergetool.writeToT\n>  \tgit reset --hard master >/dev/null 2>&1\n>  '\n>\n> +test_expect_success 'diff.orderFile configuration is honored' '\n> +\ttest_config diff.orderFile order-file &&\n> +\ttest_config mergetool.myecho.cmd \"echo \\\"\\$LOCAL\\\"\" &&\n> +\ttest_config mergetool.myecho.trustExitCode true &&\n> +\techo b >order-file &&\n> +\techo a >>order-file &&\n> +\tgit checkout -b order-file-start master &&\n> +\techo start >a &&\n> +\techo start >b &&\n> +\tgit add a b &&\n> +\tgit commit -m start &&\n> +\tgit checkout -b order-file-side1 order-file-start &&\n> +\techo side1 >a &&\n> +\techo side1 >b &&\n> +\tgit add a b &&\n> +\tgit commit -m side1 &&\n> +\tgit checkout -b order-file-side2 order-file-start &&\n> +\techo side2 >a &&\n> +\techo side2 >b &&\n> +\tgit add a b &&\n> +\tgit commit -m side2 &&\n> +\ttest_must_fail git merge order-file-side1 &&\n> +\tcat >expect <<-\\EOF &&\n> +\t\tMerging:\n> +\t\tb\n> +\t\ta\n> +\tEOF\n> +\tgit mergetool --no-prompt --tool myecho | grep -A 2 Merging: >actual &&\n\nIs grep -A universally available?\n\n> +\ttest_cmp expect actual &&\n> +\tgit reset --hard >/dev/null\n> +'\n> +'\n\nTwo single-quotes?\n\n> +\n>  test_done\n>\n\nOtherwise the patch looks good.\n\n-- Hannes\n\n"},{"id":"303588","messageId":"8f99b183-7f9b-f577-42eb-9ff7398ffbd1@kdbg.org","threadId":"44240","inReplyTo":"1475797679-32712-4-git-send-email-davvid@gmail.com","subject":"Re: [PATCH 4/4] mergetool: honor -O<order-file>","fromName":"Johannes Sixt","fromEmail":"j6t@kdbg.org","sentAt":"2016-10-07T17:16:40Z","receivedAt":"2016-10-07T17:16:47Z","isPatch":true,"sender":{"key":"j6t@kdbg.org","avatar":"https://avatars.githubusercontent.com/u/14810926?v=4"},"body":"Am 07.10.2016 um 01:47 schrieb David Aguilar:\n> diff --git a/git-mergetool.sh b/git-mergetool.sh\n> index 65696d8..9dca58b 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] [file to merge] ...'\n> +USAGE='[--tool=tool] [--tool-help] [-y|--no-prompt|--prompt] [-O<order-file>] [file to merge] ...'\n>  SUBDIRECTORY_OK=Yes\n>  NONGIT_OK=Yes\n>  OPTIONS_SPEC=\n> @@ -390,6 +390,7 @@ print_noop_and_exit () {\n>  main () {\n>  \tprompt=$(git config --bool mergetool.prompt)\n>  \tguessed_merge_tool=false\n> +\torder_file=\n>\n>  \twhile test $# != 0\n>  \tdo\n> @@ -419,6 +420,9 @@ main () {\n>  \t\t--prompt)\n>  \t\t\tprompt=true\n>  \t\t\t;;\n> +\t\t-O*)\n> +\t\t\torder_file=\"$1\"\n> +\t\t\t;;\n>  \t\t--)\n>  \t\t\tshift\n>  \t\t\tbreak\n> @@ -459,8 +463,14 @@ main () {\n>  \t\tfi\n>  \tfi\n>\n> +\tif test -n \"$order_file\"\n> +\tthen\n> +\t\tset -- \"$order_file\" -- \"$@\"\n> +\telse\n> +\t\tset -- -- \"$@\"\n> +\tfi\n>  \tfiles=$(git -c core.quotePath=false \\\n> -\t\tdiff --name-only --diff-filter=U -- \"$@\")\n> +\t\tdiff --name-only --diff-filter=U \"$@\")\n\nYou can write this as\n\n\tfiles=$(git -c core.quotePath=false \\\n\t\tdiff --name-only --diff-filter=U \\\n\t\t${order_file:+\"$order_file\"} -- \"$@\")\n\nwithout the case distinction earlier. This construct is usually used to \nattach the option (-O) in front of the argument, but it is already \nincluded in the value; so, we use the construct only to avoid an empty \nargument when the option is unset and to get a quoted string when it is set.\n\n>\n>  \tcd_to_toplevel\n>\n> diff --git a/t/t7610-mergetool.sh b/t/t7610-mergetool.sh\n> index fb2aeef..0f9869a 100755\n> --- a/t/t7610-mergetool.sh\n> +++ b/t/t7610-mergetool.sh\n> @@ -637,6 +637,33 @@ test_expect_success 'diff.orderFile configuration is honored' '\n>  \ttest_cmp expect actual &&\n>  \tgit reset --hard >/dev/null\n>  '\n> +\n> +test_expect_success 'mergetool -Oorder-file is honored' '\n> +\ttest_config diff.orderFile order-file &&\n> +\ttest_config mergetool.myecho.cmd \"echo \\\"\\$LOCAL\\\"\" &&\n> +\ttest_config mergetool.myecho.trustExitCode true &&\n> +\ttest_must_fail git merge order-file-side1 &&\n> +\tcat >expect <<-\\EOF &&\n> +\t\tMerging:\n> +\t\ta\n> +\t\tb\n> +\tEOF\n> +\tgit mergetool -O/dev/null --no-prompt --tool myecho |\n> +\tgrep -A 2 Merging: >actual &&\n> +\ttest_cmp expect actual &&\n> +\tgit reset --hard >/dev/null 2>&1 &&\n> +\n> +\tgit config --unset diff.orderFile &&\n> +\ttest_must_fail git merge order-file-side1 &&\n> +\tcat >expect <<-\\EOF &&\n> +\t\tMerging:\n> +\t\tb\n> +\t\ta\n> +\tEOF\n> +\tgit mergetool -Oorder-file --no-prompt --tool myecho |\n> +\tgrep -A 2 Merging: >actual &&\n\ngrep -A again. Furthermore, you call git mergetool in the upstream of a \npipe. This will ignore the exit status.\n\n> +\ttest_cmp expect actual &&\n> +\tgit reset --hard >/dev/null 2>&1\n>  '\n\nAh, the earlier lone quote should have been added in this patch.\n\n-- Hannes\n\n"}]}