summaryrefslogtreecommitdiff
path: root/config.c
diff options
context:
space:
mode:
authorBjörn Steinbrink <B.Steinbrink@gmx.de>2009-07-30 13:41:57 +0200
committerJunio C Hamano <gitster@pobox.com>2009-07-31 08:38:30 -0700
commitebdaae372b460ffdf5d153dcd0ac235d52b0d2ce (patch)
treee0e54f0f661802b8a13f2c84a329d774643132c8 /config.c
parente276f018f2c1f0fc962fbe44a36708d1cdebada8 (diff)
downloadgit-ebdaae372b460ffdf5d153dcd0ac235d52b0d2ce.tar.gz
config: Keep inner whitespace verbatim
Configuration values are expected to be quoted when they have leading or trailing whitespace, but inner whitespace should be kept verbatim even if the value is not quoted. This is already documented in git-config(1), but the code caused inner whitespace to be collapsed to a single space, breaking, for example, clones from a path that has two consecutive spaces in it, as future fetches would only see a single space. Reported-by: John te Bokkel <tanj.tanj@gmail.com> Signed-off-by: Björn Steinbrink <B.Steinbrink@gmx.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'config.c')
-rw-r--r--config.c10
1 files changed, 4 insertions, 6 deletions
diff --git a/config.c b/config.c
index 1682273c12..7e5594b65e 100644
--- a/config.c
+++ b/config.c
@@ -62,7 +62,8 @@ static char *parse_value(void)
if (comment)
continue;
if (isspace(c) && !quote) {
- space = 1;
+ if (len)
+ space++;
continue;
}
if (!quote) {
@@ -71,11 +72,8 @@ static char *parse_value(void)
continue;
}
}
- if (space) {
- if (len)
- value[len++] = ' ';
- space = 0;
- }
+ for (; space; space--)
+ value[len++] = ' ';
if (c == '\\') {
c = get_next_char();
switch (c) {