summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 28fc3a6)
raw | patch | inline | side by side (parent: 28fc3a6)
author | Jeff King <peff@peff.net> | |
Thu, 9 Jun 2011 15:51:36 +0000 (11:51 -0400) | ||
committer | Junio C Hamano <gitster@pobox.com> | |
Wed, 22 Jun 2011 18:24:50 +0000 (11:24 -0700) |
If you do something like:
git -c core.foo="value with = in it" ...
we would split your option on "=" into three fields and
throw away the third one. With this patch we correctly take
everything after the first "=" as the value (keys cannot
have an equals sign in them, so the parsing is unambiguous).
Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
git -c core.foo="value with = in it" ...
we would split your option on "=" into three fields and
throw away the third one. With this patch we correctly take
everything after the first "=" as the value (keys cannot
have an equals sign in them, so the parsing is unambiguous).
Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
config.c | patch | blob | history | |
t/t1300-repo-config.sh | patch | blob | history |
diff --git a/config.c b/config.c
index 61de4d6a178ec8c2886331daefead68e762362db..84ff346859b331b08c4ffd6f04eacb67d5ee3b88 100644 (file)
--- a/config.c
+++ b/config.c
struct strbuf tmp = STRBUF_INIT;
struct strbuf **pair;
strbuf_addstr(&tmp, text);
- pair = strbuf_split(&tmp, '=');
+ pair = strbuf_split_max(&tmp, '=', 2);
if (pair[0]->len && pair[0]->buf[pair[0]->len - 1] == '=')
strbuf_setlen(pair[0], pair[0]->len - 1);
strbuf_trim(pair[0]);
diff --git a/t/t1300-repo-config.sh b/t/t1300-repo-config.sh
index 3db56267ee89e1b585a548f7bee13386e47395f4..ca5058e0d461b7ab5cc9c3ec908eccf126be32c7 100755 (executable)
--- a/t/t1300-repo-config.sh
+++ b/t/t1300-repo-config.sh
test_cmp expect actual
'
+test_expect_success 'git -c does not split values on equals' '
+ echo "value with = in it" >expect &&
+ git -c core.foo="value with = in it" config core.foo >actual &&
+ test_cmp expect actual
+'
+
test_done