git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH] translate bad characters in refnames during git-svn fetch

From
MKmartin f krafft <madduck@madduck.net>
Date
Jul 17, 2007, 13:17 UTC
Message-ID
<20070717131719.GB19724@piper.oerlikon.madduck.net>
In-Reply-To
<20070717122852.GA21372@mayonaise>
also sprach Eric Wong <normalperson@yhbt.net> [2007.07.17.1428 +0200]:
> I like it, too.  How about something like the two functions below?
> This will break things a bit for people currently using % in
> refnames, however.

Well, wait. git-svn usually works in its own repo, and if that's tracked by another repo, then it is tracked under the remote/whatever namespace, so there should not be any conflicts. You also hardly ever run git-svn to clone stuff *into* an existing repo, so there can't be conflicts with existing refnames-with-%. Thus the only breakage is if a person creates a new refname inside a git-svn repo, which uses % in such a way as to collide with an imported branch/tag/whatever from git-svn. That's not breakage, since git will just refuse to do it.

Remember that we're only translating from <char> -> %XX, never the other way around, really. Okay, we might be during git-svn rebase/dcommit, but only for those refnames which we store in .git/svn/ anyway. So a user-specified refname containing % will not be a problem, will it?

> I think this will work rather nicely once I've figured out how the path
> globbing code works[1] and where to sanitize/desanitize the refnames
> properly.

I am glad you're having the same problem; makes me feel less stupid. :)

>   Somebody naming directories on the SVN side with the path component
>   ":refs/remotes" in them could screw things up for us.

Those people should be tarred and feathered. git owns the trademark on these names.

Show 6 quoted lines
> sub desanitize_ref_name {
> 	my ($refname) = @_;
> 	$refname =~ s{%(?:([0-9A-F]{2})}{chr hex($1)}g;
> 
> 	$refname;
> }

We could make it escape to %25; instead of %25. That's ugly but it would make desanitation a little safer.

> > On the other hand, we could make the translation regexps
> > configurable...
> 
> Hopefully not needed.  I fear it would just add to confusion.
I was thinking about something like.
  git-svn clone ...
  ...
  error: remote branch/tagn name includes ~, which git does not
  allow. please specify a replacement character in .git/config

and then have config.svn-remote.svn.translations simply be a list of pairs in vim pairlist syntax:

  ~:!,^:#,.:\,
-- 
martin;              (greetings from the heart of the sun.)
  \____ echo mailto: !#^."<*>"|tr "<*> mailto:" net@madduck
 
spamtraps: madduck.bogus@madduck.net
 
"it is easier to be a lover than a husband for the simple reason
 that it is more difficult to be witty every day
 than to say pretty things from time to time."
                                                   -- honoré de balzac
Previous: Eric WongNext: Robert Ewald
Message 6 of 10 in “translate bad characters in refnames during git-svn fetch”
  1. translate bad characters in refnames during git-svn fetchmartin f krafft, Jul 15, 2007
  2. Eric WongJul 16, 2007
  3. Jan HudecJul 16, 2007
  4. martin f krafftJul 16, 2007
  5. Eric WongJul 17, 2007
  6. martin f krafftJul 17, 2007
  7. Robert EwaldJul 26, 2007
  8. Martin F KrafftJul 26, 2007
  9. Mike HommeyJul 28, 2007
  10. David KastrupJul 28, 2007

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.