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>
David Aguilar committed
Jan 25, 2013 at 01:43 UTC
88d3406ad77dbab4d8ea76756822531228332b1b
1 file changed
+21
-5
git-mergetool--lib.sh
+21
-5
@@ -175,17 +175,33 @@ list_merge_tool_candidates () {
175
}
176
177
show_tool_help () {
178
- list_merge_tool_candidates
178
unavailable= available= LF='
179
'
181
- for i in $tools
180
+
181
+ scriptlets="$(git --exec-path)"/mergetools
182
+ for i in "$scriptlets"/*
183
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")
200
if type "$merge_tool_path" >/dev/null 2>&1
201
then
186
- available="$available$i$LF"
202
+ available="$available$tool$LF"
203
else
188
- unavailable="$unavailable$i$LF"
204
+ unavailable="$unavailable$tool$LF"
205
fi
206
done
207