threads / bug / 44755

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

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

## tl;dr

5 messages between Dec 22, 2016 and Feb 21, 2017.

replies: 4people: 3as markdown or json

Michael Fladischer· Dec 22, 2016, 10:12 UTC · lore
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· Dec 23, 2016, 01:42 UTC · re: Michael Fladischer · lore

[PATCH] git-svn: escape backslashes in refnames

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· Dec 23, 2016, 07:06 UTC · re: Eric Wong · lore

Re: [PATCH] git-svn: escape backslashes in refnames

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
Junio C Hamano· Feb 21, 2017, 06:02 UTC · re: Eric Wong · lore

Re: [PATCH] git-svn: escape backslashes in refnames

Eric Wong <e@80x24.org> writes:
Show 5 quoted lines
> Junio: ping?
>
> https://public-inbox.org/git/20161223014202.GA8327@starla/raw
>
> Thanks.
Thanks for reminding.  This indeed fell thru cracks.

← back to recent threads