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

Re: [RESEND] [PATCH] Fix tree mode of the file list for files containing curly brackets

From
Paul Mackerras <paulus@samba.org>
Date
Apr 27, 2008, 11:53 UTC
Message-ID
<18452.26961.14738.430774@cargo.ozlabs.ibm.com>
In-Reply-To
<20080427105700.GA28896@steel.home>
Alex Riesen writes:
> As far as I could understand the online documentation the [lindex ...]
> thing expects an array, which a string produced by git-ls-tree is not.
> So [split ...] it first, to get a real Tcl string-array.

Unfortunately that will do the wrong thing if the filename contains a tab character. I think the right thing is to split the line textually at the tab, then treat the first part as a list (which will be OK since it consists of words without special characters, separated by spaces), and the second part as the filename. That is what I was trying to do anyway, but I forgot to strip off the part after the tab, which is why lindex got unhappy with it. Here's the patch I'm about to commit.

Paul.
diff --git a/gitk-git/gitk b/gitk-git/gitk
index 9a4d9c4..da685aa 100644
--- a/gitk-git/gitk
+++ b/gitk-git/gitk
@@ -4992,11 +4992,12 @@ proc gettreeline {gtf id} {
 	if {$diffids eq $nullid} {
 	    set fname $line
 	} else {
-	    if {$diffids ne $nullid2 && [lindex $line 1] ne "blob"} continue
 	    set i [string first "\t" $line]
 	    if {$i < 0} continue
-	    set sha1 [lindex $line 2]
 	    set fname [string range $line [expr {$i+1}] end]
+	    set line [string range $line 0 [expr {$i-1}]]
+	    if {$diffids ne $nullid2 && [lindex $line 1] ne "blob"} continue
+	    set sha1 [lindex $line 2]
 	    if {[string index $fname 0] eq "\""} {
 		set fname [lindex $fname 0]
 	    }
Previous: Alex RiesenNext: Alex Riesen
Message 4 of 5 in “Fix tree mode of the file list for files containing curly brackets”
  1. Alex RiesenMar 14, 2008
  2. Fix tree mode of the file list for files containing curly bracketsAlex Riesen, Mar 14, 2008
  3. [RESEND] [PATCH] Fix tree mode of the file list for files containing curly bracketsAlex Riesen, Apr 27, 2008
  4. Paul MackerrasApr 27, 2008
  5. Alex RiesenApr 27, 2008

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.