From 49624d1e518f14fe03ba6c8824aaaf420e01a834 Mon Sep 17 00:00:00 2001 From: Stefan Beller Date: Fri, 24 Feb 2017 12:43:35 -0800 Subject: refs: parse_hide_refs_config to use parse_config_key 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 Reviewed-by: Jeff King Signed-off-by: Junio C Hamano --- refs.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'refs.c') diff --git a/refs.c b/refs.c index 9bd0bc177..92f800e9c 100644 --- a/refs.c +++ b/refs.c @@ -1029,10 +1029,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; -- cgit v1.2.1 From ad8c7cdadd96c66d0adf894250c8f4dd77bb2bee Mon Sep 17 00:00:00 2001 From: Jeff King Date: Fri, 24 Feb 2017 16:08:16 -0500 Subject: parse_hide_refs_config: tell parse_config_key we don't want a subsection This lets us avoid declaring some otherwise useless variables. Signed-off-by: Jeff King Signed-off-by: Junio C Hamano --- refs.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'refs.c') diff --git a/refs.c b/refs.c index 92f800e9c..cb8124557 100644 --- a/refs.c +++ b/refs.c @@ -1029,11 +1029,10 @@ 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; + const char *key; if (!strcmp("transfer.hiderefs", var) || - (!parse_config_key(var, section, &subsection, &subsection_len, &key) - && !subsection && !strcmp(key, "hiderefs"))) { + (!parse_config_key(var, section, NULL, NULL, &key) && + !strcmp(key, "hiderefs"))) { char *ref; int len; -- cgit v1.2.1