# [PATCH] git-svn: URL-decode the left-hand side of an svn refspec

4 messages from 2010-08-03 to 2010-08-05. Participants: Steven Walter, Eric Wong.
Thread: https://gitlist.dev/t/24625

## Steven Walter, 2010-08-03 23:21

Subject: [PATCH] git-svn: URL-decode the left-hand side of an svn refspec
Message-ID: <1280877685-4928-1-git-send-email-stevenrwalter@gmail.com>
URL: https://gitlist.dev/e/1280877685-4928-1-git-send-email-stevenrwalter%40gmail.com

```
From: Steven Walter <swalter@lpdev.prtdev.lexmark.com>

This change allows git-svn to handle an URL with colons in the path
---
 git-svn.perl |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)

diff --git a/git-svn.perl b/git-svn.perl
index af70353..5d08dc6 100755
--- a/git-svn.perl
+++ b/git-svn.perl
@@ -1812,6 +1812,8 @@ sub read_all_remotes {
 			die("svn-remote.$remote: remote ref '$remote_ref' "
 			    . "must start with 'refs/'\n")
 				unless $remote_ref =~ m{^refs/};
+                        # local_ref is an URL, so url-decode it
+                        $local_ref =~ s/\%([A-Fa-f0-9]{2})/pack('C', hex($1))/seg;
 			$r->{$remote}->{fetch}->{$local_ref} = $remote_ref;
 			$r->{$remote}->{svm} = {} if $use_svm_props;
 		} elsif (m!^(.+)\.usesvmprops=\s*(.*)\s*$!) {
-- 
1.7.0.3.gaa64d.dirty

```

## Eric Wong, 2010-08-04 08:38

Subject: Re: [PATCH] git-svn: URL-decode the left-hand side of an svn refspec
Message-ID: <20100804083840.GA19367@dcvr.yhbt.net>
URL: https://gitlist.dev/e/20100804083840.GA19367%40dcvr.yhbt.net
In-Reply-To: <1280877685-4928-1-git-send-email-stevenrwalter@gmail.com>

```
Steven Walter <stevenrwalter@gmail.com> wrote:
> From: Steven Walter <swalter@lpdev.prtdev.lexmark.com>
> 
> This change allows git-svn to handle an URL with colons in the path
> ---
>  git-svn.perl |    2 ++
>  1 files changed, 2 insertions(+), 0 deletions(-)

Thanks Steven.

Since git-svn already has a uri_decode() function, we should use that.
The decoding should apply to the local portion of branches/tags globs,
too.  Does the following work for you?

diff --git a/git-svn.perl b/git-svn.perl
index 8d2ef3d..34884b8 100755
--- a/git-svn.perl
+++ b/git-svn.perl
@@ -1820,6 +1820,7 @@ sub read_all_remotes {
 			die("svn-remote.$remote: remote ref '$remote_ref' "
 			    . "must start with 'refs/'\n")
 				unless $remote_ref =~ m{^refs/};
+			$local_ref = uri_decode($local_ref);
 			$r->{$remote}->{fetch}->{$local_ref} = $remote_ref;
 			$r->{$remote}->{svm} = {} if $use_svm_props;
 		} elsif (m!^(.+)\.usesvmprops=\s*(.*)\s*$!) {
@@ -1832,6 +1833,7 @@ sub read_all_remotes {
 			die("svn-remote.$remote: remote ref '$remote_ref' ($t) "
 			    . "must start with 'refs/'\n")
 				unless $remote_ref =~ m{^refs/};
+			$local_ref = uri_decode($local_ref);
 			my $rs = {
 			    t => $t,
 			    remote => $remote,
-- 
Eric Wong

```

## Steven Walter, 2010-08-04 12:37

Subject: Re: [PATCH] git-svn: URL-decode the left-hand side of an svn refspec
Message-ID: <AANLkTi=5qEhYABJv8CBxXwOY-UKkRc05bO=kKYkborKq@mail.gmail.com>
URL: https://gitlist.dev/e/AANLkTi%3D5qEhYABJv8CBxXwOY-UKkRc05bO%3DkKYkborKq%40mail.gmail.com
In-Reply-To: <20100804083840.GA19367@dcvr.yhbt.net>

