summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: e276f01)
raw | patch | inline | side by side (parent: e276f01)
author | Björn Steinbrink <B.Steinbrink@gmx.de> | |
Thu, 30 Jul 2009 11:41:57 +0000 (13:41 +0200) | ||
committer | Junio C Hamano <gitster@pobox.com> | |
Fri, 31 Jul 2009 15:38:30 +0000 (08:38 -0700) |
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>
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>
config.c | patch | blob | history | |
t/t1300-repo-config.sh | patch | blob | history |
diff --git a/config.c b/config.c
index 1682273c12ab042d73fa32caf30d18fb13ef85e3..7e5594b65e4e62514fde378f4f3abb1ee3d1cbdb 100644 (file)
--- a/config.c
+++ b/config.c
if (comment)
continue;
if (isspace(c) && !quote) {
- space = 1;
+ if (len)
+ space++;
continue;
}
if (!quote) {
continue;
}
}
- if (space) {
- if (len)
- value[len++] = ' ';
- space = 0;
- }
+ for (; space; space--)
+ value[len++] = ' ';
if (c == '\\') {
c = get_next_char();
switch (c) {
diff --git a/t/t1300-repo-config.sh b/t/t1300-repo-config.sh
index 43ea283242c4afc25e53d4a8c894140793649717..91cbd551d8b8031b91437238e281591268a0268f 100755 (executable)
--- a/t/t1300-repo-config.sh
+++ b/t/t1300-repo-config.sh
test_expect_success '--null --get-regexp' 'cmp result expect'
+test_expect_success 'inner whitespace kept verbatim' '
+ git config section.val "foo bar" &&
+ test "z$(git config section.val)" = "zfoo bar"
+'
+
test_expect_success SYMLINKS 'symlinked configuration' '
ln -s notyet myconfig &&