[PATCH v5] gitk: Use git-difftool for external diffs when git >= 1.7.0

Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
From: David Aguilar
Date: Thursday, April 8, 2010 - 2:08 am

git-difftool is used instead of the built-in external diff
code when git is >= 1.7.0.  git-difftool's '--extcmd=frotz'
feature was first introduced in 1.7.0 and is the mechanism
through which we launch the configured difftool.

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

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

Unlike previous versions, this one checks the git version at runtime
and gracefully falls back to the old code when git is older.

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

diff --git a/gitk b/gitk
index 1f36a3e..a49eecc 100755
--- a/gitk
+++ b/gitk
@@ -3355,6 +3355,7 @@ proc external_diff {} {
     global flist_menu_file
     global diffids
     global extdifftool
+    global git_version
 
     if {[llength $diffids] == 1} {
         # no reference commit given
@@ -3375,6 +3376,19 @@ proc external_diff {} {
         set diffidto [lindex $diffids 1]
     }
 
+    if {[package vcompare $git_version "1.7.0"] >= 0} {
+        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
+        eval exec $cmd &
+        return
+    }
+
     # make sure that several diffs wont collide
     set diffdir [gitknewtmpdir]
     if {$diffdir eq {}} return
-- 
1.7.0.3.313.g87b3c

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
[PATCH] gitk: Use git-difftool for external diffs, David Aguilar, (Sat Mar 27, 2:45 pm)
[PATCH v2] gitk: Use git-difftool for external diffs, David Aguilar, (Sat Mar 27, 5:01 pm)
[PATCH v3] gitk: Use git-difftool for external diffs, David Aguilar, (Sat Mar 27, 5:20 pm)
Re: [PATCH v3] gitk: Use git-difftool for external diffs, Markus Heidelberg, (Sun Mar 28, 3:59 am)
Re: [PATCH v3] gitk: Use git-difftool for external diffs, David Aguilar, (Tue Mar 30, 7:06 pm)
[PATCH v4] gitk: Use git-difftool for external diffs, David Aguilar, (Tue Mar 30, 7:09 pm)
Re: [PATCH v4] gitk: Use git-difftool for external diffs, Markus Heidelberg, (Fri Apr 2, 4:32 am)
[PATCH v5] gitk: Use git-difftool for external diffs when ..., David Aguilar, (Thu Apr 8, 2:08 am)