aboutsummaryrefslogtreecommitdiff
path: root/config.c
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2014-09-09 12:53:56 -0700
committerJunio C Hamano <gitster@pobox.com>2014-09-09 12:53:57 -0700
commit93424a0fd882a3ed1c1f7a8b6fe71fdaa21cce99 (patch)
treeb20b3ed1d2c1ecad9d7bc09a6679ed24015dfe36 /config.c
parent713c6f3ab06fcda921262b718742cff7f208da9a (diff)
parenta789ca70e7a5b02973b116d21674acd795238f99 (diff)
downloadgit-93424a0fd882a3ed1c1f7a8b6fe71fdaa21cce99.tar.gz
git-93424a0fd882a3ed1c1f7a8b6fe71fdaa21cce99.tar.xz
Merge branch 'jk/command-line-config-empty-string'
"git -c section.var command" and "git -c section.var= command" should pass the configuration differently (the former should be a boolean true, the latter should be an empty string). * jk/command-line-config-empty-string: config: teach "git -c" to recognize an empty string
Diffstat (limited to 'config.c')
-rw-r--r--config.c12
1 files changed, 10 insertions, 2 deletions
diff --git a/config.c b/config.c
index a191328a9..01e0bdbaf 100644
--- a/config.c
+++ b/config.c
@@ -177,19 +177,27 @@ void git_config_push_parameter(const char *text)
int git_config_parse_parameter(const char *text,
config_fn_t fn, void *data)
{
+ const char *value;
struct strbuf **pair;
+
pair = strbuf_split_str(text, '=', 2);
if (!pair[0])
return error("bogus config parameter: %s", text);
- if (pair[0]->len && pair[0]->buf[pair[0]->len - 1] == '=')
+
+ if (pair[0]->len && pair[0]->buf[pair[0]->len - 1] == '=') {
strbuf_setlen(pair[0], pair[0]->len - 1);
+ value = pair[1] ? pair[1]->buf : "";
+ } else {
+ value = NULL;
+ }
+
strbuf_trim(pair[0]);
if (!pair[0]->len) {
strbuf_list_free(pair);
return error("bogus config parameter: %s", text);
}
strbuf_tolower(pair[0]);
- if (fn(pair[0]->buf, pair[1] ? pair[1]->buf : NULL, data) < 0) {
+ if (fn(pair[0]->buf, value, data) < 0) {
strbuf_list_free(pair);
return -1;
}