diff options
author | David Aguilar <davvid@gmail.com> | 2013-01-25 01:43:54 -0800 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2013-01-27 18:32:54 -0800 |
commit | 88d3406ad77dbab4d8ea76756822531228332b1b (patch) | |
tree | 3bf91cdbb31b5f27312402c005854fd4c0fbbf01 /git-mergetool--lib.sh | |
parent | b2a6b7122e66d4882ef5ac31e3a03969b5b6a199 (diff) | |
download | git-88d3406ad77dbab4d8ea76756822531228332b1b.tar.gz |
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>
Diffstat (limited to 'git-mergetool--lib.sh')
-rw-r--r-- | git-mergetool--lib.sh | 26 |
1 files changed, 21 insertions, 5 deletions
diff --git a/git-mergetool--lib.sh b/git-mergetool--lib.sh index 4c1e1292a6..aa38bd18bf 100644 --- a/git-mergetool--lib.sh +++ b/git-mergetool--lib.sh @@ -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 |