Skip to content

Commit d1a8d0e

Browse files
Eric Wonggitster
authored andcommitted
git-svn: fix cloning of HTTP URLs with '+' in their path
With this, git svn clone -s http://svn.gnome.org/svn/gtk+ is successful. Also modified the funky rename test for this, which _does_ include escaped '+' signs for HTTP URLs. SVN seems to accept either "+" or "%2B" in filenames and directories (just not the main URL), so I'll leave it alone for now. Signed-off-by: Eric Wong <normalperson@yhbt.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
1 parent 737922a commit d1a8d0e

File tree

3 files changed

+42
-4
lines changed

3 files changed

+42
-4
lines changed

git-svn.perl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3673,7 +3673,7 @@ sub escape_uri_only {
36733673
my ($uri) = @_;
36743674
my @tmp;
36753675
foreach (split m{/}, $uri) {
3676-
s/([^\w.%-]|%(?![a-fA-F0-9]{2}))/sprintf("%%%02X",ord($1))/eg;
3676+
s/([^\w.%+-]|%(?![a-fA-F0-9]{2}))/sprintf("%%%02X",ord($1))/eg;
36773677
push @tmp, $_;
36783678
}
36793679
join('/', @tmp);

t/lib-git-svn.sh

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,11 +73,16 @@ for d in \
7373
done
7474

7575
start_httpd () {
76+
repo_base_path="$1"
7677
if test -z "$SVN_HTTPD_PORT"
7778
then
7879
echo >&2 'SVN_HTTPD_PORT is not defined!'
7980
return
8081
fi
82+
if test -z "$repo_base_path"
83+
then
84+
repo_base_path=svn
85+
fi
8186

8287
mkdir "$GIT_DIR"/logs
8388

@@ -90,13 +95,13 @@ LockFile logs/accept.lock
9095
Listen 127.0.0.1:$SVN_HTTPD_PORT
9196
LoadModule dav_module $SVN_HTTPD_MODULE_PATH/mod_dav.so
9297
LoadModule dav_svn_module $SVN_HTTPD_MODULE_PATH/mod_dav_svn.so
93-
<Location /svn>
98+
<Location /$repo_base_path>
9499
DAV svn
95100
SVNPath $rawsvnrepo
96101
</Location>
97102
EOF
98103
"$SVN_HTTPD_PATH" -f "$GIT_DIR"/httpd.conf -k start
99-
svnrepo=http://127.0.0.1:$SVN_HTTPD_PORT/svn
104+
svnrepo="http://127.0.0.1:$SVN_HTTPD_PORT/$repo_base_path"
100105
}
101106

102107
stop_httpd () {

t/t9115-git-svn-dcommit-funky-renames.sh

Lines changed: 34 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ test_description='git-svn dcommit can commit renames of files with ugly names'
99

1010
test_expect_success 'load repository with strange names' "
1111
svnadmin load -q $rawsvnrepo < ../t9115/funky-names.dump &&
12-
start_httpd
12+
start_httpd gtk+
1313
"
1414

1515
test_expect_success 'init and fetch repository' "
@@ -49,6 +49,39 @@ test_expect_success 'rename pretty file into ugly one' '
4949
git svn dcommit
5050
'
5151

52+
test_expect_success 'add a file with plus signs' '
53+
echo .. > +_+ &&
54+
git update-index --add +_+ &&
55+
git commit -m plus &&
56+
mkdir gtk+ &&
57+
git mv +_+ gtk+/_+_ &&
58+
git commit -m plus_dir &&
59+
git svn dcommit
60+
'
61+
62+
test_expect_success 'clone the repository to test rebase' "
63+
git svn clone $svnrepo test-rebase &&
64+
cd test-rebase &&
65+
echo test-rebase > test-rebase &&
66+
git add test-rebase &&
67+
git commit -m test-rebase &&
68+
cd ..
69+
"
70+
71+
test_expect_success 'make a commit to test rebase' "
72+
echo test-rebase-main > test-rebase-main &&
73+
git add test-rebase-main &&
74+
git commit -m test-rebase-main &&
75+
git svn dcommit
76+
"
77+
78+
test_expect_success 'git-svn rebase works inside a fresh-cloned repository' "
79+
cd test-rebase &&
80+
git svn rebase &&
81+
test -e test-rebase-main &&
82+
test -e test-rebase
83+
"
84+
5285
stop_httpd
5386

5487
test_done

0 commit comments

Comments
 (0)