git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] git-mergetool: Make default smarter by considering user's desktop environment and editor
@ 2007-06-06  4:28 Josh Triplett
  2007-06-06  8:08 ` Junio C Hamano
  0 siblings, 1 reply; 6+ messages in thread
From: Josh Triplett @ 2007-06-06  4:28 UTC (permalink / raw)
  To: git

[-- Attachment #1: Type: text/plain, Size: 1985 bytes --]

Make git-mergetool prefer meld under GNOME, and kdiff3 under KDE.  When
considering emerge and vimdiff, check $VISUAL and $EDITOR to see which the
user might prefer.

Signed-off-by: Josh Triplett <josh@freedesktop.org>
---

Arguably, kdiff3 should now move down next to meld, below the other
non-graphical tools, so that if the user doesn't run KDE or GNOME they get a
non-KDE, non-GNOME tool.  This patch doesn't do that, though.

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

diff --git a/git-mergetool.sh b/git-mergetool.sh
index bb21b03..2053d43 100755
--- a/git-mergetool.sh
+++ b/git-mergetool.sh
@@ -304,7 +304,13 @@ if test -z "$merge_tool"; then
 fi
 
 if test -z "$merge_tool" ; then
-    if type kdiff3 >/dev/null 2>&1 && test -n "$DISPLAY"; then
+    # Try tools that match the user's desktop environment
+    if test x"$KDE_FULL_SESSION" = x"true" && type kdiff3 >/dev/null 2>&1 && test -n "$DISPLAY"; then
+        merge_tool="kdiff3";
+    elif test x"$GNOME_DESKTOP_SESSION_ID" != x"" && type meld >/dev/null 2>&1 && test -n "$DISPLAY"; then
+        merge_tool=meld
+    # Try any graphical tool
+    elif type kdiff3 >/dev/null 2>&1 && test -n "$DISPLAY"; then
 	merge_tool="kdiff3";
     elif type tkdiff >/dev/null 2>&1 && test -n "$DISPLAY"; then
 	merge_tool=tkdiff
@@ -312,6 +318,12 @@ if test -z "$merge_tool" ; then
 	merge_tool=xxdiff
     elif type meld >/dev/null 2>&1 && test -n "$DISPLAY"; then
 	merge_tool=meld
+    # Try tools specific to the user's editor
+    elif echo "${VISUAL:-$EDITOR}" | grep '^emacs' > /dev/null 2>&1 && type emacs >/dev/null 2>&1; then
+	merge_tool=emerge
+    elif echo "${VISUAL:-$EDITOR}" | grep '^vim' > /dev/null 2>&1 && type vimdiff >/dev/null 2>&1; then
+	merge_tool=vimdiff
+    # Try other tools
     elif type opendiff >/dev/null 2>&1; then
 	merge_tool=opendiff
     elif type emacs >/dev/null 2>&1; then
-- 
1.5.2.1



[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 252 bytes --]

^ permalink raw reply related	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2007-06-06 21:20 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-06-06  4:28 [PATCH] git-mergetool: Make default smarter by considering user's desktop environment and editor Josh Triplett
2007-06-06  8:08 ` Junio C Hamano
2007-06-06  8:52   ` David Kastrup
2007-06-06  9:05     ` Junio C Hamano
2007-06-06  9:40       ` David Kastrup
2007-06-06 21:20         ` Theodore Tso

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).