{"thread":{"id":"21306","subject":"[bug][bisected] git-svn with root branches","startedAt":"2009-10-21T14:41:13Z","lastAt":"2009-10-23T06:50:56Z","messageCount":7,"participants":["Daniel Cordero","Eric Wong"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"125603","messageId":"20091021144113.GA7440@cumin","threadId":"21306","inReplyTo":null,"subject":"[bug][bisected] git-svn with root branches","fromName":"Daniel Cordero","fromEmail":"theappleman@gmail.com","sentAt":"2009-10-21T14:41:13Z","receivedAt":"2009-10-21T14:41:13Z","isPatch":false,"sender":{"key":"theappleman@gmail.com","avatar":null},"body":"Hello,\n\nwhen trying to clone a svn repo with the command-line:\n\n\t$ git svn clone -b / http://svn.collab.net/repos/svn/\n\n(that is, each folder in the root of the repo should be considered it's\nown branch)\nthe clone sometimes[1] fails saying:\n\n\tref: 'refs/remotes/' ends with a trailing slash, this is not permitted by git nor Subversion\n\nThe offending config is:\n[svn-remote \"svn\"]\n        url = http://svn.collab.net/repos/svn\n        branches = /*:refs/remotes/*\n\n\nThis used to work in the past; I bisected the bad commit to\n\ncommit 6f5748e14cc5bb0a836b649fb8e2d6a5eb166f1d\nAuthor: Adam Brewster <adambrewster@gmail.com>\nDate:   Tue Aug 11 23:14:03 2009 -0400\n\n    svn: allow branches outside of refs/remotes\n\n\nThanks in advance.\n\n\n[1] It does work when the URL has at least 1 folder of depth\n(e.g. suffix \"trunk\" to the above URL).\n\nIts config section is:\n[svn-remote \"svn\"]\n        url = http://svn.collab.net/repos/svn\n\tbranches = trunk//*:refs/remotes/*\n"},{"id":"125676","messageId":"20091022063036.GA8081@dcvr.yhbt.net","threadId":"21306","inReplyTo":"20091021144113.GA7440@cumin","subject":"Re: [bug][bisected] git-svn with root branches","fromName":"Eric Wong","fromEmail":"normalperson@yhbt.net","sentAt":"2009-10-22T06:30:36Z","receivedAt":"2009-10-22T06:30:36Z","isPatch":false,"sender":{"key":"e@80x24.org","avatar":null},"body":"Daniel Cordero <theappleman@gmail.com> wrote:\n> Hello,\n> \n> when trying to clone a svn repo with the command-line:\n> \n> \t$ git svn clone -b / http://svn.collab.net/repos/svn/\n> \n> (that is, each folder in the root of the repo should be considered it's\n> own branch)\n> the clone sometimes[1] fails saying:\n> \n> \tref: 'refs/remotes/' ends with a trailing slash, this is not permitted by git nor Subversion\n> \n> The offending config is:\n> [svn-remote \"svn\"]\n>         url = http://svn.collab.net/repos/svn\n>         branches = /*:refs/remotes/*\n> \n> \n> This used to work in the past; I bisected the bad commit to\n> \n> commit 6f5748e14cc5bb0a836b649fb8e2d6a5eb166f1d\n> Author: Adam Brewster <adambrewster@gmail.com>\n> Date:   Tue Aug 11 23:14:03 2009 -0400\n> \n>     svn: allow branches outside of refs/remotes\n> \n> \n> Thanks in advance.\n\nThanks for bisecting it for us!\n\nReverting the left hand side of these two regexps from Adam's commit\nseems to fix the problem.\n\ndiff --git a/git-svn.perl b/git-svn.perl\nindex eb4b75a..56af221 100755\n--- a/git-svn.perl\n+++ b/git-svn.perl\n@@ -1765,7 +1765,7 @@ sub read_all_remotes {\n \tmy $use_svm_props = eval { command_oneline(qw/config --bool\n \t    svn.useSvmProps/) };\n \t$use_svm_props = $use_svm_props eq 'true' if $use_svm_props;\n-\tmy $svn_refspec = qr{\\s*/?(.*?)\\s*:\\s*(.+?)\\s*};\n+\tmy $svn_refspec = qr{\\s*(.*?)\\s*:\\s*(.+?)\\s*};\n \tforeach (grep { s/^svn-remote\\.// } command(qw/config -l/)) {\n \t\tif (m!^(.+)\\.fetch=$svn_refspec$!) {\n \t\t\tmy ($remote, $local_ref, $remote_ref) = ($1, $2, $3);\n@@ -1979,7 +1979,7 @@ sub find_ref {\n \tmy ($ref_id) = @_;\n \tforeach (command(qw/config -l/)) {\n \t\tnext unless m!^svn-remote\\.(.+)\\.fetch=\n-\t\t              \\s*/?(.*?)\\s*:\\s*(.+?)\\s*$!x;\n+\t\t              \\s*(.*?)\\s*:\\s*(.+?)\\s*$!x;\n \t\tmy ($repo_id, $path, $ref) = ($1, $2, $3);\n \t\tif ($ref eq $ref_id) {\n \t\t\t$path = '' if ($path =~ m#^\\./?#);\n---\n\nI'm not sure why Adam decided the leading slash needed to be removed for\nthe git refspec.  That said, the globbing/branching code still makes me\nwant to hide under a rock and I'm generally afraid to touch it.\nI'll wait for Adam to chime in since he's braver than I am :)\n\n-- \nEric Wong\n"},{"id":"125721","messageId":"20091022185533.GA11771@dcvr.yhbt.net","threadId":"21306","inReplyTo":"c376da900910220824g2948dc2sa1156bda59b49405@mail.gmail.com","subject":"Re: [bug][bisected] git-svn with root branches","fromName":"Eric Wong","fromEmail":"normalperson@yhbt.net","sentAt":"2009-10-22T18:55:33Z","receivedAt":"2009-10-22T18:55:33Z","isPatch":false,"sender":{"key":"e@80x24.org","avatar":null},"body":"Adam Brewster <adambrewster@gmail.com> wrote:\n> > > The offending config is:\n> > > [svn-remote \"svn\"]\n> > >         url = http://svn.collab.net/repos/svn\n> > >         branches = /*:refs/remotes/*\n> > >\n> >\n> > Reverting the left hand side of these two regexps from Adam's commit\n> > seems to fix the problem.\n> >\n> > diff --git a/git-svn.perl b/git-svn.perl\n> > index eb4b75a..56af221 100755\n> > --- a/git-svn.perl\n> > +++ b/git-svn.perl\n> > @@ -1765,7 +1765,7 @@ sub read_all_remotes {\n> >        my $use_svm_props = eval { command_oneline(qw/config --bool\n> >            svn.useSvmProps/) };\n> >        $use_svm_props = $use_svm_props eq 'true' if $use_svm_props;\n> > -       my $svn_refspec = qr{\\s*/?(.*?)\\s*:\\s*(.+?)\\s*};\n> > +       my $svn_refspec = qr{\\s*(.*?)\\s*:\\s*(.+?)\\s*};\n> >        foreach (grep { s/^svn-remote\\.// } command(qw/config -l/)) {\n> >                if (m!^(.+)\\.fetch=$svn_refspec$!) {\n> >                        my ($remote, $local_ref, $remote_ref) = ($1, $2,\n> > $3);\n> > @@ -1979,7 +1979,7 @@ sub find_ref {\n> >        my ($ref_id) = @_;\n> >        foreach (command(qw/config -l/)) {\n> >                next unless m!^svn-remote\\.(.+)\\.fetch=\n> > -                             \\s*/?(.*?)\\s*:\\s*(.+?)\\s*$!x;\n> > +                             \\s*(.*?)\\s*:\\s*(.+?)\\s*$!x;\n> >                my ($repo_id, $path, $ref) = ($1, $2, $3);\n> >                if ($ref eq $ref_id) {\n> >                        $path = '' if ($path =~ m#^\\./?#);\n> > ---\n> >\n> > I'm not sure why Adam decided the leading slash needed to be removed for\n> > the git refspec.  That said, the globbing/branching code still makes me\n> > want to hide under a rock and I'm generally afraid to touch it.\n> > I'll wait for Adam to chime in since he's braver than I am :)\n> >\n> >\n> How's this for brave:  I'm not sure why I did that either.\n> \n> Looking at it again it seems correct for the leading / to be ignored because\n> it has no meaning.  What's the difference between the above config and\n> \"branches = *:refs/remotes/*\" (besides the fact that one works and one\n> doesn't)?  In both cases I think I've asked for all of the top-level\n> directories to be branches.  But that has nothing to do with the rest of the\n> patch, so it shouldn't have been included.\n>\n> Given all of that I would be more inclined to fix this with something like\n> the following:\n> \n> diff --git a/git-svn.perl b/git-svn.perl\n> index eb4b75a..cd8a93b 100755\n> --- a/git-svn.perl\n> +++ b/git-svn.perl\n> @@ -1768,7 +1768,7 @@ sub read_all_remotes {\n>      my $svn_refspec = qr{\\s*/?(.*?)\\s*:\\s*(.+?)\\s*};\n>      foreach (grep { s/^svn-remote\\.// } command(qw/config -l/)) {\n>          if (m!^(.+)\\.fetch=$svn_refspec$!) {\n> -            my ($remote, $local_ref, $remote_ref) = ($1, $2, $3);\n> +            my ($remote, $local_ref, $remote_ref) = ($1, \"/$2\", $3);\n>              die(\"svn-remote.$remote: remote ref '$remote_ref' \"\n>                  . \"must start with 'refs/'\\n\")\n>                  unless $remote_ref =~ m{^refs/};\n> @@ -1780,7 +1780,7 @@ sub read_all_remotes {\n>              $r->{$1}->{url} = $2;\n>          } elsif (m!^(.+)\\.(branches|tags)=$svn_refspec$!) {\n>              my ($remote, $t, $local_ref, $remote_ref) =\n> -                                                 ($1, $2, $3, $4);\n> +                                                 ($1, $2, \"/$3\", $4);\n>              die(\"svn-remote.$remote: remote ref '$remote_ref' ($t) \"\n>                  . \"must start with 'refs/'\\n\")\n>                  unless $remote_ref =~ m{^refs/};\n> @@ -1980,7 +1980,7 @@ sub find_ref {\n>      foreach (command(qw/config -l/)) {\n>          next unless m!^svn-remote\\.(.+)\\.fetch=\n>                        \\s*/?(.*?)\\s*:\\s*(.+?)\\s*$!x;\n> -        my ($repo_id, $path, $ref) = ($1, $2, $3);\n> +        my ($repo_id, $path, $ref) = ($1, \"/$2\", $3);\n>          if ($ref eq $ref_id) {\n>              $path = '' if ($path =~ m#^\\./?#);\n>              return ($repo_id, $path);\n> -- \n> 1.6.5.1.63.ga9d7.dirty\n> \n> That is, continue disregard the / on the actual input because it means\n> nothing, and add a / in places where the code will crash if it's not there.\n> Even better would be to find out _why_ $path and $local_ref need a leading /\n> and fix it that way, but that's more work that I don't have time for right\n> now.\n\nThanks for the feedback Adam,\n\nYeah, I'm confused by that myself :x  /me kicks himself again\n\n> On the other hand it doesn't really matter because git svn init won't accept\n> -b '' (to create the configuration I proposed above), so I have no practical\n> objection to Eric's solution.\n\nMeanwhile, your patch looks good to me.  Let me know if you want write\na commit message for it or if you want me to do it.\n\nI actually tried editing my $GIT_CONFIG in $EDITOR to have a bare '*' as\nthe ref glob:\n\n\t[svn-remote \"svn\"]\n\t\turl = http://svn.collab.net/repos/svn\n\t\tbranches = *:refs/remotes/*\n\nSince I've tried it, I suspect others may try editing $GIT_CONFIG in the\nsame way as well.\n\n-- \nEric Wong\n"},{"id":"125766","messageId":"20091023044843.GA16169@dcvr.yhbt.net","threadId":"21306","inReplyTo":"20091021144113.GA7440@cumin","subject":"[PATCH] git svn: fix fetch where glob is on the top-level URL","fromName":"Eric Wong","fromEmail":"normalperson@yhbt.net","sentAt":"2009-10-23T04:48:43Z","receivedAt":"2009-10-23T04:48:43Z","isPatch":true,"sender":{"key":"e@80x24.org","avatar":null},"body":">From 3abaf9fdf216fd0307bb9e9f03772bd80a64177c Mon Sep 17 00:00:00 2001\nFrom: Adam Brewster <adambrewster@gmail.com>\nDate: Thu, 22 Oct 2009 21:26:32 -0700\nSubject: [PATCH] git svn: fix fetch where glob is on the top-level URL\n\nIn cases where the top-level URL we're tracking is the path we\nglob against, we can once again track odd repositories that keep\nbranches/tags at the top level.  This regression was introduced\nin commit 6f5748e14cc5bb0a836b649fb8e2d6a5eb166f1d.\n\nAdditionally, the leading slash is now optional when tracking\nthe top-level path to be consistent with non-top-level paths.\nWe now allow both of the following \"branches\" in [svn-remote\n\"foo\"] sections of $GIT_CONFIG:\n\n\t; with a leading slash (this worked before 6f5748e1)\n        branches = /*:refs/remotes/*\n\n\t; now it it also works without a leading slash\n        branches = *:refs/remotes/*\n\nThanks to Daniel Cordero for the original bug report and\nbisection.\n\n[ew: commit message]\n\nSigned-off-by: Eric Wong <normalperson@yhbt.net>\n---\n\n  Daniel Cordero <theappleman@gmail.com> wrote:\n  > Hello,\n  > \n  > when trying to clone a svn repo with the command-line:\n  > \n  > \t$ git svn clone -b / http://svn.collab.net/repos/svn/\n  > \n  > (that is, each folder in the root of the repo should be considered it's\n  > own branch)\n  > the clone sometimes[1] fails saying:\n  > \n  > \tref: 'refs/remotes/' ends with a trailing slash, this is not permitted by git nor Subversion\n  > \n  > The offending config is:\n  > [svn-remote \"svn\"]\n  >         url = http://svn.collab.net/repos/svn\n  >         branches = /*:refs/remotes/*\n  > \n  > \n  > This used to work in the past; I bisected the bad commit to\n  > \n  > commit 6f5748e14cc5bb0a836b649fb8e2d6a5eb166f1d\n  > Author: Adam Brewster <adambrewster@gmail.com>\n  > Date:   Tue Aug 11 23:14:03 2009 -0400\n  > \n  >     svn: allow branches outside of refs/remotes\n  > \n  > \n  > Thanks in advance.\n  > \n  > \n  > [1] It does work when the URL has at least 1 folder of depth\n  > (e.g. suffix \"trunk\" to the above URL).\n  > \n  > Its config section is:\n  > [svn-remote \"svn\"]\n  >         url = http://svn.collab.net/repos/svn\n  > \tbranches = trunk//*:refs/remotes/*\n  > \n\n git-svn.perl |    6 +++---\n 1 files changed, 3 insertions(+), 3 deletions(-)\n\ndiff --git a/git-svn.perl b/git-svn.perl\nindex eb4b75a..2e9a720 100755\n--- a/git-svn.perl\n+++ b/git-svn.perl\n@@ -1768,7 +1768,7 @@ sub read_all_remotes {\n \tmy $svn_refspec = qr{\\s*/?(.*?)\\s*:\\s*(.+?)\\s*};\n \tforeach (grep { s/^svn-remote\\.// } command(qw/config -l/)) {\n \t\tif (m!^(.+)\\.fetch=$svn_refspec$!) {\n-\t\t\tmy ($remote, $local_ref, $remote_ref) = ($1, $2, $3);\n+\t\t\tmy ($remote, $local_ref, $remote_ref) = ($1, \"/$2\", $3);\n \t\t\tdie(\"svn-remote.$remote: remote ref '$remote_ref' \"\n \t\t\t    . \"must start with 'refs/'\\n\")\n \t\t\t\tunless $remote_ref =~ m{^refs/};\n@@ -1780,7 +1780,7 @@ sub read_all_remotes {\n \t\t\t$r->{$1}->{url} = $2;\n \t\t} elsif (m!^(.+)\\.(branches|tags)=$svn_refspec$!) {\n \t\t\tmy ($remote, $t, $local_ref, $remote_ref) =\n-\t\t\t                                     ($1, $2, $3, $4);\n+\t\t\t                                   ($1, $2, \"/$3\", $4);\n \t\t\tdie(\"svn-remote.$remote: remote ref '$remote_ref' ($t) \"\n \t\t\t    . \"must start with 'refs/'\\n\")\n \t\t\t\tunless $remote_ref =~ m{^refs/};\n@@ -1980,7 +1980,7 @@ sub find_ref {\n \tforeach (command(qw/config -l/)) {\n \t\tnext unless m!^svn-remote\\.(.+)\\.fetch=\n \t\t              \\s*/?(.*?)\\s*:\\s*(.+?)\\s*$!x;\n-\t\tmy ($repo_id, $path, $ref) = ($1, $2, $3);\n+\t\tmy ($repo_id, $path, $ref) = ($1, \"/$2\", $3);\n \t\tif ($ref eq $ref_id) {\n \t\t\t$path = '' if ($path =~ m#^\\./?#);\n \t\t\treturn ($repo_id, $path);\n-- \nEric Wong\n"},{"id":"125771","messageId":"20091023060751.GA14477@dcvr.yhbt.net","threadId":"21306","inReplyTo":"20091023044843.GA16169@dcvr.yhbt.net","subject":"Re: [PATCH] git svn: fix fetch where glob is on the top-level URL","fromName":"Eric Wong","fromEmail":"normalperson@yhbt.net","sentAt":"2009-10-23T06:07:51Z","receivedAt":"2009-10-23T06:07:51Z","isPatch":true,"sender":{"key":"e@80x24.org","avatar":null},"body":"Eric Wong <normalperson@yhbt.net> wrote:\n> From 3abaf9fdf216fd0307bb9e9f03772bd80a64177c Mon Sep 17 00:00:00 2001\n> From: Adam Brewster <adambrewster@gmail.com>\n> Date: Thu, 22 Oct 2009 21:26:32 -0700\n> Subject: [PATCH] git svn: fix fetch where glob is on the top-level URL\n\nActually, no, something is broken here it seems...  Ugh, falling asleep :x\n\n-- \nEric Wong\n"},{"id":"125773","messageId":"20091023063815.GA15445@dcvr.yhbt.net","threadId":"21306","inReplyTo":"c376da900910220824g2948dc2sa1156bda59b49405@mail.gmail.com","subject":"Re: [bug][bisected] git-svn with root branches","fromName":"Eric Wong","fromEmail":"normalperson@yhbt.net","sentAt":"2009-10-23T06:38:15Z","receivedAt":"2009-10-23T06:38:15Z","isPatch":false,"sender":{"key":"e@80x24.org","avatar":null},"body":"Adam Brewster <adambrewster@gmail.com> wrote:\n> > I'm not sure why Adam decided the leading slash needed to be removed for\n> > the git refspec.  That said, the globbing/branching code still makes me\n> > want to hide under a rock and I'm generally afraid to touch it.\n> > I'll wait for Adam to chime in since he's braver than I am :)\n> >\n> How's this for brave:  I'm not sure why I did that either.\n> \n> Looking at it again it seems correct for the leading / to be ignored because\n> it has no meaning.  What's the difference between the above config and\n> \"branches = *:refs/remotes/*\" (besides the fact that one works and one\n> doesn't)?  In both cases I think I've asked for all of the top-level\n> directories to be branches.  But that has nothing to do with the rest of the\n> patch, so it shouldn't have been included.\n\n<snip>\n\n> That is, continue disregard the / on the actual input because it means\n> nothing, and add a / in places where the code will crash if it's not there.\n> Even better would be to find out _why_ $path and $local_ref need a leading /\n> and fix it that way, but that's more work that I don't have time for right\n> now.\n\nActually, SVN 1.5+ does not like the leading \"/\" and trips on an\nassertion failure on all cases except a standalone \"/\".  That is, \"/*\"\ncontinues to work since we send \"/\" to SVN::Ra::get_log().\n\n-- \nEric Wong\n"},{"id":"125774","messageId":"20091023065056.GA25187@dcvr.yhbt.net","threadId":"21306","inReplyTo":"20091023060751.GA14477@dcvr.yhbt.net","subject":"Re: [PATCH] git svn: fix fetch where glob is on the top-level URL","fromName":"Eric Wong","fromEmail":"normalperson@yhbt.net","sentAt":"2009-10-23T06:50:56Z","receivedAt":"2009-10-23T06:50:56Z","isPatch":true,"sender":{"key":"e@80x24.org","avatar":null},"body":"Eric Wong <normalperson@yhbt.net> wrote:\n> Eric Wong <normalperson@yhbt.net> wrote:\n> > From 3abaf9fdf216fd0307bb9e9f03772bd80a64177c Mon Sep 17 00:00:00 2001\n> > From: Adam Brewster <adambrewster@gmail.com>\n> > Date: Thu, 22 Oct 2009 21:26:32 -0700\n> > Subject: [PATCH] git svn: fix fetch where glob is on the top-level URL\n> \n> Actually, no, something is broken here it seems...  Ugh, falling asleep :x\n\nOops, I was running the tests from the wrong machine that didn't have\nthe patch on that one.\n\nAs noted in my previous email, the leading slashes cause\nSVN::Ra::get_log to fail with an assertion if the path passed to it\nhas a leading slash but is not a standalone slash.\n\nHere's my original patch which seems to work fine (but doesn't allow the\nmore flexible, bare \"*\" in \"branches = *:refs/remotes/*\" Adam's one did.\n\n>From 42079a567bef745996b6272ad546d682dfcf57d6 Mon Sep 17 00:00:00 2001\nFrom: Eric Wong <normalperson@yhbt.net>\nDate: Thu, 22 Oct 2009 23:39:04 -0700\nSubject: [PATCH] git svn: fix fetch where glob is on the top-level URL\n\nIn cases where the top-level URL we're tracking is the path we\nglob against, we can once again track odd repositories that keep\nbranches/tags at the top level.  This regression was introduced\nin commit 6f5748e14cc5bb0a836b649fb8e2d6a5eb166f1d.\n\nThanks to Daniel Cordero for the original bug report and\nbisection.\n\nSigned-off-by: Eric Wong <normalperson@yhbt.net>\n---\n git-svn.perl |    4 ++--\n 1 files changed, 2 insertions(+), 2 deletions(-)\n\ndiff --git a/git-svn.perl b/git-svn.perl\nindex eb4b75a..56af221 100755\n--- a/git-svn.perl\n+++ b/git-svn.perl\n@@ -1765,7 +1765,7 @@ sub read_all_remotes {\n \tmy $use_svm_props = eval { command_oneline(qw/config --bool\n \t    svn.useSvmProps/) };\n \t$use_svm_props = $use_svm_props eq 'true' if $use_svm_props;\n-\tmy $svn_refspec = qr{\\s*/?(.*?)\\s*:\\s*(.+?)\\s*};\n+\tmy $svn_refspec = qr{\\s*(.*?)\\s*:\\s*(.+?)\\s*};\n \tforeach (grep { s/^svn-remote\\.// } command(qw/config -l/)) {\n \t\tif (m!^(.+)\\.fetch=$svn_refspec$!) {\n \t\t\tmy ($remote, $local_ref, $remote_ref) = ($1, $2, $3);\n@@ -1979,7 +1979,7 @@ sub find_ref {\n \tmy ($ref_id) = @_;\n \tforeach (command(qw/config -l/)) {\n \t\tnext unless m!^svn-remote\\.(.+)\\.fetch=\n-\t\t              \\s*/?(.*?)\\s*:\\s*(.+?)\\s*$!x;\n+\t\t              \\s*(.*?)\\s*:\\s*(.+?)\\s*$!x;\n \t\tmy ($repo_id, $path, $ref) = ($1, $2, $3);\n \t\tif ($ref eq $ref_id) {\n \t\t\t$path = '' if ($path =~ m#^\\./?#);\n-- \nEric Wong\n"}]}