Skip to content

Commit

Permalink
gitk: Honor TMPDIR when viewing external diffs
Browse files Browse the repository at this point in the history
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>
Signed-off-by: Paul Mackerras <paulus@samba.org>
  • Loading branch information
David Aguilar authored and Paul Mackerras committed Jun 15, 2014
1 parent 17f9836 commit c7664f1
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions gitk
Original file line number Diff line number Diff line change
Expand Up @@ -3493,10 +3493,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
Expand Down

0 comments on commit c7664f1

Please sign in to comment.