{"thread":{"id":"26856","subject":"Re: [msysGit] Trailing spaces in branchname (git-svn)","startedAt":"2011-03-24T21:26:42Z","lastAt":"2011-06-21T22:16:43Z","messageCount":5,"participants":["Erik Faye-Lund","Magnus Kallström"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"164257","messageId":"AANLkTinZnd0R8Rnv4kaiJAGP0qKEwgbU+nP=donmbEbp@mail.gmail.com","threadId":"26856","inReplyTo":"0014af8a-3b24-4398-88aa-7a3e460f2283@s11g2000yqh.googlegroups.com","subject":"Re: [msysGit] Trailing spaces in branchname (git-svn)","fromName":"Erik Faye-Lund","fromEmail":"kusmabite@gmail.com","sentAt":"2011-03-24T21:26:42Z","receivedAt":"2011-03-24T21:26:42Z","isPatch":false,"sender":{"key":"kusmabite@gmail.com","avatar":"https://avatars.githubusercontent.com/u/47073?v=4"},"body":"On Thu, Mar 24, 2011 at 9:16 PM, Barthus <magnus.kallstrom@gmail.com> wrote:\n> I am trying to clone a subversion repository that has a branchname\n> with a trailing space. Since I can't find a solution I downloaded the\n> code to try to understand the problem. Since I am not familiar with\n> perl it is a bit hard for me. This is what I have found out so far:\n>\n> In git-svn.perl:\n> tmp_index_do is called and tries to create the folder with the\n> trailing space (under svn/refs/remotes) with the following line of\n> code:\n> mkpath([$dir]) unless -d $dir;\n> reading the solution above, I figured that I should be able to\n> \"sanitize\" the path -reusing som code already existing in the script:\n>        sub refname\n> I then tried to:\n> git svn fetch\n>\n> Now the folder gets created, but then some lockfile is supposed to be\n> created (with the trailing space in the path), and it fails again.\n>\n> I have not been able to locate the call that tries to create the\n> lockfile (yet), and I guess there will be more fileoperations made to\n> the folder. If I manage to figure out the code my theory now is to\n> \"sanitize\" the branchname in the structure where it is contained when\n> it comes from subversion (possibly adding a \"sanitized\" storage to not\n> destroy the original name if it is needed), and see if the clone/fetch\n> can continue.\n>\n> My hope is though, that someone who understands this maybe can fix it,\n> or maybe point me in the right direction.\n\nThis kind of question is usually better to ask on the main Git mailing\nlist, as it's not really Windows specific.\n"},{"id":"170066","messageId":"BANLkTikaeXxRMJErAYy3-LSrvfNZXAbEEw@mail.gmail.com","threadId":"26856","inReplyTo":"12ada6de-4345-4259-b832-371a74df9775@l6g2000vbn.googlegroups.com","subject":"Re: Trailing spaces in branchname (git-svn)","fromName":"Erik Faye-Lund","fromEmail":"kusmabite@gmail.com","sentAt":"2011-06-15T14:00:10Z","receivedAt":"2011-06-15T14:00:10Z","isPatch":false,"sender":{"key":"kusmabite@gmail.com","avatar":"https://avatars.githubusercontent.com/u/47073?v=4"},"body":"Please don't cull the CC-list.\n\nOn Wed, Jun 15, 2011 at 3:38 PM, Barthus <magnus.kallstrom@gmail.com> wrote:\n>\n>> This kind of question is usually better to ask on the main Git mailing\n>> list, as it's not really Windows specific.\n>\n> I found a similar (older) thread in the git-mailing-list, discussing\n> the same issue. This led me to try cloning the same repository on a\n> Linux-machine - with success. Linux (at least my distro - Ubuntu)\n> handles trailing spaces in directory names.\n>\n> Isn't this a msysgit-issue? (I just want to make sure that I don't\n> spend my (and your) time in the wrong place)\n\nIf it works on Linux then yes, it's probably a Git for Windows issue.\n\nSome quick testing reveals that paths can have a trailing space on\nLinux, but not on Windows. It sounds to me like you need to modify the\nrefname subroutine in git-svn.perl to escape this. Something like this\nseems to work for me:\n---8<---\ndiff --git a/git-svn.perl b/git-svn.perl\nindex 7849cfc..7a44145 100755\n--- a/git-svn.perl\n+++ b/git-svn.perl\n@@ -2126,6 +2126,9 @@ sub refname {\n \t# @{ becomes %40{\n \t$refname =~ s{\\@\\{}{%40\\{}g;\n\n+\t# trailing space is not not allowed on Windows\n+\t$refname =~ s{ $}{%20};\n+\n \treturn $refname;\n }\n\n\n---8<---\nIf it works for you, I'll submit a proper patch for it.\n"},{"id":"170069","messageId":"BANLkTikgF53tKbUsJJznENAiW8Smm5ePPA@mail.gmail.com","threadId":"26856","inReplyTo":"b8767de1-ab2c-4d2a-9024-9ad9b29c614d@j9g2000vbs.googlegroups.com","subject":"Re: [msysGit] Re: Trailing spaces in branchname (git-svn)","fromName":"Erik Faye-Lund","fromEmail":"kusmabite@gmail.com","sentAt":"2011-06-15T14:38:15Z","receivedAt":"2011-06-15T14:38:15Z","isPatch":false,"sender":{"key":"kusmabite@gmail.com","avatar":"https://avatars.githubusercontent.com/u/47073?v=4"},"body":"Again, please don't cull the CC-list. When replying, hit \"reply all\"\nin your e-mail client.\n\nAlso, please don't top-post either. It makes it harder for others to\nfollow the discussion. I've corrected the quoting this time.\n\nOn Wed, Jun 15, 2011 at 4:12 PM, Barthus <magnus.kallstrom@gmail.com> wrote:\n> On 15 Juni, 16:00, Erik Faye-Lund <kusmab...@gmail.com> wrote:\n>> Please don't cull the CC-list.\n>>\n>> On Wed, Jun 15, 2011 at 3:38 PM, Barthus <magnus.kallst...@gmail.com> wrote:\n>>\n>> >> This kind of question is usually better to ask on the main Git mailing\n>> >> list, as it's not really Windows specific.\n>>\n>> > I found a similar (older) thread in the git-mailing-list, discussing\n>> > the same issue. This led me to try cloning the same repository on a\n>> > Linux-machine - with success. Linux (at least my distro - Ubuntu)\n>> > handles trailing spaces in directory names.\n>>\n>> > Isn't this a msysgit-issue? (I just want to make sure that I don't\n>> > spend my (and your) time in the wrong place)\n>>\n>> If it works on Linux then yes, it's probably a Git for Windows issue.\n>>\n>> Some quick testing reveals that paths can have a trailing space on\n>> Linux, but not on Windows. It sounds to me like you need to modify the\n>> refname subroutine in git-svn.perl to escape this. Something like this\n>> seems to work for me:\n>> ---8<---\n>> diff --git a/git-svn.perl b/git-svn.perl\n>> index 7849cfc..7a44145 100755\n>> --- a/git-svn.perl\n>> +++ b/git-svn.perl\n>> @@ -2126,6 +2126,9 @@ sub refname {\n>>         # @{ becomes %40{\n>>         $refname =~ s{\\@\\{}{%40\\{}g;\n>>\n>> +       # trailing space is not not allowed on Windows\n>> +       $refname =~ s{ $}{%20};\n>> +\n>>         return $refname;\n>>  }\n>>\n>> ---8<---\n>> If it works for you, I'll submit a proper patch for it.\n>\n> Ok, thanks. I'll try as soon as possible (will be away for a few\n> days...)\n>\n\nYou might want to try this patch instead, as it deals with refnames\nlike \"foo /bar\" and \"foo \\bar\" also:\n\ndiff --git a/git-svn.perl b/git-svn.perl\nindex 7849cfc..54894e4 100755\n--- a/git-svn.perl\n+++ b/git-svn.perl\n@@ -2126,6 +2126,9 @@ sub refname {\n \t# @{ becomes %40{\n \t$refname =~ s{\\@\\{}{%40\\{}g;\n\n+\t# trailing space is not not allowed on Windows\n+\t$refname =~ s{ (?=/|\\\\|$)}{%20}g;\n+\n \treturn $refname;\n }\n"},{"id":"170085","messageId":"58D5F1F8-CC94-4629-B476-91512ED35E0E@gmail.com","threadId":"26856","inReplyTo":"BANLkTikgF53tKbUsJJznENAiW8Smm5ePPA@mail.gmail.com","subject":"Re: Re: Trailing spaces in branchname (git-svn)","fromName":"Magnus Kallström","fromEmail":"magnus.kallstrom@gmail.com","sentAt":"2011-06-15T21:13:32Z","receivedAt":"2011-06-15T21:13:32Z","isPatch":false,"sender":{"key":"magnus.kallstrom@gmail.com","avatar":null},"body":"(I hope I get it right now - previously I used Googles web-interface, and I just couldn't find a way to respond to all. Trying from my email client instead now... I have even read the 'Welcome post' again :) )\n\nUnfortunately, the patch didn't work.\n\nThis is the error I get when it aborts:\nFound branch parent: (refs/remotes/CR3533 sÃ¶kning pÃ¥ fakturabelopp ) be4dd98d152d82f098b90089f4df6a2d411d84e1\nfatal: Unable to create 'd:/Dev/GIT/svk/KOB/.git/svn/refs/remotes/CR3533 sökning på fakturabelopp /index.lock': No such file or directory\nread-tree be4dd98d152d82f098b90089f4df6a2d411d84e1: command returned error: 128\n\nThe patch itself is probably working for other parts, and I even tried a similar patch back in March. I never managed to figure out where the call to the locking-function got it's path though. "},{"id":"170429","messageId":"BANLkTinmmk2KRTBy8rZLhpksK_wqM49_aw@mail.gmail.com","threadId":"26856","inReplyTo":"58D5F1F8-CC94-4629-B476-91512ED35E0E@gmail.com","subject":"Re: Re: Trailing spaces in branchname (git-svn)","fromName":"Magnus Kallström","fromEmail":"magnus.kallstrom@gmail.com","sentAt":"2011-06-21T22:16:43Z","receivedAt":"2011-06-21T22:16:43Z","isPatch":false,"sender":{"key":"magnus.kallstrom@gmail.com","avatar":null},"body":"2011/6/15 Magnus Kallström <magnus.kallstrom@gmail.com>\n\n> (I hope I get it right now - previously I used Googles web-interface, and I\n> just couldn't find a way to respond to all. Trying from my email client\n> instead now... I have even read the 'Welcome post' again :) )\n>\n> Unfortunately, the patch didn't work.\n>\n> This is the error I get when it aborts:\n> Found branch parent: (refs/remotes/CR3533 sÃ¶kning pÃ¥ fakturabelopp )\n> be4dd98d152d82f098b90089f4df6a2d411d84e1\n> fatal: Unable to create 'd:/Dev/GIT/svk/KOB/.git/svn/refs/remotes/CR3533\n> sökning på fakturabelopp /index.lock': No such file or directory\n> read-tree be4dd98d152d82f098b90089f4df6a2d411d84e1: command returned error:\n> 128\n>\n> The patch itself is probably working for other parts, and I even tried a\n> similar patch back in March. I never managed to figure out where the call to\n> the locking-function got it's path though.\n>\n\n\nHi again!\n\nI have now successfully cloned \"my\" repository with the following changes in\ngit-svn.perl. I'm not sure if the change in \"sub refname\" is needed, but I\nwill try to reproduce the error when I find the time for it (the full clone\nfails after 2-3 days).\n\nI can't tell if it breaks anything else, but as far as I can tell, the clone\nis working.\n\nDoes it look as if the modification is done in the right place?\n\n/Magnus\n\n---8<---\ndiff --git a/git-svn.perl b/git-svn.perl\nindex 7849cfc..c5e2d23 100755\n--- a/git-svn.perl\n+++ b/git-svn.perl\n@@ -2126,6 +2126,9 @@ sub refname {\n     # @{ becomes %40{\n     $refname =~ s{\\@\\{}{%40\\{}g;\n\n+    # trailing space is not not allowed on Windows\n+    $refname =~ s{ (?=/|\\\\|$)}{%20}g;\n+\n     return $refname;\n }\n\n@@ -3883,6 +3886,7 @@ sub _new {\n     }\n\n     $_[3] = $path = '' unless (defined $path);\n+    $dir =~ s{ (?=/|\\\\|$)}{%20}g;\n     mkpath([$dir]);\n     bless {\n         ref_id => $ref_id, dir => $dir, index => \"$dir/index\",\n---8<---\n"}]}