* remote url format in config
[not found] <47ade73f0907291750v281f3858qd3658c459dd950e8@mail.gmail.com>
@ 2009-07-30 0:52 ` John te Bokkel / Tempus
2009-07-30 11:41 ` [PATCH] config: Keep inner whitespace verbatim Björn Steinbrink
0 siblings, 1 reply; 2+ messages in thread
From: John te Bokkel / Tempus @ 2009-07-30 0:52 UTC (permalink / raw)
To: git
There is a bug in the way the url is stored for remote urls. It is
really a minor problem and easily worked around. However it may a good
idea for the future to url encode that string.
What happened:
added a remote with two consecutive spaces in the url.
git remote add local_remote /dir/folder with\ \ -\ \ two consecutive\
\ spaces/project.git
git push local_remote master
error: url with only single spaces is not a git repo
the .git/config url is written correctly however it gets munged when
it is read from the config.
url = /dir/folder with - two consecutive spaces/project.git
to make it work correctly, just quote it.
url = "/dir/folder with - two consecutive spaces/project.git"
perhaps it would be a good idea to url encode the url when it is first
written to the config file.
url = /dir/folder%20with%20%20-%20%20two%20consecutive%20%20spaces/project.git
^ permalink raw reply [flat|nested] 2+ messages in thread
* [PATCH] config: Keep inner whitespace verbatim
2009-07-30 0:52 ` remote url format in config John te Bokkel / Tempus
@ 2009-07-30 11:41 ` Björn Steinbrink
0 siblings, 0 replies; 2+ messages in thread
From: Björn Steinbrink @ 2009-07-30 11:41 UTC (permalink / raw)
To: John te Bokkel / Tempus; +Cc: git, Junio C Hamano
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
^ permalink raw reply related [flat|nested] 2+ messages in thread
end of thread, other threads:[~2009-07-30 11:42 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[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 ` [PATCH] config: Keep inner whitespace verbatim Björn Steinbrink
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).