From: "Björn Steinbrink" <B.Steinbrink@gmx.de>
To: John te Bokkel / Tempus <tanj.tanj@gmail.com>
Cc: git@vger.kernel.org, Junio C Hamano <gitster@pobox.com>
Subject: [PATCH] config: Keep inner whitespace verbatim
Date: Thu, 30 Jul 2009 13:41:57 +0200 [thread overview]
Message-ID: <20090730114157.GA5560@atjola.homenet> (raw)
In-Reply-To: <47ade73f0907291752k62c66903lc2617a16ec0973bd@mail.gmail.com>
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>
---
config.c | 6 +++---
t/t1300-repo-config.sh | 5 +++++
2 files changed, 8 insertions(+), 3 deletions(-)
diff --git a/config.c b/config.c
index 738b244..e25b7d6 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) {
@@ -72,9 +73,8 @@ static char *parse_value(void)
}
}
if (space) {
- if (len)
+ for (; space; --space)
value[len++] = ' ';
- space = 0;
}
if (c == '\\') {
c = get_next_char();
diff --git a/t/t1300-repo-config.sh b/t/t1300-repo-config.sh
index 8c43dcd..83b7294 100755
--- a/t/t1300-repo-config.sh
+++ b/t/t1300-repo-config.sh
@@ -755,6 +755,11 @@ echo >>result
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 &&
--
1.6.3.GIT
prev parent reply other threads:[~2009-07-30 11:42 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <47ade73f0907291750v281f3858qd3658c459dd950e8@mail.gmail.com>
2009-07-30 0:52 ` remote url format in config John te Bokkel / Tempus
2009-07-30 11:41 ` Björn Steinbrink [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20090730114157.GA5560@atjola.homenet \
--to=b.steinbrink@gmx.de \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=tanj.tanj@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).