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

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

From
David Aguilar <davvid@gmail.com>
Date
Apr 8, 2010, 09:08 UTC
Message-ID
<1270717690-32133-1-git-send-email-davvid@gmail.com>
In-Reply-To
<20100408090211.GA31594@gmail.com>

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
Previous: David AguilarNext: Paul Mackerras
Message 9 of 14 in “gitk: Use git-difftool for external diffs”
  1. gitk: Use git-difftool for external diffsDavid Aguilar, Mar 27, 2010
  2. gitk: Use git-difftool for external diffsDavid Aguilar, Mar 28, 2010
  3. gitk: Use git-difftool for external diffsDavid Aguilar, Mar 28, 2010
  4. Markus HeidelbergMar 28, 2010
  5. David AguilarMar 31, 2010
  6. gitk: Use git-difftool for external diffsDavid Aguilar, Mar 31, 2010
  7. Markus HeidelbergApr 2, 2010
  8. David AguilarApr 8, 2010
  9. gitk: Use git-difftool for external diffs when git >= 1.7.0David Aguilar, Apr 8, 2010
  10. Paul MackerrasApr 17, 2010
  11. David AguilarApr 17, 2010
  12. Jay SoffianApr 18, 2010
  13. gitk: Use git-difftool for external diffs when availableDavid Aguilar, Apr 20, 2010
  14. David AguilarJun 8, 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.