git-svn: fix URL canonicalization during init w/ SVN 1.7+
URL canonicalization when full URLs are passed became broken when using SVN::_Core::svn_dirent_canonicalize under SVN 1.7. Ensure we canonicalize paths and URLs with appropriate functions for each type from now on as the path/URL-agnostic SVN::_Core::svn_path_canonicalize function is deprecated in SVN. Tested with the following commands: git svn init -T svn://svn.code.sf.net/p/squirrelmail/code/trunk git svn init -b svn://svn.code.sf.net/p/squirrelmail/code/branches Reported-by: Adam Dinwoodie <adam@dinwoodie.org> http://mid.gmane.org/20160315162344.GM29016@dinwoodie.org Signed-off-by: Eric Wong <normalperson@yhbt.net>
Eric Wong committed
Mar 16, 2016 at 20:14 UTC
b557165311f7ed1b94d94a74e7ea3a6e76bbbe88
2 files changed
+9
-7
git-svn.perl
+8
-6
@@ -1745,11 +1745,12 @@ sub post_fetch_checkout {
1745
1746
sub complete_svn_url {
1747
my ($url, $path) = @_;
1748
- $path = canonicalize_path($path);
1748
1750
- # If the path is not a URL...
1751
- if ($path !~ m#^[a-z\+]+://#) {
1752
- if (!defined $url || $url !~ m#^[a-z\+]+://#) {
1749
+ if ($path =~ m#^[a-z\+]+://#i) { # path is a URL
1750
+ $path = canonicalize_url($path);
1751
+ } else {
1752
+ $path = canonicalize_path($path);
1753
+ if (!defined $url || $url !~ m#^[a-z\+]+://#i) {
1754
fatal("E: '$path' is not a complete URL ",
1755
"and a separate URL is not specified");
1756
}
@@ -1764,11 +1765,12 @@ sub complete_url_ls_init {
1765
print STDERR "W: $switch not specified\n";
1766
return;
1767
}
1767
- $repo_path = canonicalize_path($repo_path);
1768
- if ($repo_path =~ m#^[a-z\+]+://#) {
1768
+ if ($repo_path =~ m#^[a-z\+]+://#i) {
1769
+ $repo_path = canonicalize_url($repo_path);
1770
$ra = Git::SVN::Ra->new($repo_path);
1771
$repo_path = '';
1772
} else {
1773
+ $repo_path = canonicalize_path($repo_path);
1774
$repo_path =~ s#^/+##;
1775
unless ($ra) {
1776
fatal("E: '$repo_path' is not a complete URL ",
t/t9117-git-svn-init-clone.sh
+1
-1
@@ -119,7 +119,7 @@ test_expect_success 'clone with -s/-T/-b/-t and --prefix "" still works' '
119
rm -f warning
120
'
121
122
-test_expect_failure 'init with -T as a full url works' '
122
+test_expect_success 'init with -T as a full url works' '
123
test ! -d project &&
124
git svn init -T "$svnrepo"/project/trunk project &&
125
rm -rf project