@@ -19,9 +19,24 @@ is_available () {
1919 type " $merge_tool_path " > /dev/null 2>&1
2020}
2121
22+ list_config_tools () {
23+ section=$1
24+ line_prefix=${2:- }
25+
26+ git config --get-regexp $section ' \..*\.cmd' |
27+ while read -r key value
28+ do
29+ toolname=${key# $section .}
30+ toolname=${toolname% .cmd}
31+
32+ printf " %s%s\n" " $line_prefix " " $toolname "
33+ done
34+ }
35+
2236show_tool_names () {
2337 condition=${1:- true} per_line_prefix=${2:- } preamble=${3:- }
2438 not_found_msg=${4:- }
39+ extra_content=${5:- }
2540
2641 shown_any=
2742 ( cd " $MERGE_TOOLS_DIR " && ls ) | {
@@ -40,6 +55,19 @@ show_tool_names () {
4055 fi
4156 done
4257
58+ if test -n " $extra_content "
59+ then
60+ if test -n " $preamble "
61+ then
62+ # Note: no '\n' here since we don't want a
63+ # blank line if there is no initial content.
64+ printf " %s" " $preamble "
65+ preamble=
66+ fi
67+ shown_any=yes
68+ printf " \n%s\n" " $extra_content "
69+ fi
70+
4371 if test -n " $preamble " && test -n " $not_found_msg "
4472 then
4573 printf " %s\n" " $not_found_msg "
@@ -254,9 +282,20 @@ show_tool_help () {
254282 any_shown=no
255283
256284 cmd_name=${TOOL_MODE} tool
285+ config_tools=$( {
286+ diff_mode && list_config_tools difftool " $tab$tab "
287+ list_config_tools mergetool " $tab$tab "
288+ } | sort)
289+ extra_content=
290+ if test -n " $config_tools "
291+ then
292+ extra_content=" ${tab} user-defined:${LF} $config_tools "
293+ fi
294+
257295 show_tool_names ' mode_ok && is_available' " $tab$tab " \
258296 " $tool_opt may be set to one of the following:" \
259- " No suitable tool for 'git $cmd_name --tool=<tool>' found." &&
297+ " No suitable tool for 'git $cmd_name --tool=<tool>' found." \
298+ " $extra_content " &&
260299 any_shown=yes
261300
262301 show_tool_names ' mode_ok && ! is_available' " $tab$tab " \
0 commit comments