git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] refs: parse_hide_refs_config to use parse_config_key
@ 2017-02-24 20:33 Stefan Beller
  2017-02-24 20:39 ` Jeff King
  0 siblings, 1 reply; 16+ messages in thread
From: Stefan Beller @ 2017-02-24 20:33 UTC (permalink / raw)
  To: gitster, peff; +Cc: git, Stefan Beller

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>
---

  When investigating the state of the art for parsing config options, I saw
  opportunity for a small drive-by patch in an area that I did not look at for 
  a long time.
  
  The authors of the two mentioned commits are Jeff and Junio, so maybe you
  remember another reason for this NEEDSWORK here?
  
  Thanks,
  Stefan
  
 refs.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/refs.c b/refs.c
index cd36b64ed9..c9e5f13630 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)
+	    && !strcmp(key, "hiderefs"))) {
 		char *ref;
 		int len;
 
-- 
2.12.0.rc1.16.ge4278d41a0.dirty


^ permalink raw reply related	[flat|nested] 16+ messages in thread

end of thread, other threads:[~2017-02-24 23:28 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-02-24 20:33 [PATCH] refs: parse_hide_refs_config to use parse_config_key Stefan Beller
2017-02-24 20:39 ` Jeff King
2017-02-24 20:43   ` Stefan Beller
2017-02-24 20:47     ` Jeff King
2017-02-24 20:47     ` Junio C Hamano
2017-02-24 21:06   ` Jeff King
2017-02-24 21:07     ` [PATCH 1/3] parse_config_key: use skip_prefix instead of starts_with Jeff King
2017-02-24 21:08     ` [PATCH 2/3] parse_config_key: allow matching single-level config Jeff King
2017-02-24 21:20       ` Junio C Hamano
2017-02-24 21:25         ` Junio C Hamano
2017-02-24 21:26         ` Jeff King
2017-02-24 21:08     ` [PATCH 3/3] parse_hide_refs_config: tell parse_config_key we don't want a subsection Jeff King
2017-02-24 23:28       ` Stefan Beller
2017-02-24 21:18     ` [PATCH] refs: parse_hide_refs_config to use parse_config_key Junio C Hamano
2017-02-24 21:20       ` Jeff King
2017-02-24 21:24         ` Junio C Hamano

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).