Merge branch 'pb/mergetool-errors'
End-user experience of "git mergetool" when the command errors out has been improved. * pb/mergetool-errors: git-difftool--helper.sh: exit upon initialize_merge_tool errors git-mergetool--lib.sh: add error message for unknown tool variant git-mergetool--lib.sh: add error message if 'setup_user_tool' fails git-mergetool--lib.sh: use TOOL_MODE when erroring about unknown tool completion: complete '--tool-help' in 'git mergetool'
This commit is contained in:
@ -2331,7 +2331,7 @@ _git_mergetool ()
|
|||||||
return
|
return
|
||||||
;;
|
;;
|
||||||
--*)
|
--*)
|
||||||
__gitcomp "--tool= --prompt --no-prompt --gui --no-gui"
|
__gitcomp "--tool= --tool-help --prompt --no-prompt --gui --no-gui"
|
||||||
return
|
return
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
@ -61,9 +61,7 @@ launch_merge_tool () {
|
|||||||
export BASE
|
export BASE
|
||||||
eval $GIT_DIFFTOOL_EXTCMD '"$LOCAL"' '"$REMOTE"'
|
eval $GIT_DIFFTOOL_EXTCMD '"$LOCAL"' '"$REMOTE"'
|
||||||
else
|
else
|
||||||
initialize_merge_tool "$merge_tool"
|
initialize_merge_tool "$merge_tool" || exit 1
|
||||||
# ignore the error from the above --- run_merge_tool
|
|
||||||
# will diagnose unusable tool by itself
|
|
||||||
run_merge_tool "$merge_tool"
|
run_merge_tool "$merge_tool"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
@ -87,9 +85,7 @@ if test -n "$GIT_DIFFTOOL_DIRDIFF"
|
|||||||
then
|
then
|
||||||
LOCAL="$1"
|
LOCAL="$1"
|
||||||
REMOTE="$2"
|
REMOTE="$2"
|
||||||
initialize_merge_tool "$merge_tool"
|
initialize_merge_tool "$merge_tool" || exit 1
|
||||||
# ignore the error from the above --- run_merge_tool
|
|
||||||
# will diagnose unusable tool by itself
|
|
||||||
run_merge_tool "$merge_tool" false
|
run_merge_tool "$merge_tool" false
|
||||||
|
|
||||||
status=$?
|
status=$?
|
||||||
|
@ -159,7 +159,7 @@ check_unchanged () {
|
|||||||
}
|
}
|
||||||
|
|
||||||
valid_tool () {
|
valid_tool () {
|
||||||
setup_tool "$1" && return 0
|
setup_tool "$1" 2>/dev/null && return 0
|
||||||
cmd=$(get_merge_tool_cmd "$1")
|
cmd=$(get_merge_tool_cmd "$1")
|
||||||
test -n "$cmd"
|
test -n "$cmd"
|
||||||
}
|
}
|
||||||
@ -250,7 +250,12 @@ setup_tool () {
|
|||||||
. "$MERGE_TOOLS_DIR/${tool%[0-9]}"
|
. "$MERGE_TOOLS_DIR/${tool%[0-9]}"
|
||||||
else
|
else
|
||||||
setup_user_tool
|
setup_user_tool
|
||||||
return $?
|
rc=$?
|
||||||
|
if test $rc -ne 0
|
||||||
|
then
|
||||||
|
echo >&2 "error: ${TOOL_MODE}tool.$tool.cmd not set for tool '$tool'"
|
||||||
|
fi
|
||||||
|
return $rc
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Now let the user override the default command for the tool. If
|
# Now let the user override the default command for the tool. If
|
||||||
@ -259,6 +264,7 @@ setup_tool () {
|
|||||||
|
|
||||||
if ! list_tool_variants | grep -q "^$tool$"
|
if ! list_tool_variants | grep -q "^$tool$"
|
||||||
then
|
then
|
||||||
|
echo "error: unknown tool variant '$tool'" >&2
|
||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@ -474,7 +480,7 @@ get_merge_tool_path () {
|
|||||||
merge_tool="$1"
|
merge_tool="$1"
|
||||||
if ! valid_tool "$merge_tool"
|
if ! valid_tool "$merge_tool"
|
||||||
then
|
then
|
||||||
echo >&2 "Unknown merge tool $merge_tool"
|
echo >&2 "Unknown $TOOL_MODE tool $merge_tool"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
if diff_mode
|
if diff_mode
|
||||||
|
@ -898,4 +898,12 @@ test_expect_success 'mergetool with guiDefault' '
|
|||||||
git commit -m "branch1 resolved with mergetool"
|
git commit -m "branch1 resolved with mergetool"
|
||||||
'
|
'
|
||||||
|
|
||||||
|
test_expect_success 'mergetool with non-existent tool' '
|
||||||
|
test_when_finished "git reset --hard" &&
|
||||||
|
git checkout -b test$test_count branch1 &&
|
||||||
|
test_must_fail git merge main &&
|
||||||
|
yes "" | test_must_fail git mergetool --tool=absent >out 2>&1 &&
|
||||||
|
test_grep "mergetool.absent.cmd not set for tool" out
|
||||||
|
'
|
||||||
|
|
||||||
test_done
|
test_done
|
||||||
|
Reference in New Issue
Block a user