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

[PATCH] Fix for config file section parsing.

From
sean <seanlkml@sympatico.ca>
Date
May 5, 2006, 13:49 UTC
Message-ID
<BAYC1-PASMTP0769AAD931EFA5390875EDAEB50@CEZ.ICE>

Currently, if the target key has a section that matches the initial substring of another section we mistakenly believe we've found the correct section. To avoid this problem, ensure that the section lengths are identical before comparison.

Signed-off-by: Sean Estabrooks <seanlkml@sympatico.ca>
---
Here's an example of the problem:
$ git repo-config a.b.c d
$ cat .git/config
[a.b]
        c = d
$ git repo-config a.x y
$ cat .git/config
[a.b]
        c = d
        x = y
 config.c |    5 +++--
 1 files changed, 3 insertions(+), 2 deletions(-)
f956fd1a6b1d3c82d9bc735427b58ec41d9e5dd1
diff --git a/config.c b/config.c
index 4e1f0c2..a3e14d7 100644
--- a/config.c
+++ b/config.c
@@ -335,8 +335,9 @@ static int store_aux(const char* key, co
 			store.offset[store.seen] = ftell(config_file);
 			store.state = KEY_SEEN;
 			store.seen++;
-		} else if(!strncmp(key, store.key, store.baselen))
-			store.state = SECTION_SEEN;
+		} else if (strrchr(key, '.') - key == store.baselen &&
+			      !strncmp(key, store.key, store.baselen))
+					store.state = SECTION_SEEN;
 	}
 	return 0;
 }
-- 
1.3.2.g2fb9
Message 1 of 1 in “Fix for config file section parsing.”
  1. Fix for config file section parsing.sean, May 5, 2006

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.