From: David Aguilar <davvid@gmail.com>
To: Git Mailing List <git@vger.kernel.org>
Cc: Junio C Hamano <gitster@pobox.com>, Johannes Sixt <j6t@kdbg.org>,
Luis Gutierrez <luisgutz@gmail.com>
Subject: [PATCH 4/4] mergetool: honor -O<order-file>
Date: Thu, 6 Oct 2016 16:47:59 -0700 [thread overview]
Message-ID: <1475797679-32712-4-git-send-email-davvid@gmail.com> (raw)
In-Reply-To: <1475797679-32712-1-git-send-email-davvid@gmail.com>
Teach mergetool to pass "-O<order-file>" down to `git diff` when
specified on the command-line.
Signed-off-by: David Aguilar <davvid@gmail.com>
---
Documentation/git-mergetool.txt | 10 ++++++----
git-mergetool.sh | 14 ++++++++++++--
t/t7610-mergetool.sh | 27 +++++++++++++++++++++++++++
3 files changed, 45 insertions(+), 6 deletions(-)
diff --git a/Documentation/git-mergetool.txt b/Documentation/git-mergetool.txt
index c4c1a9b..3622d66 100644
--- a/Documentation/git-mergetool.txt
+++ b/Documentation/git-mergetool.txt
@@ -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
---------------
diff --git a/git-mergetool.sh b/git-mergetool.sh
index 65696d8..9dca58b 100755
--- a/git-mergetool.sh
+++ b/git-mergetool.sh
@@ -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<order-file>] [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
+ order_file=
while test $# != 0
do
@@ -419,6 +420,9 @@ main () {
--prompt)
prompt=true
;;
+ -O*)
+ order_file="$1"
+ ;;
--)
shift
break
@@ -459,8 +463,14 @@ main () {
fi
fi
+ if test -n "$order_file"
+ then
+ set -- "$order_file" -- "$@"
+ else
+ set -- -- "$@"
+ fi
files=$(git -c core.quotePath=false \
- diff --name-only --diff-filter=U -- "$@")
+ diff --name-only --diff-filter=U "$@")
cd_to_toplevel
diff --git a/t/t7610-mergetool.sh b/t/t7610-mergetool.sh
index fb2aeef..0f9869a 100755
--- a/t/t7610-mergetool.sh
+++ b/t/t7610-mergetool.sh
@@ -637,6 +637,33 @@ 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 |
+ grep -A 2 Merging: >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 |
+ grep -A 2 Merging: >actual &&
+ test_cmp expect actual &&
+ git reset --hard >/dev/null 2>&1
'
test_done
--
2.10.1.355.g33afd83.dirty
next prev parent reply other threads:[~2016-10-06 23:48 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-10-06 23:47 [PATCH 1/4] mergetool: add copyright David Aguilar
2016-10-06 23:47 ` [PATCH 2/4] mergetool: move main program flow into a main() function David Aguilar
2016-10-07 5:51 ` Johannes Sixt
2016-10-06 23:47 ` [PATCH 3/4] mergetool: honor diff.orderFile David Aguilar
2016-10-07 17:08 ` Johannes Sixt
2016-10-06 23:47 ` David Aguilar [this message]
2016-10-07 17:16 ` [PATCH 4/4] mergetool: honor -O<order-file> Johannes Sixt
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: http://vger.kernel.org/majordomo-info.html
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1475797679-32712-4-git-send-email-davvid@gmail.com \
--to=davvid@gmail.com \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=j6t@kdbg.org \
--cc=luisgutz@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://80x24.org/mirrors/git.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).