Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Eric Wong committed Mar 16, 2016
1 parent 4be4d55 commit b557165
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
14 changes: 8 additions & 6 deletions git-svn.perl
Expand Up @@ -1745,11 +1745,12 @@ sub post_fetch_checkout {

sub complete_svn_url {
my ($url, $path) = @_;
$path = canonicalize_path($path);

# If the path is not a URL...
if ($path !~ m#^[a-z\+]+://#) {
if (!defined $url || $url !~ m#^[a-z\+]+://#) {
if ($path =~ m#^[a-z\+]+://#i) { # path is a URL
$path = canonicalize_url($path);
} else {
$path = canonicalize_path($path);
if (!defined $url || $url !~ m#^[a-z\+]+://#i) {
fatal("E: '$path' is not a complete URL ",
"and a separate URL is not specified");
}
Expand All @@ -1764,11 +1765,12 @@ sub complete_url_ls_init {
print STDERR "W: $switch not specified\n";
return;
}
$repo_path = canonicalize_path($repo_path);
if ($repo_path =~ m#^[a-z\+]+://#) {
if ($repo_path =~ m#^[a-z\+]+://#i) {
$repo_path = canonicalize_url($repo_path);
$ra = Git::SVN::Ra->new($repo_path);
$repo_path = '';
} else {
$repo_path = canonicalize_path($repo_path);
$repo_path =~ s#^/+##;
unless ($ra) {
fatal("E: '$repo_path' is not a complete URL ",
Expand Down
2 changes: 1 addition & 1 deletion t/t9117-git-svn-init-clone.sh
Expand Up @@ -119,7 +119,7 @@ test_expect_success 'clone with -s/-T/-b/-t and --prefix "" still works' '
rm -f warning
'

test_expect_failure 'init with -T as a full url works' '
test_expect_success 'init with -T as a full url works' '
test ! -d project &&
git svn init -T "$svnrepo"/project/trunk project &&
rm -rf project
Expand Down

0 comments on commit b557165

Please sign in to comment.