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

Re: (Resend)[PATCH] git-svn: Translate invalid characters in refname

From
RERobert Ewald <robert.ewald@nov.com>
Date
Jul 30, 2007, 13:33 UTC
Message-ID
<f8kpan$t6c$1@sea.gmane.org>
In-Reply-To
<7v6442kxvu.fsf@assigned-by-dhcp.cox.net>
Junio C Hamano wrote:
Show 21 quoted lines
> Robert Ewald <robert.ewald@nov.com> writes:
> 
>> +sub refname {
>> +        my ($refname) = "refs/remotes/$_[0]->{ref_id}" ;
>> +
>> +        # It cannot end with a slash /, we'll throw up on this because
>> +        # SVN can't have directories with a slash in their name, either:
>> +        if ($refname =~ m{/$}) {
>> +                die "ref: '$refname' ends with a trailing slash, this is ",
>> +                    "not permitted by git nor Subversion\n";
>> +        }
>> +
>> +        # It cannot have ASCII control character space, tilde ~, caret ^,
>> +        # colon :, question-mark ?, asterisk *, space, or open bracket [
>> +        # anywhere.
>> +        #
>> +        # Additionally, % must be escaped because it is used for escaping
>> +        # and we want our escaped refname to be reversible
>> +        $refname =~ s{([ \%~\^:\?\*\[\t])}{uc sprintf('%%%02x',ord($1))}eg;
> 
> uc of sprintf()?  You meant "%%%02X"?

You are right. Being a total Perl noob I just took Eric's suggestion from an earlier post without really understanding everything.

> Other than that, looks sane to me.  I presume that SVN branches
> whose name would be mangled with this patch would not have been
> successfully imported with older git-svn anyway, so this won't
> introduce any regressions?

Now that you mention it, I am not entirely sure. We introduce the % which is mangled as well. It wasn't mangled before.

I now could think of a case that someone has a git-svn branch with a % in the name checked out.

When updates are fetched a new branch head would be created. It wouldn't destroy anything, but a script might break. On the other hand, the script needs to be updated anyway. So I am not sure if % should be handled separately.

> Eric?
Yes, Eric, please comment.
-- 
Robert Ewald
Previous: Junio C HamanoNext: Eric Wong
Message 3 of 6 in “(Resend)[PATCH] git-svn: Translate invalid characters in refname”
  1. Robert EwaldJul 30, 2007
  2. Junio C HamanoJul 30, 2007
  3. Robert EwaldJul 30, 2007
  4. Eric WongJul 30, 2007
  5. Junio C HamanoJul 31, 2007
  6. martin f krafftAug 15, 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.