Skip to content

Commit 7b10422

Browse files
René Scharfegitster
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 78d553b commit 7b10422

File tree

1 file changed

+6
-7
lines changed

1 file changed

+6
-7
lines changed

git-mergetool--lib.sh

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -325,15 +325,14 @@ guess_merge_tool () {
325325
fi
326326
tools="$tools gvimdiff diffuse ecmerge araxis"
327327
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*)
333330
tools="$tools vimdiff emerge"
334-
else
331+
;;
332+
*)
335333
tools="$tools emerge vimdiff"
336-
fi
334+
;;
335+
esac
337336
echo >&2 "merge tool candidates: $tools"
338337

339338
# Loop over each candidate and stop when a valid merge tool is found.

0 commit comments

Comments
 (0)