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

[PATCH] gitk: honor TMPDIR when viewing external diffs

From
David Aguilar <davvid@gmail.com>
Date
Jun 13, 2014, 21:13 UTC
Message-ID
<1402694017-91249-1-git-send-email-davvid@gmail.com>

gitk fails to show diffs when browsing a read-only repository. This is due to gitk's assumption that the current directory is always writable.

Teach gitk to honor either the GITK_TMPDIR or TMPDIR environment variables. This allows users to override the default location used when writing temporary files.

Signed-off-by: David Aguilar <davvid@gmail.com>
---
 gitk | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)
diff --git a/gitk b/gitk
index 90764e8..82293dd 100755
--- a/gitk
+++ b/gitk
@@ -3492,10 +3492,17 @@ proc flist_hl {only} {
 }
 
 proc gitknewtmpdir {} {
-    global diffnum gitktmpdir gitdir
+    global diffnum gitktmpdir gitdir env
 
     if {![info exists gitktmpdir]} {
-	set gitktmpdir [file join $gitdir [format ".gitk-tmp.%s" [pid]]]
+	if {[info exists env(GITK_TMPDIR)]} {
+	    set tmpdir $env(GITK_TMPDIR)
+	} elseif {[info exists env(TMPDIR)]} {
+	    set tmpdir $env(TMPDIR)
+	} else {
+	    set tmpdir $gitdir
+	}
+	set gitktmpdir [file join $tmpdir [format ".gitk-tmp.%s" [pid]]]
 	if {[catch {file mkdir $gitktmpdir} err]} {
 	    error_popup "[mc "Error creating temporary directory %s:" $gitktmpdir] $err"
 	    unset gitktmpdir
-- 
2.0.0.257.g75cc6c6
Next: Paul Mackerras
Message 1 of 2 in “gitk: honor TMPDIR when viewing external diffs”
  1. gitk: honor TMPDIR when viewing external diffsDavid Aguilar, Jun 13, 2014
  2. Paul MackerrasJun 15, 2014

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.