Skip to content

Commit 88d3406

Browse files
davvidgitster
authored andcommitted
mergetool--lib: improve show_tool_help() output
Check the can_diff and can_merge functions before deciding whether to add the tool to the available/unavailable lists. This makes "--tool-help" context-sensitive so that "git mergetool --tool-help" displays merge tools only and "git difftool --tool-help" displays diff tools only. Signed-off-by: David Aguilar <davvid@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
1 parent b2a6b71 commit 88d3406

File tree

1 file changed

+21
-5
lines changed

1 file changed

+21
-5
lines changed

git-mergetool--lib.sh

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -175,17 +175,33 @@ list_merge_tool_candidates () {
175175
}
176176

177177
show_tool_help () {
178-
list_merge_tool_candidates
179178
unavailable= available= LF='
180179
'
181-
for i in $tools
180+
181+
scriptlets="$(git --exec-path)"/mergetools
182+
for i in "$scriptlets"/*
182183
do
183-
merge_tool_path=$(translate_merge_tool_path "$i")
184+
. "$scriptlets"/defaults
185+
. "$i"
186+
187+
tool="$(basename "$i")"
188+
if test "$tool" = "defaults"
189+
then
190+
continue
191+
elif merge_mode && ! can_merge
192+
then
193+
continue
194+
elif diff_mode && ! can_diff
195+
then
196+
continue
197+
fi
198+
199+
merge_tool_path=$(translate_merge_tool_path "$tool")
184200
if type "$merge_tool_path" >/dev/null 2>&1
185201
then
186-
available="$available$i$LF"
202+
available="$available$tool$LF"
187203
else
188-
unavailable="$unavailable$i$LF"
204+
unavailable="$unavailable$tool$LF"
189205
fi
190206
done
191207

0 commit comments

Comments
 (0)