summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 97b88dd)
raw | patch | inline | side by side (parent: 97b88dd)
author | Bryan Donlan <bdonlan@fushizen.net> | |
Sun, 4 May 2008 05:37:52 +0000 (01:37 -0400) | ||
committer | Junio C Hamano <gitster@pobox.com> | |
Mon, 5 May 2008 21:17:00 +0000 (14:17 -0700) |
If an element of the configuration key name other than the first or last
contains a backslash, it is not escaped on output, but is treated as an
escape sequence on input. Thus, the backslash is lost when re-loading
the configuration.
This patch corrects this by having backslashes escaped properly, and
introduces a new test for this bug.
Signed-off-by: Bryan Donlan <bdonlan@fushizen.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
contains a backslash, it is not escaped on output, but is treated as an
escape sequence on input. Thus, the backslash is lost when re-loading
the configuration.
This patch corrects this by having backslashes escaped properly, and
introduces a new test for this bug.
Signed-off-by: Bryan Donlan <bdonlan@fushizen.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
config.c | patch | blob | history | |
t/t1303-wacky-config.sh | patch | blob | history |
diff --git a/config.c b/config.c
index b0ada515b9d839fc8691bc9af320353ff323b251..f0ac4569a33630e20d6e7531d50eee55cf0dd9d4 100644 (file)
--- a/config.c
+++ b/config.c
if (dot) {
strbuf_addf(&sb, "[%.*s \"", (int)(dot - key), key);
for (i = dot - key + 1; i < store.baselen; i++) {
- if (key[i] == '"')
+ if (key[i] == '"' || key[i] == '\\')
strbuf_addch(&sb, '\\');
strbuf_addch(&sb, key[i]);
}
index 99985dcd79f12d680c51e8f64d61c47a70b43f36..f366b53fb671a5ef52c34516bc4ab3869a142d8e 100755 (executable)
--- a/t/t1303-wacky-config.sh
+++ b/t/t1303-wacky-config.sh
check section2.key bar
'
+SECTION="test.q\"s\\sq'sp e.key"
+test_expect_success 'make sure git-config escapes section names properly' '
+ git config "$SECTION" bar &&
+ check "$SECTION" bar
+'
+
test_done