mergetool--lib: simplify guess_merge_tool()
Use a case statement instead of calling grep to find out if the editor's name contains the string "vim". Remove the check for emacs, as this branch did the same as the default one anyway. Signed-off-by: Rene Scharfe <rene.scharfe@lsrfire.ath.cx> Signed-off-by: Junio C Hamano <gitster@pobox.com>
René Scharfe committed
Nov 24, 2009 at 00:29 UTC
7b1042292d5dc18508213c3be888b740d02f02e3
1 file changed
+6
-7
git-mergetool--lib.sh
+6
-7
@@ -325,15 +325,14 @@ guess_merge_tool () {
325
fi
326
tools="$tools gvimdiff diffuse ecmerge araxis"
327
fi
328
- if echo "${VISUAL:-$EDITOR}" | grep emacs > /dev/null 2>&1; then
329
- # $EDITOR is emacs so add emerge as a candidate
330
- tools="$tools emerge vimdiff"
331
- elif echo "${VISUAL:-$EDITOR}" | grep vim > /dev/null 2>&1; then
332
- # $EDITOR is vim so add vimdiff as a candidate
328
+ case "${VISUAL:-$EDITOR}" in
329
+ *vim*)
330
tools="$tools vimdiff emerge"
334
- else
331
+ ;;
332
+ *)
333
tools="$tools emerge vimdiff"
336
- fi
334
+ ;;
335
+ esac
336
echo >&2 "merge tool candidates: $tools"
337
338
# Loop over each candidate and stop when a valid merge tool is found.