Skip to contentSkip to conversation

gitk: honor TMPDIR when viewing external diffs

PATCH Applied David Aguilar 2 participants 2 messages Jun 15, 2016

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 gitk: honor TMPDIR when viewing external diffs

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.

---
 gitk | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)
gitk +9 -2
index 90764e8..82293dd 100755
@@ -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
Signature · 1 line
2.0.0.257.g75cc6c6
#1 lore raw
Quoted 9 lines · David Aguilar

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.

Thanks, applied.

Paul.