Skip to content

Commit 097e111

Browse files
j6tpaulusmack
authored andcommitted
gitk: Do not hard-code "encoding" in attribute lookup functions
Commit 39ee47e (Clean up file encoding code and add enable/disable option, 2008-10-15) rewrote the attribute lookup functions gitattr and cache_gitattr, but in the process hard-coded the attribute name "encoding" instead of using the functions' parameters. This fixes it. This is not a serious regression because currently all callers look only for "encoding". Further note that this fix assumes that future callers will not pass an attribute name that contains regex special characters. Signed-off-by: Johannes Sixt <[email protected]> Signed-off-by: Paul Mackerras <[email protected]>
1 parent a41ddbb commit 097e111

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

gitk

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10901,7 +10901,7 @@ proc gitattr {path attr default} {
1090110901
} else {
1090210902
set r "unspecified"
1090310903
if {![catch {set line [exec git check-attr $attr -- $path]}]} {
10904-
regexp "(.*): encoding: (.*)" $line m f r
10904+
regexp "(.*): $attr: (.*)" $line m f r
1090510905
}
1090610906
set path_attr_cache($attr,$path) $r
1090710907
}
@@ -10929,7 +10929,7 @@ proc cache_gitattr {attr pathlist} {
1092910929
set newlist [lrange $newlist $lim end]
1093010930
if {![catch {set rlist [eval exec git check-attr $attr -- $head]}]} {
1093110931
foreach row [split $rlist "\n"] {
10932-
if {[regexp "(.*): encoding: (.*)" $row m path value]} {
10932+
if {[regexp "(.*): $attr: (.*)" $row m path value]} {
1093310933
if {[string index $path 0] eq "\""} {
1093410934
set path [encoding convertfrom [lindex $path 0]]
1093510935
}

0 commit comments

Comments
 (0)