Skip to content

Commit c7664f1

Browse files
davvidpaulusmack
authored andcommitted
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. Signed-off-by: David Aguilar <[email protected]> Signed-off-by: Paul Mackerras <[email protected]>
1 parent 17f9836 commit c7664f1

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

gitk

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3493,10 +3493,17 @@ proc flist_hl {only} {
34933493
}
34943494

34953495
proc gitknewtmpdir {} {
3496-
global diffnum gitktmpdir gitdir
3496+
global diffnum gitktmpdir gitdir env
34973497

34983498
if {![info exists gitktmpdir]} {
3499-
set gitktmpdir [file join $gitdir [format ".gitk-tmp.%s" [pid]]]
3499+
if {[info exists env(GITK_TMPDIR)]} {
3500+
set tmpdir $env(GITK_TMPDIR)
3501+
} elseif {[info exists env(TMPDIR)]} {
3502+
set tmpdir $env(TMPDIR)
3503+
} else {
3504+
set tmpdir $gitdir
3505+
}
3506+
set gitktmpdir [file join $tmpdir [format ".gitk-tmp.%s" [pid]]]
35003507
if {[catch {file mkdir $gitktmpdir} err]} {
35013508
error_popup "[mc "Error creating temporary directory %s:" $gitktmpdir] $err"
35023509
unset gitktmpdir

0 commit comments

Comments
 (0)