git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH] mergetool--lib: simplify guess_merge_tool()

From
René Scharfe <rene.scharfe@lsrfire.ath.cx>
Date
Nov 23, 2009, 23:29 UTC
Message-ID
<4B0B1ACD.6000008@lsrfire.ath.cx>
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
Previous: René ScharfeNext: David Aguilar
Message 7 of 12 in “unset GREP_OPTIONS in test-lib.sh”
  1. unset GREP_OPTIONS in test-lib.shBert Wesarg, Nov 18, 2009
  2. Junio C HamanoNov 18, 2009
  3. René ScharfeNov 22, 2009
  4. Carlo Marcelo Arenas BelonNov 23, 2009
  5. Junio C HamanoNov 23, 2009
  6. René ScharfeNov 23, 2009
  7. mergetool--lib: simplify guess_merge_tool()René Scharfe, Nov 23, 2009
  8. David AguilarNov 27, 2009
  9. Junio C HamanoNov 23, 2009
  10. René ScharfeNov 23, 2009
  11. Junio C HamanoNov 24, 2009
  12. Bert WesargMar 7, 2010

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.