git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: David Aguilar <davvid@gmail.com>
To: Paul Mackerras <paulus@samba.org>
Cc: git@vger.kernel.org, Thomas Arcila <thomas.arcila@gmail.com>,
	Markus Heidelberg <markus.heidelberg@web.de>,
	Nanako Shiraishi <nanako3@lavabit.com>,
	Junio C Hamano <gitster@pobox.com>
Subject: [PATCH v6] gitk: Use git-difftool for external diffs when available
Date: Tue, 20 Apr 2010 01:11:19 -0700	[thread overview]
Message-ID: <1271751079-18884-1-git-send-email-davvid@gmail.com> (raw)
In-Reply-To: <20100417085230.GC6681@brick.ozlabs.ibm.com>

git-difftool's '--extcmd=frotz' was added in 1.7.0 and
is the mechanism through which gitk launches the
configured 'extdifftool'.  When 'extdifftool' is
misconfigured an error dialog is used to display
git-difftool's stdout and stderr.

The existing implementation moved into 'proc gitkextdiff'
for use with git < 1.7.0.

One benefit of this change is that gitk's external diff
no longer requires write-access to the current directory.

Signed-off-by: David Aguilar <davvid@gmail.com>
---

Changes since last time:

* Errors are shown using 'proc error_popup'
* The existing code moved into a tidy function

 gitk |   25 +++++++++++++++++++++++++
 1 files changed, 25 insertions(+), 0 deletions(-)

diff --git a/gitk b/gitk
index 1b0e09a..0533baf 100755
--- a/gitk
+++ b/gitk
@@ -3361,6 +3361,7 @@ proc external_diff {} {
     global flist_menu_file
     global diffids
     global extdifftool
+    global git_version
 
     if {[llength $diffids] == 1} {
         # no reference commit given
@@ -3380,6 +3381,30 @@ proc external_diff {} {
         set diffidfrom [lindex $diffids 0]
         set diffidto [lindex $diffids 1]
     }
+    if {[package vcompare $git_version "1.7.0"] < 0} {
+        gitkextdiff $diffidfrom $diffidto
+        return
+    }
+
+    set cmd [list "git" "difftool" "--no-prompt" "--extcmd=$extdifftool"]
+    if {$diffidfrom ne $nullid && $diffidfrom ne $nullid2} {
+        lappend cmd $diffidfrom
+    }
+    if {$diffidto ne $nullid && $diffidto ne $nullid2} {
+        lappend cmd $diffidto
+    }
+    lappend cmd "--" $flist_menu_file
+
+    set pipe [open |$cmd r]
+    set stdout [read $pipe]
+    if {[catch {close $pipe} stderr] != 0} {
+        error_popup "git-difftool: $stdout $stderr"
+    }
+}
+
+proc gitkextdiff {diffidfrom diffidto} {
+    global flist_menu_file
+    global extdifftool
 
     # make sure that several diffs wont collide
     set diffdir [gitknewtmpdir]
-- 
1.7.1.rc2.5.gddd02

  parent reply	other threads:[~2010-04-20  8:11 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-03-27 21:45 [PATCH] gitk: Use git-difftool for external diffs David Aguilar
2010-03-28  0:01 ` [PATCH v2] " David Aguilar
2010-03-28  0:20 ` [PATCH v3] " David Aguilar
2010-03-28 10:59   ` Markus Heidelberg
2010-03-31  2:06     ` David Aguilar
2010-03-31  2:09     ` [PATCH v4] " David Aguilar
2010-04-02 11:32       ` Markus Heidelberg
2010-04-08  9:02         ` David Aguilar
2010-04-08  9:08           ` [PATCH v5] gitk: Use git-difftool for external diffs when git >= 1.7.0 David Aguilar
2010-04-17  8:52             ` Paul Mackerras
2010-04-17 22:45               ` David Aguilar
2010-04-18  2:20                 ` Jay Soffian
2010-04-20  8:11               ` David Aguilar [this message]
2010-06-08  8:10                 ` [PATCH v6] gitk: Use git-difftool for external diffs when available David Aguilar

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=1271751079-18884-1-git-send-email-davvid@gmail.com \
    --to=davvid@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=markus.heidelberg@web.de \
    --cc=nanako3@lavabit.com \
    --cc=paulus@samba.org \
    --cc=thomas.arcila@gmail.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).