Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.kernel.org/pub/scm/git/git.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTanay Abhra <tanayabh@gmail.com>2014-08-18 14:17:57 +0400
committerJunio C Hamano <gitster@pobox.com>2014-08-18 21:45:59 +0400
commitc8466645edd1413c7efed824f5bddac457eb77f9 (patch)
tree1e0aa1584d4b7155e56f62bead24136ef54f8cde /config.c
parent32f56600bb6ac6fc57183e79d2c1515dfa56672f (diff)
make config --add behave correctly for empty and NULL values
Currently if we have a config file like, [foo] baz bar = and we try something like, "git config --add foo.baz roll", Git will segfault. Moreover, for "git config --add foo.bar roll", it will overwrite the original value instead of appending after the existing empty value. The problem lies with the regexp used for simulating --add in `git_config_set_multivar_in_file()`, "^$", which in ideal case should not match with any string but is true for empty strings. Instead use a regexp like "a^" which can not be true for any string, empty or not. For removing the segfault add a check for NULL values in `matches()` in config.c. Signed-off-by: Tanay Abhra <tanayabh@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'config.c')
-rw-r--r--config.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/config.c b/config.c
index 2634457f6b..ffe010423d 100644
--- a/config.c
+++ b/config.c
@@ -1233,7 +1233,7 @@ static int matches(const char *key, const char *value)
return !strcmp(key, store.key) &&
(store.value_regex == NULL ||
(store.do_not_match ^
- !regexec(store.value_regex, value, 0, NULL, 0)));
+ (value && !regexec(store.value_regex, value, 0, NULL, 0))));
}
static int store_aux(const char *key, const char *value, void *cb)