```
On Wed, Aug 4, 2010 at 4:38 AM, Eric Wong <normalperson@yhbt.net> wrote:
> Thanks Steven.
>
> Since git-svn already has a uri_decode() function, we should use that.
> The decoding should apply to the local portion of branches/tags globs,
> too.  Does the following work for you?
>
> diff --git a/git-svn.perl b/git-svn.perl
> index 8d2ef3d..34884b8 100755
> --- a/git-svn.perl
> +++ b/git-svn.perl
> @@ -1820,6 +1820,7 @@ sub read_all_remotes {
>                        die("svn-remote.$remote: remote ref '$remote_ref' "
>                            . "must start with 'refs/'\n")
>                                unless $remote_ref =~ m{^refs/};
> +                       $local_ref = uri_decode($local_ref);
>                        $r->{$remote}->{fetch}->{$local_ref} = $remote_ref;
>                        $r->{$remote}->{svm} = {} if $use_svm_props;
>                } elsif (m!^(.+)\.usesvmprops=\s*(.*)\s*$!) {
> @@ -1832,6 +1833,7 @@ sub read_all_remotes {
>                        die("svn-remote.$remote: remote ref '$remote_ref' ($t) "
>                            . "must start with 'refs/'\n")
>                                unless $remote_ref =~ m{^refs/};
> +                       $local_ref = uri_decode($local_ref);
>                        my $rs = {
>                            t => $t,
>                            remote => $remote,
> --
> Eric Wong
>

Yes, this works.  Thanks!
-- 
-Steven Walter <stevenrwalter@gmail.com>

```

## Eric Wong, 2010-08-05 06:40

Subject: Re: [PATCH] git-svn: URL-decode the left-hand side of an svn refspec
Message-ID: <20100805064055.GA4319@dcvr.yhbt.net>
URL: https://gitlist.dev/e/20100805064055.GA4319%40dcvr.yhbt.net
In-Reply-To: <AANLkTi=5qEhYABJv8CBxXwOY-UKkRc05bO=kKYkborKq@mail.gmail.com>

```
Steven Walter <stevenrwalter@gmail.com> wrote:
> On Wed, Aug 4, 2010 at 4:38 AM, Eric Wong <normalperson@yhbt.net> wrote:
> > Thanks Steven.
> >
> > Since git-svn already has a uri_decode() function, we should use that.
> > The decoding should apply to the local portion of branches/tags globs,
> > too.  Does the following work for you?
<snip>
> Yes, this works.  Thanks!

Thanks Steven, I've pushed the following out for Junio at
git://git.bogomips.org/git-svn

From 46cb16fb599451f417e7cd668e77866f5aa03fc0 Mon Sep 17 00:00:00 2001
From: Steven Walter <swalter@lpdev.prtdev.lexmark.com>
Date: Tue, 3 Aug 2010 19:21:25 -0400
Subject: [PATCH] git svn: URL-decode left-hand side of svn refspec

This change allows git-svn to handle an URL with colons in the path

[ew: rewritten to use uri_decode() function]

Signed-off-by: Eric Wong <normalperson@yhbt.net>
---
 git-svn.perl |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)

diff --git a/git-svn.perl b/git-svn.perl
index 8d2ef3d..34884b8 100755
--- a/git-svn.perl
+++ b/git-svn.perl
@@ -1820,6 +1820,7 @@ sub read_all_remotes {
 			die("svn-remote.$remote: remote ref '$remote_ref' "
 			    . "must start with 'refs/'\n")
 				unless $remote_ref =~ m{^refs/};
+			$local_ref = uri_decode($local_ref);
 			$r->{$remote}->{fetch}->{$local_ref} = $remote_ref;
 			$r->{$remote}->{svm} = {} if $use_svm_props;
 		} elsif (m!^(.+)\.usesvmprops=\s*(.*)\s*$!) {
@@ -1832,6 +1833,7 @@ sub read_all_remotes {
 			die("svn-remote.$remote: remote ref '$remote_ref' ($t) "
 			    . "must start with 'refs/'\n")
 				unless $remote_ref =~ m{^refs/};
+			$local_ref = uri_decode($local_ref);
 			my $rs = {
 			    t => $t,
 			    remote => $remote,
-- 
Eric Wong

```
