git-mergetool: move show_tool_help to mergetool--lib

This is the first step in unifying "git difftool --tool-help" and "git mergetool --tool-help". Signed-off-by: John Keeping <john@keeping.me.uk> Signed-off-by: David Aguilar <davvid@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

John Keeping committed Jan 25, 2013 at 01:43 UTC 4a8273a3ed1d9db48920433471f87090423d1b5e
2 files changed +37 -37
git-mergetool--lib.sh
+37
@@ -174,6 +174,43 @@ list_merge_tool_candidates () {
174 esac
175 }
176
177 +show_tool_help () {
178 + TOOL_MODE=merge
179 + list_merge_tool_candidates
180 + unavailable= available= LF='
181 +'
182 + for i in $tools
183 + do
184 + merge_tool_path=$(translate_merge_tool_path "$i")
185 + if type "$merge_tool_path" >/dev/null 2>&1
186 + then
187 + available="$available$i$LF"
188 + else
189 + unavailable="$unavailable$i$LF"
190 + fi
191 + done
192 + if test -n "$available"
193 + then
194 + echo "'git mergetool --tool=<tool>' may be set to one of the following:"
195 + echo "$available" | sort | sed -e 's/^/ /'
196 + else
197 + echo "No suitable tool for 'git mergetool --tool=<tool>' found."
198 + fi
199 + if test -n "$unavailable"
200 + then
201 + echo
202 + echo 'The following tools are valid, but not currently available:'
203 + echo "$unavailable" | sort | sed -e 's/^/ /'
204 + fi
205 + if test -n "$unavailable$available"
206 + then
207 + echo
208 + echo "Some of the tools listed above only work in a windowed"
209 + echo "environment. If run in a terminal-only session, they will fail."
210 + fi
211 + exit 0
212 +}
213 +
214 guess_merge_tool () {
215 list_merge_tool_candidates
216 echo >&2 "merge tool candidates: $tools"
git-mergetool.sh
-37
@@ -315,43 +315,6 @@ merge_file () {
315 return 0
316 }
317
318 -show_tool_help () {
319 - TOOL_MODE=merge
320 - list_merge_tool_candidates
321 - unavailable= available= LF='
322 -'
323 - for i in $tools
324 - do
325 - merge_tool_path=$(translate_merge_tool_path "$i")
326 - if type "$merge_tool_path" >/dev/null 2>&1
327 - then
328 - available="$available$i$LF"
329 - else
330 - unavailable="$unavailable$i$LF"
331 - fi
332 - done
333 - if test -n "$available"
334 - then
335 - echo "'git mergetool --tool=<tool>' may be set to one of the following:"
336 - echo "$available" | sort | sed -e 's/^/ /'
337 - else
338 - echo "No suitable tool for 'git mergetool --tool=<tool>' found."
339 - fi
340 - if test -n "$unavailable"
341 - then
342 - echo
343 - echo 'The following tools are valid, but not currently available:'
344 - echo "$unavailable" | sort | sed -e 's/^/ /'
345 - fi
346 - if test -n "$unavailable$available"
347 - then
348 - echo
349 - echo "Some of the tools listed above only work in a windowed"
350 - echo "environment. If run in a terminal-only session, they will fail."
351 - fi
352 - exit 0
353 -}
354 -
318 prompt=$(git config --bool mergetool.prompt || echo true)
319
320 while test $# != 0