summaryrefslogtreecommitdiff
path: root/config.c
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2011-07-19 09:45:21 -0700
committerJunio C Hamano <gitster@pobox.com>2011-07-19 09:45:21 -0700
commitfe01ef31b79af85ca50738b11b048e3fad856d34 (patch)
tree0083d9d0b45381ff59856ba612f7f1b851a31a76 /config.c
parent20a80d04a4835dfec2823570719f17b6892e4841 (diff)
parentf77bccaeba7a4c542e9b89d144af74bddd36fd08 (diff)
downloadgit-fe01ef31b79af85ca50738b11b048e3fad856d34.tar.gz
Merge branch 'jk/maint-config-param'
* jk/maint-config-param: config: use strbuf_split_str instead of a temporary strbuf strbuf: allow strbuf_split to work on non-strbufs config: avoid segfault when parsing command-line config config: die on error in command-line config fix "git -c" parsing of values with equals signs strbuf_split: add a max parameter
Diffstat (limited to 'config.c')
-rw-r--r--config.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/config.c b/config.c
index 1fc063b256..9340dfe5a8 100644
--- a/config.c
+++ b/config.c
@@ -50,10 +50,10 @@ void git_config_push_parameter(const char *text)
static int git_config_parse_parameter(const char *text,
config_fn_t fn, void *data)
{
- struct strbuf tmp = STRBUF_INIT;
struct strbuf **pair;
- strbuf_addstr(&tmp, text);
- pair = strbuf_split(&tmp, '=');
+ 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] == '=')
strbuf_setlen(pair[0], pair[0]->len - 1);
strbuf_trim(pair[0]);
@@ -874,7 +874,7 @@ int git_config_early(config_fn_t fn, void *data, const char *repo_config)
switch (git_config_from_parameters(fn, data)) {
case -1: /* error */
- ret--;
+ die("unable to parse command-line config");
break;
case 0: /* found nothing */
break;