summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--config.c2
-rwxr-xr-xt/t1303-wacky-config.sh6
2 files changed, 7 insertions, 1 deletions
diff --git a/config.c b/config.c
index b0ada515b9..f0ac4569a3 100644
--- a/config.c
+++ b/config.c
@@ -680,7 +680,7 @@ static int store_write_section(int fd, const char* key)
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]);
}
diff --git a/t/t1303-wacky-config.sh b/t/t1303-wacky-config.sh
index 99985dcd79..f366b53fb6 100755
--- a/t/t1303-wacky-config.sh
+++ b/t/t1303-wacky-config.sh
@@ -34,4 +34,10 @@ test_expect_success 'add key in different section' '
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