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

[PATCH] gitk: Do not hard-code "encoding" in attribute lookup functions

From
Johannes Sixt <j.sixt@viscovery.net>
Date
Jul 21, 2009, 08:09 UTC
Message-ID
<4A6577CC.2000403@viscovery.net>
From: Johannes Sixt <j6t@kdbg.org>

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 <j6t@kdbg.org>
---
 gitk |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/gitk b/gitk
index 4604c83..8aafb19 100755
--- a/gitk
+++ b/gitk
@@ -10901,7 +10901,7 @@ proc gitattr {path attr default} {
     } else {
 	set r "unspecified"
 	if {![catch {set line [exec git check-attr $attr -- $path]}]} {
-	    regexp "(.*): encoding: (.*)" $line m f r
+	    regexp "(.*): $attr: (.*)" $line m f r
 	}
 	set path_attr_cache($attr,$path) $r
     }
@@ -10929,7 +10929,7 @@ proc cache_gitattr {attr pathlist} {
 	set newlist [lrange $newlist $lim end]
 	if {![catch {set rlist [eval exec git check-attr $attr -- $head]}]} {
 	    foreach row [split $rlist "\n"] {
-		if {[regexp "(.*): encoding: (.*)" $row m path value]} {
+		if {[regexp "(.*): $attr: (.*)" $row m path value]} {
 		    if {[string index $path 0] eq "\""} {
 			set path [encoding convertfrom [lindex $path 0]]
 		    }
-- 
1.6.4.rc1.1032.g74cb
Next: Paul Mackerras
Message 1 of 2 in “gitk: Do not hard-code "encoding" in attribute lookup functions”
  1. gitk: Do not hard-code "encoding" in attribute lookup functionsJohannes Sixt, Jul 21, 2009
  2. Paul MackerrasAug 13, 2009

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.