summaryrefslogtreecommitdiff
path: root/config.c
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2017-03-10 21:24:22 (GMT)
committerJunio C Hamano <gitster@pobox.com>2017-03-10 21:24:22 (GMT)
commit963792ed277bde985ea9ff4953529d656b186571 (patch)
treece457fde106f33c0cd9c75b1c15a5169752431cb /config.c
parent34061299002fcbf5467385debbd9ad3d5f1c5a4e (diff)
parentad8c7cdadd96c66d0adf894250c8f4dd77bb2bee (diff)
downloadgit-963792ed277bde985ea9ff4953529d656b186571.zip
git-963792ed277bde985ea9ff4953529d656b186571.tar.gz
git-963792ed277bde985ea9ff4953529d656b186571.tar.bz2
Merge branch 'jk/parse-config-key-cleanup'
The "parse_config_key()" API function has been cleaned up. * jk/parse-config-key-cleanup: parse_hide_refs_config: tell parse_config_key we don't want a subsection parse_config_key: allow matching single-level config parse_config_key: use skip_prefix instead of starts_with
Diffstat (limited to 'config.c')
-rw-r--r--config.c15
1 files changed, 9 insertions, 6 deletions
diff --git a/config.c b/config.c
index 48edc6a..0e9e1eb 100644
--- a/config.c
+++ b/config.c
@@ -2540,11 +2540,10 @@ int parse_config_key(const char *var,
const char **subsection, int *subsection_len,
const char **key)
{
- int section_len = strlen(section);
const char *dot;
/* Does it start with "section." ? */
- if (!starts_with(var, section) || var[section_len] != '.')
+ if (!skip_prefix(var, section, &var) || *var != '.')
return -1;
/*
@@ -2556,12 +2555,16 @@ int parse_config_key(const char *var,
*key = dot + 1;
/* Did we have a subsection at all? */
- if (dot == var + section_len) {
- *subsection = NULL;
- *subsection_len = 0;
+ if (dot == var) {
+ if (subsection) {
+ *subsection = NULL;
+ *subsection_len = 0;
+ }
}
else {
- *subsection = var + section_len + 1;
+ if (!subsection)
+ return -1;
+ *subsection = var + 1;
*subsection_len = dot - *subsection;
}