mergetool: honor -O<orderfile>
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>
David Aguilar committed
Oct 7, 2016 at 17:01 UTC
654311bf6ee0fbf530c088271c2c76d46f31f82d
3 files changed
+40
-6
Documentation/git-mergetool.txt
+6
-4
@@ -79,10 +79,12 @@ success of the resolution after the custom tool has exited.
79
Prompt before each invocation of the merge resolution program
80
to give the user a chance to skip the path.
81
82
-DIFF ORDER FILES
83
-----------------
84
-`git mergetool` honors the `diff.orderFile` configuration variable
85
-used by `git diff`. See linkgit:git-config[1] for more details.
82
+-O<orderfile>::
83
+ Process files in the order specified in the
84
+ <orderfile>, which has one shell glob pattern per line.
85
+ This overrides the `diff.orderFile` configuration variable
86
+ (see linkgit:git-config[1]). To cancel `diff.orderFile`,
87
+ use `-O/dev/null`.
88
89
TEMPORARY FILES
90
---------------
git-mergetool.sh
+7
-2
@@ -9,7 +9,7 @@
9
# at the discretion of Junio C Hamano.
10
#
11
12
-USAGE='[--tool=tool] [--tool-help] [-y|--no-prompt|--prompt] [file to merge] ...'
12
+USAGE='[--tool=tool] [--tool-help] [-y|--no-prompt|--prompt] [-O<orderfile>] [file to merge] ...'
13
SUBDIRECTORY_OK=Yes
14
NONGIT_OK=Yes
15
OPTIONS_SPEC=
@@ -390,6 +390,7 @@ print_noop_and_exit () {
390
main () {
391
prompt=$(git config --bool mergetool.prompt)
392
guessed_merge_tool=false
393
+ orderfile=
394
395
while test $# != 0
396
do
@@ -419,6 +420,9 @@ main () {
420
--prompt)
421
prompt=true
422
;;
423
+ -O*)
424
+ orderfile="$1"
425
+ ;;
426
--)
427
shift
428
break
@@ -460,7 +464,8 @@ main () {
464
fi
465
466
files=$(git -c core.quotePath=false \
463
- diff --name-only --diff-filter=U -- "$@")
467
+ diff --name-only --diff-filter=U \
468
+ ${orderfile:+"$orderfile"} -- "$@")
469
470
cd_to_toplevel
471
t/t7610-mergetool.sh
+27
@@ -638,5 +638,32 @@ test_expect_success 'diff.orderFile configuration is honored' '
638
test_cmp expect actual &&
639
git reset --hard >/dev/null
640
'
641
+test_expect_success 'mergetool -Oorder-file is honored' '
642
+ test_config diff.orderFile order-file &&
643
+ test_config mergetool.myecho.cmd "echo \"\$LOCAL\"" &&
644
+ test_config mergetool.myecho.trustExitCode true &&
645
+ test_must_fail git merge order-file-side1 &&
646
+ cat >expect <<-\EOF &&
647
+ Merging:
648
+ a
649
+ b
650
+ EOF
651
+ git mergetool -O/dev/null --no-prompt --tool myecho >output &&
652
+ git grep --no-index -h -A2 Merging: output >actual &&
653
+ test_cmp expect actual &&
654
+ git reset --hard >/dev/null 2>&1 &&
655
+
656
+ git config --unset diff.orderFile &&
657
+ test_must_fail git merge order-file-side1 &&
658
+ cat >expect <<-\EOF &&
659
+ Merging:
660
+ b
661
+ a
662
+ EOF
663
+ git mergetool -Oorder-file --no-prompt --tool myecho >output &&
664
+ git grep --no-index -h -A2 Merging: output >actual &&
665
+ test_cmp expect actual &&
666
+ git reset --hard >/dev/null 2>&1
667
+'
668
669
test_done