]> git.ipfire.org Git - thirdparty/git.git/commitdiff
mergetool: honor -O<orderfile>
authorDavid Aguilar <davvid@gmail.com>
Sat, 8 Oct 2016 00:01:30 +0000 (17:01 -0700)
committerJunio C Hamano <gitster@pobox.com>
Tue, 11 Oct 2016 17:04:31 +0000 (10:04 -0700)
Teach mergetool to pass "-O<orderfile>" down to `git diff` when
specified on the command-line.

Helped-by: Johannes Sixt <j6t@kdbg.org>
Signed-off-by: David Aguilar <davvid@gmail.com>
Reviewed-by: Johannes Sixt <j6t@kdbg.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Documentation/git-mergetool.txt
git-mergetool.sh
t/t7610-mergetool.sh

index c4c1a9bde4ea6f8d28674630221c9a16523c9e7e..3622d66488c7de057d32e02cd4cfd21704500822 100644 (file)
@@ -79,10 +79,12 @@ success of the resolution after the custom tool has exited.
        Prompt before each invocation of the merge resolution program
        to give the user a chance to skip the path.
 
-DIFF ORDER FILES
-----------------
-`git mergetool` honors the `diff.orderFile` configuration variable
-used by `git diff`.  See linkgit:git-config[1] for more details.
+-O<orderfile>::
+       Process files in the order specified in the
+       <orderfile>, which has one shell glob pattern per line.
+       This overrides the `diff.orderFile` configuration variable
+       (see linkgit:git-config[1]).  To cancel `diff.orderFile`,
+       use `-O/dev/null`.
 
 TEMPORARY FILES
 ---------------
index 65696d83828a960e3e8d4b2794b7aa0b3172ff1e..e52b4e4f24088d7552d88aa5a3c9ffc308f6a4cf 100755 (executable)
@@ -9,7 +9,7 @@
 # at the discretion of Junio C Hamano.
 #
 
-USAGE='[--tool=tool] [--tool-help] [-y|--no-prompt|--prompt] [file to merge] ...'
+USAGE='[--tool=tool] [--tool-help] [-y|--no-prompt|--prompt] [-O<orderfile>] [file to merge] ...'
 SUBDIRECTORY_OK=Yes
 NONGIT_OK=Yes
 OPTIONS_SPEC=
@@ -390,6 +390,7 @@ print_noop_and_exit () {
 main () {
        prompt=$(git config --bool mergetool.prompt)
        guessed_merge_tool=false
+       orderfile=
 
        while test $# != 0
        do
@@ -419,6 +420,9 @@ main () {
                --prompt)
                        prompt=true
                        ;;
+               -O*)
+                       orderfile="$1"
+                       ;;
                --)
                        shift
                        break
@@ -460,7 +464,8 @@ main () {
        fi
 
        files=$(git -c core.quotePath=false \
-               diff --name-only --diff-filter=U -- "$@")
+               diff --name-only --diff-filter=U \
+               ${orderfile:+"$orderfile"} -- "$@")
 
        cd_to_toplevel
 
index 38c1e4de713c6ce4db5262d1753b6323bb43e453..6d9f21511fe1062565d8d08f60c385cffd94cac6 100755 (executable)
@@ -638,5 +638,32 @@ test_expect_success 'diff.orderFile configuration is honored' '
        test_cmp expect actual &&
        git reset --hard >/dev/null
 '
+test_expect_success 'mergetool -Oorder-file is honored' '
+       test_config diff.orderFile order-file &&
+       test_config mergetool.myecho.cmd "echo \"\$LOCAL\"" &&
+       test_config mergetool.myecho.trustExitCode true &&
+       test_must_fail git merge order-file-side1 &&
+       cat >expect <<-\EOF &&
+               Merging:
+               a
+               b
+       EOF
+       git mergetool -O/dev/null --no-prompt --tool myecho >output &&
+       git grep --no-index -h -A2 Merging: output >actual &&
+       test_cmp expect actual &&
+       git reset --hard >/dev/null 2>&1 &&
+
+       git config --unset diff.orderFile &&
+       test_must_fail git merge order-file-side1 &&
+       cat >expect <<-\EOF &&
+               Merging:
+               b
+               a
+       EOF
+       git mergetool -Oorder-file --no-prompt --tool myecho >output &&
+       git grep --no-index -h -A2 Merging: output >actual &&
+       test_cmp expect actual &&
+       git reset --hard >/dev/null 2>&1
+'
 
 test_done