git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Josh Triplett <josh@freedesktop.org>
To: git@vger.kernel.org
Subject: [PATCH] git-mergetool: Make default smarter by considering user's desktop environment and editor
Date: Tue, 05 Jun 2007 21:28:18 -0700	[thread overview]
Message-ID: <466637E2.5040303@freedesktop.org> (raw)

[-- 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 --]

             reply	other threads:[~2007-06-06  4:29 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-06-06  4:28 Josh Triplett [this message]
2007-06-06  8:08 ` [PATCH] git-mergetool: Make default smarter by considering user's desktop environment and editor 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

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=466637E2.5040303@freedesktop.org \
    --to=josh@freedesktop.org \
    --cc=git@vger.kernel.org \
    /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).