# [PATCH] Canonicalize svn urls to prevent libsvn assertion

2 messages from 2009-06-26 to 2009-06-26. Participants: Ulrich Dangel, Eric Wong.
Thread: https://gitlist.dev/t/19944

## Ulrich Dangel, 2009-06-26 14:52

Subject: [PATCH] Canonicalize svn urls to prevent libsvn assertion
Message-ID: <1246027929-2792-1-git-send-email-uli@spamt.net>
URL: https://gitlist.dev/e/1246027929-2792-1-git-send-email-uli%40spamt.net

```
Cloning/initializing svn repositories with an uncanonicalize url does not
work as libsvn throws an assertion. This patch canonicalize svn uris for the
clone and init command from git-svn.

Signed-off-by: Ulrich Dangel <uli@spamt.net>
---
 git-svn.perl |    9 ++++++++-
 1 files changed, 8 insertions(+), 1 deletions(-)

diff --git a/git-svn.perl b/git-svn.perl
index 3301797..5130a8c 100755
--- a/git-svn.perl
+++ b/git-svn.perl
@@ -380,6 +380,7 @@ sub cmd_init {
 	}
 	my $url = shift or die "SVN repository location required ",
 	                       "as a command-line argument\n";
+	$url = canonicalize_url($url);
 	init_subdir(@_);
 	do_git_init_db();
 
@@ -741,6 +742,12 @@ sub canonicalize_path {
 	return $path;
 }
 
+sub canonicalize_url {
+	my ($url) = @_;
+	$url =~ s#^([^:]+://[^/]*/)(.*)$#$1 . canonicalize_path($2)#e;
+	return $url;
+}
+
 # get_svnprops(PATH)
 # ------------------
 # Helper for cmd_propget and cmd_proplist below.
@@ -810,7 +817,7 @@ sub cmd_multi_init {
 
 	$_prefix = '' unless defined $_prefix;
 	if (defined $url) {
-		$url =~ s#/+$##;
+		$url = canonicalize_url($url);    
 		init_subdir(@_);
 	}
 	do_git_init_db();
-- 
1.6.3.1

```

## Eric Wong, 2009-06-26 21:49

Subject: Re: [PATCH] Canonicalize svn urls to prevent libsvn assertion
Message-ID: <20090626214957.GA12855@dcvr.yhbt.net>
URL: https://gitlist.dev/e/20090626214957.GA12855%40dcvr.yhbt.net
In-Reply-To: <1246027929-2792-1-git-send-email-uli@spamt.net>

```
Ulrich Dangel <uli@spamt.net> wrote:
> Cloning/initializing svn repositories with an uncanonicalize url does not
> work as libsvn throws an assertion. This patch canonicalize svn uris for the
> clone and init command from git-svn.
> 
> Signed-off-by: Ulrich Dangel <uli@spamt.net>

Thanks,

I'm not getting any assertions in my version of SVN (1.5.1) but it
actually does cause issues with path stripping when following
repositories.

Acked-by: Eric Wong <normalperson@yhbt.net>
..and pushed out to git://git.bogomips.org/git-svn

There was a minor trailing whitespace issue which I fixed, too

-- 
Eric Wong

```
