{"thread":{"id":"44242","subject":"[PATCH v2 4/4] mergetool: honor -O<orderfile>","startedAt":"2016-10-07T04:05:26Z","lastAt":"2016-10-07T04:05:26Z","messageCount":1,"participants":["David Aguilar"],"isPatch":true,"patchVersion":2,"patchTotal":4},"messages":[{"id":"303547","messageId":"20161007040502.16801-1-davvid@gmail.com","threadId":"44242","inReplyTo":null,"subject":"[PATCH v2 4/4] mergetool: honor -O<orderfile>","fromName":"David Aguilar","fromEmail":"davvid@gmail.com","sentAt":"2016-10-07T04:05:02Z","receivedAt":"2016-10-07T04:05:26Z","isPatch":true,"sender":{"key":"davvid@gmail.com","avatar":"https://avatars.githubusercontent.com/u/13196?v=4"},"body":"Teach mergetool to pass \"-O<orderfile>\" down to `git diff` when\nspecified on the command-line.\n\nSigned-off-by: David Aguilar <davvid@gmail.com>\n---\nThis is a replacement patch for 4/4 from the original series.\n\nThe changes are stylistic -- the \"order_file\" variable name and\n\"-O<order-file>\" in the usage were changed to \"orderfile\" and\n\"-O<orderfile>\" for consistency with the documentation.\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..1a0fe7a 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<orderfile>] [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+\torderfile=\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\torderfile=\"$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 \"$orderfile\"\n+\tthen\n+\t\tset -- \"$orderfile\" -- \"$@\"\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.386.g42aabb0\n\n"}]}