Skip to contentSkip to conversation

gitk: Honor TMPDIR when viewing diffs externally

PATCH Superseded David Aguilar 1 participant 1 message Jun 15, 2016

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 gitk: Honor TMPDIR when viewing diffs externally

gitk's external diff fails when browsing read-only repositories. This is due to gitk's assumption that the current directory is always writable. By honoring TMPDIR we avoid this problem and allow users to define the location used for temporary files.

---
 gitk |   10 +++++++---
 1 files changed, 7 insertions(+), 3 deletions(-)
gitk +7 -3
index db5ec54..a065e94 100755
@@ -3170,11 +3170,15 @@ proc flist_hl {only} {
 }
 
 proc gitknewtmpdir {} {
-    global diffnum gitktmpdir gitdir
+    global diffnum gitktmpdir gitdir env
 
     if {![info exists gitktmpdir]} {
-	set gitktmpdir [file join [file dirname $gitdir] \
-			    [format ".gitk-tmp.%s" [pid]]]
+	if {[info exists env(TMPDIR)]} {
+	    set tmpdir $env(TMPDIR)
+	} else {
+	    set tmpdir [file dirname $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
1.6.5.2.180.gc5b3e