File tree Expand file tree Collapse file tree 4 files changed +20
-10
lines changed Expand file tree Collapse file tree 4 files changed +20
-10
lines changed Original file line number Diff line number Diff line change @@ -2331,7 +2331,7 @@ _git_mergetool ()
23312331 return
23322332 ;;
23332333 --* )
2334- __gitcomp " --tool= --prompt --no-prompt --gui --no-gui"
2334+ __gitcomp " --tool= --tool-help -- prompt --no-prompt --gui --no-gui"
23352335 return
23362336 ;;
23372337 esac
Original file line number Diff line number Diff line change @@ -61,9 +61,7 @@ launch_merge_tool () {
6161 export BASE
6262 eval $GIT_DIFFTOOL_EXTCMD ' "$LOCAL"' ' "$REMOTE"'
6363 else
64- initialize_merge_tool " $merge_tool "
65- # ignore the error from the above --- run_merge_tool
66- # will diagnose unusable tool by itself
64+ initialize_merge_tool " $merge_tool " || exit 1
6765 run_merge_tool " $merge_tool "
6866 fi
6967}
@@ -87,9 +85,7 @@ if test -n "$GIT_DIFFTOOL_DIRDIFF"
8785then
8886 LOCAL=" $1 "
8987 REMOTE=" $2 "
90- initialize_merge_tool " $merge_tool "
91- # ignore the error from the above --- run_merge_tool
92- # will diagnose unusable tool by itself
88+ initialize_merge_tool " $merge_tool " || exit 1
9389 run_merge_tool " $merge_tool " false
9490
9591 status=$?
Original file line number Diff line number Diff line change @@ -159,7 +159,7 @@ check_unchanged () {
159159}
160160
161161valid_tool () {
162- setup_tool " $1 " && return 0
162+ setup_tool " $1 " 2> /dev/null && return 0
163163 cmd=$( get_merge_tool_cmd " $1 " )
164164 test -n " $cmd "
165165}
@@ -250,7 +250,12 @@ setup_tool () {
250250 . " $MERGE_TOOLS_DIR /${tool% [0-9]} "
251251 else
252252 setup_user_tool
253- return $?
253+ rc=$?
254+ if test $rc -ne 0
255+ then
256+ echo >&2 " error: ${TOOL_MODE} tool.$tool .cmd not set for tool '$tool '"
257+ fi
258+ return $rc
254259 fi
255260
256261 # Now let the user override the default command for the tool. If
@@ -259,6 +264,7 @@ setup_tool () {
259264
260265 if ! list_tool_variants | grep -q " ^$tool $"
261266 then
267+ echo " error: unknown tool variant '$tool '" >&2
262268 return 1
263269 fi
264270
@@ -474,7 +480,7 @@ get_merge_tool_path () {
474480 merge_tool=" $1 "
475481 if ! valid_tool " $merge_tool "
476482 then
477- echo >&2 " Unknown merge tool $merge_tool "
483+ echo >&2 " Unknown $TOOL_MODE tool $merge_tool "
478484 exit 1
479485 fi
480486 if diff_mode
Original file line number Diff line number Diff line change @@ -898,4 +898,12 @@ test_expect_success 'mergetool with guiDefault' '
898898 git commit -m "branch1 resolved with mergetool"
899899'
900900
901+ test_expect_success ' mergetool with non-existent tool' '
902+ test_when_finished "git reset --hard" &&
903+ git checkout -b test$test_count branch1 &&
904+ test_must_fail git merge main &&
905+ yes "" | test_must_fail git mergetool --tool=absent >out 2>&1 &&
906+ test_grep "mergetool.absent.cmd not set for tool" out
907+ '
908+
901909test_done
You can’t perform that action at this time.
0 commit comments