Browse Source

[PATCH] gitk: Use GIT_DIR where appropriate.

Some places assumed .git is the GIT_DIR, resulting heads and
tags not showing when it was run like "GIT_DIR=. gitk --all".
This is not a contrived example --- I rely on it to verify
my private copy of git.git repository before pushing it out.

Define a single procedure "gitdir" and use it.

Signed-off-by: Junio C Hamano <junkio@cox.net>
Signed-off-by: Paul Mackerras <paulus@samba.org>
maint
Junio C Hamano 20 years ago committed by Paul Mackerras
parent
commit
73b6a6cbda
  1. 24
      gitk

24
gitk

@ -7,17 +7,22 @@ exec wish "$0" -- "${1+$@}"
# and distributed under the terms of the GNU General Public Licence, # and distributed under the terms of the GNU General Public Licence,
# either version 2, or (at your option) any later version. # either version 2, or (at your option) any later version.


proc gitdir {} {
global env
if {[info exists env(GIT_DIR)]} {
return $env(GIT_DIR)
} else {
return ".git"
}
}

proc getcommits {rargs} { proc getcommits {rargs} {
global commits commfd phase canv mainfont env global commits commfd phase canv mainfont env
global startmsecs nextupdate global startmsecs nextupdate
global ctext maincursor textcursor leftover global ctext maincursor textcursor leftover


# check that we can find a .git directory somewhere... # check that we can find a .git directory somewhere...
if {[info exists env(GIT_DIR)]} { set gitdir [gitdir]
set gitdir $env(GIT_DIR)
} else {
set gitdir ".git"
}
if {![file isdirectory $gitdir]} { if {![file isdirectory $gitdir]} {
error_popup "Cannot find the git directory \"$gitdir\"." error_popup "Cannot find the git directory \"$gitdir\"."
exit 1 exit 1
@ -212,7 +217,7 @@ proc parsecommit {id contents listed} {


proc readrefs {} { proc readrefs {} {
global tagids idtags headids idheads global tagids idtags headids idheads
set tags [glob -nocomplain -types f .git/refs/tags/*] set tags [glob -nocomplain -types f [gitdir]/refs/tags/*]
foreach f $tags { foreach f $tags {
catch { catch {
set fd [open $f r] set fd [open $f r]
@ -241,7 +246,7 @@ proc readrefs {} {
close $fd close $fd
} }
} }
set heads [glob -nocomplain -types f .git/refs/heads/*] set heads [glob -nocomplain -types f [gitdir]/refs/heads/*]
foreach f $heads { foreach f $heads {
catch { catch {
set fd [open $f r] set fd [open $f r]
@ -2752,10 +2757,7 @@ proc domktag {} {
return return
} }
if {[catch { if {[catch {
set dir ".git" set dir [gitdir]
if {[info exists env(GIT_DIR)]} {
set dir $env(GIT_DIR)
}
set fname [file join $dir "refs/tags" $tag] set fname [file join $dir "refs/tags" $tag]
set f [open $fname w] set f [open $fname w]
puts $f $id puts $f $id

Loading…
Cancel
Save