Re: Problems with binary patches (pull) and spaces in filenames (gitk)
- From
Jan Harkes <jaharkes@cs.cmu.edu>
- Date
- Nov 9, 2005, 23:00 UTC
- Message-ID
- <20051109230048.GH31850@delft.aura.cs.cmu.edu>
- In-Reply-To
- <7vfyq5bhi2.fsf@assigned-by-dhcp.cox.net>
On Wed, Nov 09, 2005 at 02:09:41PM -0800, Junio C Hamano wrote:
> Another minor gitk gripe I have is that it does not look at
> subdirectories of refs/{heads,tags}/ so I do not get labels to
> my topic branch heads.I've been using the following gitk 'customization'. ISTR that it can be cleaned up a bit further and do everything in a single scan of the refs/ subtree. I'll take another look at that tonight.
Jan
diff --git a/gitk b/gitk index a9d37d9..cd0b84f 100755 --- a/gitk +++ b/gitk @@ -237,16 +237,27 @@ proc parsecommit {id contents listed old $comname $comdate $comment] } +# recursively list all files in a directory +proc listTree {root} { + set files [glob -nocomplain -directory $root -types f *] + set nodes [glob -nocomplain -directory $root -types d *] + foreach node $nodes { + set children [listTree $node] + set files [concat $files $children] + } + return $files +} + proc readrefs {} { global tagids idtags headids idheads tagcontents - set tags [glob -nocomplain -types f [gitdir]/refs/tags/*] + set tags [listTree [gitdir]/refs/tags] foreach f $tags { catch { set fd [open $f r] set line [read $fd] if {[regexp {^[0-9a-f]{40}} $line id]} { - set direct [file tail $f] + regexp {[gitdir]/refs/tags/(.*)} $f match direct set tagids($direct) $id lappend idtags($id) $direct set tagblob [exec git-cat-file tag $id] @@ -271,13 +282,13 @@ proc readrefs {} { close $fd } } - set heads [glob -nocomplain -types f [gitdir]/refs/heads/*] + set heads [listTree [gitdir]/refs/heads] foreach f $heads { catch { set fd [open $f r] set line [read $fd 40] if {[regexp {^[0-9a-f]{40}} $line id]} { - set head [file tail $f] + regexp {[gitdir]/refs/heads/(.*)} $f match head set headids($head) $line lappend idheads($line) $head }