git/list[1] front-page[2] threads[3] people[4] search[5] about
 

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
 	    }
Previous: Peter EriksenNext: Linus Torvalds
Message 5 of 6 in “Problems with binary patches (pull) and spaces in filenames (gitk)”
  1. Peter EriksenNov 9, 2005
  2. Junio C HamanoNov 9, 2005
  3. Junio C HamanoNov 9, 2005
  4. Peter EriksenNov 9, 2005
  5. Jan HarkesNov 9, 2005
  6. Linus TorvaldsNov 9, 2005

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.