Don't try and percent-escape existing percent escapes in git-svn URIs
git-svn project names are percent-escaped ever since f5530b8 (git-svn: support for funky branch and project names over HTTP(S), 2007-11-11). Unfortunately this breaks the scenario where the user hands git-svn an already-escaped URI. Fix the regexp to skip over what looks like existing percent escapes, and test this scenario. Signed-off-by: Kevin Ballard <kevin@sb.org> Acked-by: Eric Wong <normalperson@yhbt.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Kevin Ballard committed
Mar 20, 2008 at 16:08 UTC
8114da161611d6eb7cc6163aee2f5ba51ccad9f3
2 files changed
+32
-1
git-svn.perl
+1
-1
@@ -3665,7 +3665,7 @@ sub escape_uri_only {
3665
my ($uri) = @_;
3666
my @tmp;
3667
foreach (split m{/}, $uri) {
3668
- s/([^\w.-])/sprintf("%%%02X",ord($1))/eg;
3668
+ s/([^\w.%-]|%(?![a-fA-F0-9]{2}))/sprintf("%%%02X",ord($1))/eg;
3669
push @tmp, $_;
3670
}
3671
join('/', @tmp);
t/t9120-git-svn-clone-with-percent-escapes.sh
new
+31
@@ -0,0 +1,31 @@
1
+#!/bin/sh
2
+#
3
+# Copyright (c) 2008 Kevin Ballard
4
+#
5
+
6
+test_description='git-svn clone with percent escapes'
7
+. ./lib-git-svn.sh
8
+
9
+test_expect_success 'setup svnrepo' "
10
+ mkdir project project/trunk project/branches project/tags &&
11
+ echo foo > project/trunk/foo &&
12
+ svn import -m '$test_description' project '$svnrepo/pr ject' &&
13
+ rm -rf project &&
14
+ start_httpd
15
+"
16
+
17
+if test "$SVN_HTTPD_PORT" = ""
18
+then
19
+ test_expect_failure 'test clone with percent escapes - needs SVN_HTTPD_PORT set' 'false'
20
+else
21
+ test_expect_success 'test clone with percent escapes' '
22
+ git svn clone "$svnrepo/pr%20ject" clone &&
23
+ cd clone &&
24
+ git rev-parse refs/remotes/git-svn &&
25
+ cd ..
26
+ '
27
+fi
28
+
29
+stop_httpd
30
+
31
+test_done