summaryrefslogtreecommitdiff
path: root/cache.h
diff options
context:
space:
mode:
authorJeff King <peff@peff.net>2013-01-23 01:23:05 -0500
committerJunio C Hamano <gitster@pobox.com>2013-01-23 08:41:49 -0800
commit1b86bbb0ade4641c2da0dc74ebca1c09ec772bb4 (patch)
tree349d2c169d9c9f84d855ea5d929407d0722ddaeb /cache.h
parent94702dd1ac27618b60198f7c8bceafaaaf7743e2 (diff)
downloadgit-1b86bbb0ade4641c2da0dc74ebca1c09ec772bb4.tar.gz
config: add helper function for parsing key names
The config callback functions get keys of the general form: section.subsection.key (where the subsection may be contain arbitrary data, or may be missing). For matching keys without subsections, it is simple enough to call "strcmp". Matching keys with subsections is a little more complicated, and each callback does it in an ad-hoc way, usually involving error-prone pointer arithmetic. Let's provide a helper that keeps the pointer arithmetic all in one place. Signed-off-by: Jeff King <peff@peff.net> Reviewed-by: Jonathan Nieder <jrnieder@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'cache.h')
-rw-r--r--cache.h15
1 files changed, 15 insertions, 0 deletions
diff --git a/cache.h b/cache.h
index c257953fa7..b19305bca2 100644
--- a/cache.h
+++ b/cache.h
@@ -1164,6 +1164,21 @@ struct config_include_data {
#define CONFIG_INCLUDE_INIT { 0 }
extern int git_config_include(const char *name, const char *value, void *data);
+/*
+ * Match and parse a config key of the form:
+ *
+ * section.(subsection.)?key
+ *
+ * (i.e., what gets handed to a config_fn_t). The caller provides the section;
+ * we return -1 if it does not match, 0 otherwise. The subsection and key
+ * out-parameters are filled by the function (and subsection is NULL if it is
+ * missing).
+ */
+extern int parse_config_key(const char *var,
+ const char *section,
+ const char **subsection, int *subsection_len,
+ const char **key);
+
extern int committer_ident_sufficiently_given(void);
extern int author_ident_sufficiently_given(void);