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

[PATCH] refs: parse_hide_refs_config to use parse_config_key

From
Stefan Beller <sbeller@google.com>
Date
Feb 24, 2017, 20:43 UTC
Message-ID
<20170224204335.10652-1-sbeller@google.com>
In-Reply-To
<20170224203940.hbmfsouw5k67l3h3@sigill.intra.peff.net>

parse_config_key was introduced in 1b86bbb0ade (config: add helper function for parsing key names, 2013-01-22), the NEEDSWORK that is removed in this patch was introduced at daebaa7813 (upload/receive-pack: allow hiding ref hierarchies, 2013-01-18), which is only a couple days apart, so presumably the code replaced in this patch was only introduced due to not wanting to wait on the proper helper function being available.

Make the condition easier to read by using parse_config_key.
Signed-off-by: Stefan Beller <sbeller@google.com>
---
 refs.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/refs.c b/refs.c
index cd36b64ed9..21bc8c9101 100644
--- a/refs.c
+++ b/refs.c
@@ -1034,10 +1034,11 @@ static struct string_list *hide_refs;
 
 int parse_hide_refs_config(const char *var, const char *value, const char *section)
 {
+	const char *subsection, *key;
+	int subsection_len;
 	if (!strcmp("transfer.hiderefs", var) ||
-	    /* NEEDSWORK: use parse_config_key() once both are merged */
-	    (starts_with(var, section) && var[strlen(section)] == '.' &&
-	     !strcmp(var + strlen(section), ".hiderefs"))) {
+	    (!parse_config_key(var, section, &subsection, &subsection_len, &key)
+	    && !subsection && !strcmp(key, "hiderefs"))) {
 		char *ref;
 		int len;
 
-- 
2.12.0.rc1.16.ge4278d41a0.dirty
Previous: Jeff KingNext: Jeff King
Message 3 of 16 in “refs: parse_hide_refs_config to use parse_config_key”
  1. refs: parse_hide_refs_config to use parse_config_keyStefan Beller, Feb 24, 2017
  2. Jeff KingFeb 24, 2017
  3. refs: parse_hide_refs_config to use parse_config_keyStefan Beller, Feb 24, 2017
  4. Jeff KingFeb 24, 2017
  5. Junio C HamanoFeb 24, 2017
  6. Jeff KingFeb 24, 2017
  7. 1/3 parse_config_key: use skip_prefix instead of starts_withJeff King, Feb 24, 2017
  8. 2/3 parse_config_key: allow matching single-level configJeff King, Feb 24, 2017
  9. Junio C HamanoFeb 24, 2017
  10. Junio C HamanoFeb 24, 2017
  11. Jeff KingFeb 24, 2017
  12. 3/3 parse_hide_refs_config: tell parse_config_key we don't want a subsectionJeff King, Feb 24, 2017
  13. Stefan BellerFeb 24, 2017
  14. Junio C HamanoFeb 24, 2017
  15. Jeff KingFeb 24, 2017
  16. Junio C HamanoFeb 24, 2017

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.