Skip to content

Commit f31fa2c

Browse files
committed
gitk: Fix handling of tree file list with special chars in names
Alex Riesen pointed out that displaying a commit in 'tree' mode fails if some files have names with special characters such as '{' or '}' in them, due to the fact that we treat the line returned from git ls-tree as a Tcl list at one point. This fixes it by doing what I originally intended but didn't quite get right. We split the line from git ls-tree at the first tab and treat the part before the tab as a list (which is OK since it doesn't have special characters in it) and the part after the tab as the filename. Signed-off-by: Paul Mackerras <paulus@samba.org>
1 parent 80dd7b4 commit f31fa2c

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

gitk

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4992,11 +4992,12 @@ proc gettreeline {gtf id} {
49924992
if {$diffids eq $nullid} {
49934993
set fname $line
49944994
} else {
4995-
if {$diffids ne $nullid2 && [lindex $line 1] ne "blob"} continue
49964995
set i [string first "\t" $line]
49974996
if {$i < 0} continue
4998-
set sha1 [lindex $line 2]
49994997
set fname [string range $line [expr {$i+1}] end]
4998+
set line [string range $line 0 [expr {$i-1}]]
4999+
if {$diffids ne $nullid2 && [lindex $line 1] ne "blob"} continue
5000+
set sha1 [lindex $line 2]
50005001
if {[string index $fname 0] eq "\""} {
50015002
set fname [lindex $fname 0]
50025003
}

0 commit comments

Comments
 (0)