git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "René Scharfe" <rene.scharfe@lsrfire.ath.cx>
To: Junio C Hamano <gitster@pobox.com>
Cc: Carlo Marcelo Arenas Belon <carenas@sajinet.com.pe>,
	Bert Wesarg <bert.wesarg@googlemail.com>,
	git@vger.kernel.org
Subject: [PATCH] mergetool--lib: simplify guess_merge_tool()
Date: Tue, 24 Nov 2009 00:29:17 +0100	[thread overview]
Message-ID: <4B0B1ACD.6000008@lsrfire.ath.cx> (raw)
In-Reply-To: <4B0B185B.4090305@lsrfire.ath.cx>

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>
---
This removes all grep calls from this script.

 git-mergetool--lib.sh |   13 ++++++-------
 1 files changed, 6 insertions(+), 7 deletions(-)

diff --git a/git-mergetool--lib.sh b/git-mergetool--lib.sh
index f7c571e..5b62785 100644
--- a/git-mergetool--lib.sh
+++ b/git-mergetool--lib.sh
@@ -338,15 +338,14 @@ guess_merge_tool () {
 		fi
 		tools="$tools gvimdiff diffuse ecmerge p4merge araxis"
 	fi
-	if echo "${VISUAL:-$EDITOR}" | grep emacs > /dev/null 2>&1; then
-		# $EDITOR is emacs so add emerge as a candidate
-		tools="$tools emerge vimdiff"
-	elif echo "${VISUAL:-$EDITOR}" | grep vim > /dev/null 2>&1; then
-		# $EDITOR is vim so add vimdiff as a candidate
+	case "${VISUAL:-$EDITOR}" in
+	*vim*)
 		tools="$tools vimdiff emerge"
-	else
+		;;
+	*)
 		tools="$tools emerge vimdiff"
-	fi
+		;;
+	esac
 	echo >&2 "merge tool candidates: $tools"
 
 	# Loop over each candidate and stop when a valid merge tool is found.
-- 
1.6.5

  reply	other threads:[~2009-11-23 23:29 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-11-18 16:15 [PATCH] unset GREP_OPTIONS in test-lib.sh Bert Wesarg
2009-11-18 22:05 ` Junio C Hamano
2009-11-22 15:58   ` René Scharfe
2009-11-23 11:22     ` Carlo Marcelo Arenas Belon
2009-11-23 18:27       ` Junio C Hamano
2009-11-23 23:18         ` René Scharfe
2009-11-23 23:29           ` René Scharfe [this message]
2009-11-27  3:22             ` [PATCH] mergetool--lib: simplify guess_merge_tool() David Aguilar
2009-11-23 23:52           ` [PATCH] unset GREP_OPTIONS in test-lib.sh Junio C Hamano
2009-11-23 23:59             ` René Scharfe
2009-11-24  0:35               ` Junio C Hamano
2010-03-07 10:30   ` Bert Wesarg

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4B0B1ACD.6000008@lsrfire.ath.cx \
    --to=rene.scharfe@lsrfire.ath.cx \
    --cc=bert.wesarg@googlemail.com \
    --cc=carenas@sajinet.com.pe \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).