# Bug-Report: git-svn and backslash in SVN branch name

5 messages from 2016-12-22 to 2017-02-21. Participants: Michael Fladischer, Eric Wong, Junio C Hamano.
Thread: https://gitlist.dev/t/44755

## Michael Fladischer, 2016-12-22 10:12

Subject: Bug-Report: git-svn and backslash in SVN branch name
Message-ID: <cb8cd9b1-9882-64d2-435d-40d0b2b82d59@fladi.at>
URL: https://gitlist.dev/e/cb8cd9b1-9882-64d2-435d-40d0b2b82d59%40fladi.at

```
Hi,

I'm  trying to clone a SVN repo in order to migrate it to git but i hit
a wall with SVN branch names that contain a backslash, which seems to be
allowed in SVN but prohibited in git refs:

r289 = c4cb1f0c34e741a07de9673515c853d49c5522b9
(refs/remotes/origin/dicomBaseClass)
Found possible branch point: file:///path.repo/trunk/dicomBaseClass =>
file:///path.repo/tags/dicomBaseClass%5Cv0.1, 181
Initializing parent: refs/remotes/origin/tags/dicomBaseClass\v0.1@181
W: Ignoring error from SVN, path probably does not exist: (160013):
Filesystem has no item: File not found: revision 101, path
'/trunk/dicomBaseClass'
W: Do not be alarmed at the above message git-svn is just searching
aggressively for old history.
This may take a while on large repositories
Found possible branch point: file:///path.repo/dicomBaseClass =>
file:///path.repo/trunk/dicomBaseClass, 172
Initializing parent: refs/remotes/origin/tags/dicomBaseClass\v0.1@172
fatal: update_ref failed for ref
'refs/remotes/origin/tags/dicomBaseClass\v0.1@172': refusing to update
ref with bad name
'refs/remotes/origin/tags/dicomBaseClass\v0.1@172'
update-ref -m r75 refs/remotes/origin/tags/dicomBaseClass\v0.1@172
1fe0cc23e3cd56a1087562f8ca3d2e40cd2b30d4: command returned error: 128

The tag in case is "dicomBaseClass\v0.1@172".

Is there a way to mangle those names on the fly to get rid of the
backslashes or can they be handled in any other way to be compatible
with git?

Cheers,
-- 
Michael Fladischer
Fladi.at


```

## Eric Wong, 2016-12-23 01:42

Subject: [PATCH] git-svn: escape backslashes in refnames
Message-ID: <20161223014202.GA8327@starla>
URL: https://gitlist.dev/e/20161223014202.GA8327%40starla
In-Reply-To: <cb8cd9b1-9882-64d2-435d-40d0b2b82d59@fladi.at>

```
Hi Michael, the patch below should fix things up.

Junio: this should go to 'maint', pull request below.

----------------8<---------------
Subject: [PATCH] git-svn: escape backslashes in refnames

This brings git-svn refname escaping up-to-date with
commit a4c2e69936df8dd0b071b85664c6cc6a4870dd84
("Disallow '\' in ref names") from May 2009.

Reported-by: Michael Fladischer <michael@fladi.at>
Message-ID: <cb8cd9b1-9882-64d2-435d-40d0b2b82d59@fladi.at>
Signed-off-by: Eric Wong <e@80x24.org>
---
  The following changes since commit a274e0a036ea886a31f8b216564ab1b4a3142f6c:

    Sync with maint-2.10 (2016-12-05 11:25:47 -0800)

  are available in the git repository at:

    git://bogomips.org/git-svn.git svn-escape-backslash

  for you to fetch changes up to 22af6fef9b6538c9e87e147a920be9509acf1ddd:

    git-svn: escape backslashes in refnames (2016-12-23 01:37:36 +0000)

  ----------------------------------------------------------------
  Eric Wong (1):
        git-svn: escape backslashes in refnames

   perl/Git/SVN.pm | 2 +-
   1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/perl/Git/SVN.pm b/perl/Git/SVN.pm
index 711d2687a3..98518f4ddb 100644
--- a/perl/Git/SVN.pm
+++ b/perl/Git/SVN.pm
@@ -490,7 +490,7 @@ sub refname {
 	#
 	# Additionally, % must be escaped because it is used for escaping
 	# and we want our escaped refname to be reversible
-	$refname =~ s{([ \%~\^:\?\*\[\t])}{sprintf('%%%02X',ord($1))}eg;
+	$refname =~ s{([ \%~\^:\?\*\[\t\\])}{sprintf('%%%02X',ord($1))}eg;
 
 	# no slash-separated component can begin with a dot .
 	# /.* becomes /%2E*
-- 
EW

```

## Michael Fladischer, 2016-12-23 07:06

Subject: Re: [PATCH] git-svn: escape backslashes in refnames
Message-ID: <cb6a6ea2-aaa2-8522-a7e2-44e1bc540338@fladi.at>
URL: https://gitlist.dev/e/cb6a6ea2-aaa2-8522-a7e2-44e1bc540338%40fladi.at
In-Reply-To: <20161223014202.GA8327@starla>

```
On 2016-12-23 02:42, Eric Wong wrote:
> Hi Michael, the patch below should fix things up.

Thank you Eric, I was able to successfully fetch the SVN tag with your
patch applied.

Cheers,
-- 
Michael Fladischer
Fladi.at


```

## Eric Wong, 2017-02-21 04:54

Subject: Re: [PATCH] git-svn: escape backslashes in refnames
Message-ID: <20170221045420.GA24048@whir>
URL: https://gitlist.dev/e/20170221045420.GA24048%40whir
In-Reply-To: <20161223014202.GA8327@starla>

```
Junio: ping?

https://public-inbox.org/git/20161223014202.GA8327@starla/raw

Thanks.

```

## Junio C Hamano, 2017-02-21 06:02

Subject: Re: [PATCH] git-svn: escape backslashes in refnames
Message-ID: <xmqq4lzohyij.fsf@gitster.mtv.corp.google.com>
URL: https://gitlist.dev/e/xmqq4lzohyij.fsf%40gitster.mtv.corp.google.com
In-Reply-To: <20170221045420.GA24048@whir>

```
Eric Wong <e@80x24.org> writes:

> Junio: ping?
>
> https://public-inbox.org/git/20161223014202.GA8327@starla/raw
>
> Thanks.

Thanks for reminding.  This indeed fell thru cracks.

```
