mergetool--lib: don't call "exit" in setup_tool
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> Signed-off-by: David Aguilar <davvid@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
parent
88d3406ad7
commit
62957bea0c
@ -58,7 +58,11 @@ setup_tool () {
|
|||||||
. "$mergetools/defaults"
|
. "$mergetools/defaults"
|
||||||
if ! test -f "$mergetools/$tool"
|
if ! test -f "$mergetools/$tool"
|
||||||
then
|
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
|
fi
|
||||||
|
|
||||||
# Load the redefined functions
|
# Load the redefined functions
|
||||||
@ -67,11 +71,11 @@ setup_tool () {
|
|||||||
if merge_mode && ! can_merge
|
if merge_mode && ! can_merge
|
||||||
then
|
then
|
||||||
echo "error: '$tool' can not be used to resolve merges" >&2
|
echo "error: '$tool' can not be used to resolve merges" >&2
|
||||||
exit 1
|
return 1
|
||||||
elif diff_mode && ! can_diff
|
elif diff_mode && ! can_diff
|
||||||
then
|
then
|
||||||
echo "error: '$tool' can only be used to resolve merges" >&2
|
echo "error: '$tool' can only be used to resolve merges" >&2
|
||||||
exit 1
|
return 1
|
||||||
fi
|
fi
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
@ -101,6 +105,19 @@ run_merge_tool () {
|
|||||||
|
|
||||||
# Bring tool-specific functions into scope
|
# Bring tool-specific functions into scope
|
||||||
setup_tool "$1"
|
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
|
if merge_mode
|
||||||
then
|
then
|
||||||
|
Loading…
Reference in New Issue
Block a user