From: John Keeping <john@keeping.me.uk>
To: Junio C Hamano <gitster@pobox.com>
Cc: David Aguilar <davvid@gmail.com>, git@vger.kernel.org
Subject: [PATCH 1/2 v3] mergetool--lib: don't call "exit" in setup_tool
Date: Sat, 26 Jan 2013 13:50:23 +0000 [thread overview]
Message-ID: <20130126135023.GJ7498@serenity.lan> (raw)
In-Reply-To: <20130126121721.GI7498@serenity.lan>
This will make it easier to use setup_tool in places where we expect
that the selected tool will not support the current mode.
We need to introduce a new return code for setup_tool to differentiate
between the case of "the selected tool is invalid" and "the selected
tool is not a built-in" since we must call setup_tool when a custom
'merge.<tool>.path' is configured for a built-in tool but avoid failing
when the configured tool is not a built-in.
Signed-off-by: John Keeping <john@keeping.me.uk>
---
> On Fri, Jan 25, 2013 at 04:24:03PM -0800, Junio C Hamano wrote:
> > Applying this one on top of 1/7 thru 5/7 and 7/7 seems to break
> > t7610 rather badly.
>
> Sorry about that. The 'setup_tool' function should really be called
> 'setup_builtin_tool' - it isn't necessary when a custom mergetool is
> configured and will return 1 when called with an argument that isn't a
> builtin tool from $GIT_EXEC_PATH/mergetools.
>
> The change is the second hunk below which now wraps the call to
> setup_tool in an if block as well as adding the "|| return".
Now that I've run the entire test suite, that still wasn't correct since
it did not correctly handle the case where the user overrides the path
for one of the built-in mergetools.
git-mergetool--lib.sh | 23 ++++++++++++++++++++---
1 file changed, 20 insertions(+), 3 deletions(-)
diff --git a/git-mergetool--lib.sh b/git-mergetool--lib.sh
index 4c1e129..dd4f088 100644
--- a/git-mergetool--lib.sh
+++ b/git-mergetool--lib.sh
@@ -58,7 +58,11 @@ setup_tool () {
. "$mergetools/defaults"
if ! test -f "$mergetools/$tool"
then
- return 1
+ # Use a special return code for this case since we want to
+ # source "defaults" even when an explicit tool path is
+ # configured since the user can use that to override the
+ # default path in the scriptlet.
+ return 2
fi
# Load the redefined functions
@@ -67,11 +71,11 @@ setup_tool () {
if merge_mode && ! can_merge
then
echo "error: '$tool' can not be used to resolve merges" >&2
- exit 1
+ return 1
elif diff_mode && ! can_diff
then
echo "error: '$tool' can only be used to resolve merges" >&2
- exit 1
+ return 1
fi
return 0
}
@@ -101,6 +105,19 @@ run_merge_tool () {
# Bring tool-specific functions into scope
setup_tool "$1"
+ exitcode=$?
+ case $exitcode in
+ 0)
+ :
+ ;;
+ 2)
+ # The configured tool is not a built-in tool.
+ test -n "$merge_tool_path" || return 1
+ ;;
+ *)
+ return $exitcode
+ ;;
+ esac
if merge_mode
then
--
1.8.1
next prev parent reply other threads:[~2013-01-26 13:59 UTC|newest]
Thread overview: 30+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-01-25 9:43 [PATCH 0/7] mergetool-lib improvements for --tool-help David Aguilar
2013-01-25 9:43 ` [PATCH 1/7] git-mergetool: move show_tool_help to mergetool--lib David Aguilar
2013-01-25 9:43 ` [PATCH 2/7] git-mergetool: remove redundant assignment David Aguilar
2013-01-25 9:43 ` [PATCH 3/7] git-mergetool: don't hardcode 'mergetool' in show_tool_help David Aguilar
2013-01-25 9:43 ` [PATCH 4/7] git-difftool: use git-mergetool--lib for "--tool-help" David Aguilar
2013-01-25 9:43 ` [PATCH 5/7] mergetools/vim: Remove redundant diff command David Aguilar
2013-01-25 9:43 ` [PATCH 6/7] mergetools: Fix difftool/mergetool --tool-help listing for vim David Aguilar
2013-01-25 10:23 ` Sebastian Schuberth
2013-01-25 10:28 ` David Aguilar
2013-01-25 10:34 ` Sebastian Schuberth
2013-01-25 11:39 ` Sebastian Schuberth
2013-01-25 10:38 ` John Keeping
2013-01-25 10:40 ` David Aguilar
2013-01-25 19:11 ` Junio C Hamano
2013-01-25 9:43 ` [PATCH 7/7] mergetool--lib: Improve show_tool_help() output David Aguilar
2013-01-25 19:54 ` John Keeping
2013-01-25 20:06 ` Junio C Hamano
2013-01-25 20:08 ` John Keeping
2013-01-25 20:16 ` Junio C Hamano
2013-01-25 20:46 ` John Keeping
2013-01-25 20:56 ` Junio C Hamano
2013-01-25 21:16 ` John Keeping
2013-01-25 21:47 ` Junio C Hamano
2013-01-25 22:02 ` John Keeping
2013-01-25 22:03 ` [PATCH 8/7] mergetool--lib: don't call "exit" in setup_tool John Keeping
2013-01-26 0:24 ` Junio C Hamano
2013-01-26 7:01 ` David Aguilar
2013-01-26 12:17 ` [PATCH 1/2 v2] " John Keeping
2013-01-26 13:50 ` John Keeping [this message]
2013-01-25 22:04 ` [PATCH 9/7] mergetool--lib: fix path lookup in guess_merge_tool John Keeping
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
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20130126135023.GJ7498@serenity.lan \
--to=john@keeping.me.uk \
--cc=davvid@gmail.com \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.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.
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 NNTP newsgroup(s).