mirror of
https://github.com/git/git.git
synced 2026-01-09 17:46:37 +00:00
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>
This commit is contained in:
committed by
Junio C Hamano
parent
b2a6b7122e
commit
88d3406ad7
@@ -175,17 +175,33 @@ list_merge_tool_candidates () {
|
|||||||
}
|
}
|
||||||
|
|
||||||
show_tool_help () {
|
show_tool_help () {
|
||||||
list_merge_tool_candidates
|
|
||||||
unavailable= available= LF='
|
unavailable= available= LF='
|
||||||
'
|
'
|
||||||
for i in $tools
|
|
||||||
|
scriptlets="$(git --exec-path)"/mergetools
|
||||||
|
for i in "$scriptlets"/*
|
||||||
do
|
do
|
||||||
merge_tool_path=$(translate_merge_tool_path "$i")
|
. "$scriptlets"/defaults
|
||||||
|
. "$i"
|
||||||
|
|
||||||
|
tool="$(basename "$i")"
|
||||||
|
if test "$tool" = "defaults"
|
||||||
|
then
|
||||||
|
continue
|
||||||
|
elif merge_mode && ! can_merge
|
||||||
|
then
|
||||||
|
continue
|
||||||
|
elif diff_mode && ! can_diff
|
||||||
|
then
|
||||||
|
continue
|
||||||
|
fi
|
||||||
|
|
||||||
|
merge_tool_path=$(translate_merge_tool_path "$tool")
|
||||||
if type "$merge_tool_path" >/dev/null 2>&1
|
if type "$merge_tool_path" >/dev/null 2>&1
|
||||||
then
|
then
|
||||||
available="$available$i$LF"
|
available="$available$tool$LF"
|
||||||
else
|
else
|
||||||
unavailable="$unavailable$i$LF"
|
unavailable="$unavailable$tool$LF"
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user