Skip to content

Commit

Permalink
mergetool--lib: improve show_tool_help() output
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
David Aguilar authored and Junio C Hamano committed Jan 28, 2013
1 parent b2a6b71 commit 88d3406
Showing 1 changed file with 21 additions and 5 deletions.
26 changes: 21 additions & 5 deletions git-mergetool--lib.sh
Original file line number Diff line number Diff line change
Expand Up @@ -175,17 +175,33 @@ list_merge_tool_candidates () {
}

show_tool_help () {
list_merge_tool_candidates
unavailable= available= LF='
'
for i in $tools

scriptlets="$(git --exec-path)"/mergetools
for i in "$scriptlets"/*
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
then
available="$available$i$LF"
available="$available$tool$LF"
else
unavailable="$unavailable$i$LF"
unavailable="$unavailable$tool$LF"
fi
done

Expand Down

0 comments on commit 88d3406

Please sign in to comment.