summaryrefslogtreecommitdiff
path: root/builtin/config.c
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2011-02-28 05:58:31 (GMT)
committerJunio C Hamano <gitster@pobox.com>2011-02-28 05:58:31 (GMT)
commitfbfeeaf29480a3299fa6c3349b7a8c1b147c18c5 (patch)
tree4e7060b4640e33114131dff5c8df78dc60470ef9 /builtin/config.c
parentecd75ddb6f3fb7f2424d5852bcb4f50896cdcc9d (diff)
parent2169ddc056b56deba701cbbba28cdaf2e9821224 (diff)
downloadgit-fbfeeaf29480a3299fa6c3349b7a8c1b147c18c5.zip
git-fbfeeaf29480a3299fa6c3349b7a8c1b147c18c5.tar.gz
git-fbfeeaf29480a3299fa6c3349b7a8c1b147c18c5.tar.bz2
Merge branch 'lp/config-vername-check'
* lp/config-vername-check: Disallow empty section and variable names Sanity-check config variable names
Diffstat (limited to 'builtin/config.c')
-rw-r--r--builtin/config.c27
1 files changed, 20 insertions, 7 deletions
diff --git a/builtin/config.c b/builtin/config.c
index e27415d..76be0b7 100644
--- a/builtin/config.c
+++ b/builtin/config.c
@@ -153,7 +153,6 @@ static int show_config(const char *key_, const char *value_, void *cb)
static int get_value(const char *key_, const char *regex_)
{
int ret = -1;
- char *tl;
char *global = NULL, *repo_config = NULL;
const char *system_wide = NULL, *local;
@@ -167,18 +166,32 @@ static int get_value(const char *key_, const char *regex_)
system_wide = git_etc_gitconfig();
}
- key = xstrdup(key_);
- for (tl=key+strlen(key)-1; tl >= key && *tl != '.'; --tl)
- *tl = tolower(*tl);
- for (tl=key; *tl && *tl != '.'; ++tl)
- *tl = tolower(*tl);
-
if (use_key_regexp) {
+ char *tl;
+
+ /*
+ * NEEDSWORK: this naive pattern lowercasing obviously does not
+ * work for more complex patterns like "^[^.]*Foo.*bar".
+ * Perhaps we should deprecate this altogether someday.
+ */
+
+ key = xstrdup(key_);
+ for (tl = key + strlen(key) - 1;
+ tl >= key && *tl != '.';
+ tl--)
+ *tl = tolower(*tl);
+ for (tl = key; *tl && *tl != '.'; tl++)
+ *tl = tolower(*tl);
+
key_regexp = (regex_t*)xmalloc(sizeof(regex_t));
if (regcomp(key_regexp, key, REG_EXTENDED)) {
fprintf(stderr, "Invalid key pattern: %s\n", key_);
+ free(key);
goto free_strings;
}
+ } else {
+ if (git_config_parse_key(key_, &key, NULL))
+ goto free_strings;
}
if (regex_) {