{"thread":{"id":"18124","subject":"git-svn does not support intermediate directories?","startedAt":"2009-03-04T01:43:47Z","lastAt":"2009-03-09T21:54:48Z","messageCount":6,"participants":["Michael Lai","Tim Stoakes","Eric Wong"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"106940","messageId":"21fc26450903031743x4beda8a3i835ecbd428817070@mail.gmail.com","threadId":"18124","inReplyTo":null,"subject":"git-svn does not support intermediate directories?","fromName":"Michael Lai","fromEmail":"myllai@gmail.com","sentAt":"2009-03-04T01:43:47Z","receivedAt":"2009-03-04T01:43:47Z","isPatch":false,"sender":{"key":"myllai@gmail.com","avatar":null},"body":"Hey all,\n\n  After spending some hours struggling with git svn, it would appear\nthat it does not support svn projects stored in paths similar to\n\"http://foo.com/svn/repos/bar/myproject\", where \"myproject\" uses the\nstandard SVN tags/trunk/branches layout.  I'm currently using git\n1.6.1, though I tried this with 1.6.2-rc2 as well.  The resulting\n.git/config looks something like this:\n\n[svn-remote \"svn\"]\n\turl = http://foo.com/svn/repos/bar\n\tfetch = myproject/trunk:refs/remotes/trunk\n\tbranches = bar/myproject/branches/*:refs/remotes/*\n\ttags = bar/myproject/tags/*:refs/remotes/tags/*\n\nYes, that's a redundant \"bar\" directory under \"branches =\" and \"tags\n=\".  The issue seems to lie in git-svn doing something intelligent to\nextract the appropriate trunk directory.  For the branches and tags,\nhowever, it just takes the full URL and removes the repository root\n(http://foo.com/svn/repos/bar) to produce \"bar/myproject/{branches,\ntags}/*\".  The second effect is that \"git svn fetch\" will run but exit\nquietly without actually pulling anything from the repository.  I\ntracked down an existing thread on the mailing list from a while ago\n(Feb 4th, title of \"git-svn doesn't fetch anything\"), but there was no\nresolution.\n\nThere is a quick workaround, which was to make this change to match_paths:\n< \t$self->{path_regex} ||= qr/^\\/\\Q$self->{path}\\E\\//;\n---\n> \t$self->{path_regex} ||= qr/\\/\\Q$self->{path}\\E\\//;\n\nThe additional \"bar\" directory gets pulled in when git-svn tries to\ndetermine what paths to pull down, and tries to match\n\"/myproject/trunk\" to \"/bar/myproject/trunk\".  I've merely put a\nband-aid on the situation.  My perl is rudimentary at best, or I'd\nhave spent additional time to try to put in a \"proper\" patch, but was\nwondering if anyone else had run into this problem and would be\nwilling to put in a fix (or point me in the right direction, that\nworks too).\n\nThanks,\nMike\n"},{"id":"106941","messageId":"20090304043019.GC20790@mail.rocksoft.com","threadId":"18124","inReplyTo":"21fc26450903031743x4beda8a3i835ecbd428817070@mail.gmail.com","subject":"Re: git-svn does not support intermediate directories?","fromName":"Tim Stoakes","fromEmail":"tim@stoakes.net","sentAt":"2009-03-04T04:30:20Z","receivedAt":"2009-03-04T04:30:20Z","isPatch":false,"sender":{"key":"tim@stoakes.net","avatar":null},"body":"Michael Lai(myllai@gmail.com)@030309-17:43:\n>   After spending some hours struggling with git svn, it would appear\n> that it does not support svn projects stored in paths similar to\n> \"http://foo.com/svn/repos/bar/myproject\", where \"myproject\" uses the\n> standard SVN tags/trunk/branches layout.  I'm currently using git\n> 1.6.1, though I tried this with 1.6.2-rc2 as well.  The resulting\n> .git/config looks something like this:\n> \n> [svn-remote \"svn\"]\n> \turl = http://foo.com/svn/repos/bar\n> \tfetch = myproject/trunk:refs/remotes/trunk\n> \tbranches = bar/myproject/branches/*:refs/remotes/*\n> \ttags = bar/myproject/tags/*:refs/remotes/tags/*\n> \n> Yes, that's a redundant \"bar\" directory under \"branches =\" and \"tags\n> =\".  The issue seems to lie in git-svn doing something intelligent to\n> extract the appropriate trunk directory.  For the branches and tags,\n> however, it just takes the full URL and removes the repository root\n> (http://foo.com/svn/repos/bar) to produce \"bar/myproject/{branches,\n> tags}/*\".  The second effect is that \"git svn fetch\" will run but exit\n> quietly without actually pulling anything from the repository.  I\n> tracked down an existing thread on the mailing list from a while ago\n> (Feb 4th, title of \"git-svn doesn't fetch anything\"), but there was no\n> resolution.\n\nI've just run into this exact same issue.\n\n> There is a quick workaround, which was to make this change to match_paths:\n> < \t$self->{path_regex} ||= qr/^\\/\\Q$self->{path}\\E\\//;\n> ---\n> > \t$self->{path_regex} ||= qr/\\/\\Q$self->{path}\\E\\//;\n> \n> The additional \"bar\" directory gets pulled in when git-svn tries to\n> determine what paths to pull down, and tries to match\n> \"/myproject/trunk\" to \"/bar/myproject/trunk\".  I've merely put a\n> band-aid on the situation.  My perl is rudimentary at best, or I'd\n> have spent additional time to try to put in a \"proper\" patch, but was\n> wondering if anyone else had run into this problem and would be\n> willing to put in a fix (or point me in the right direction, that\n> works too).\n\nI messed about with disabling $Git::SVN::_minimize_url, but that seemed\nto break other things.\n\nMade worse for me was the fact that my 'bar' in the present was renamed\nfrom 'baz' in the past, so git-svn couldn't find it at r1. Very\nconfusing!\n\nI'd like a nicer solution too.\n\nTim\n\n-- \nTim Stoakes\n"},{"id":"107122","messageId":"21fc26450903051612u1400b2b4gd71c3eafa4418e37@mail.gmail.com","threadId":"18124","inReplyTo":"20090304043019.GC20790@mail.rocksoft.com","subject":"Re: [RFC PATCH] git-svn does not support intermediate directories?","fromName":"Michael Lai","fromEmail":"myllai@gmail.com","sentAt":"2009-03-06T00:12:27Z","receivedAt":"2009-03-06T00:12:27Z","isPatch":true,"sender":{"key":"myllai@gmail.com","avatar":null},"body":"I did some additional hacking and may have found a slightly cleaner\nway of at least fixing the problems with \"git svn fetch\".  The problem\nwith the wrong paths being initialized for branches and tags is fairly\nminor (since you can just edit the config by hand), so I'll probably\naddress that later, if I have time.  Here's the patch (I hope I'm\ndoing this right):\n\ndiff --git a/git-svn.perl b/git-svn.perl\nindex 959eb52..174f266 100755\n--- a/git-svn.perl\n+++ b/git-svn.perl\n@@ -2351,7 +2351,11 @@ sub match_paths {\n        if (my $path = $paths->{\"/$self->{path}\"}) {\n                return ($path->{action} eq 'D') ? 0 : 1;\n        }\n-       $self->{path_regex} ||= qr/^\\/\\Q$self->{path}\\E\\//;\n+       my $repos_root = $self->ra->{repos_root};\n+       my $intermediate_path = $self->{url};\n+       $intermediate_path =~ s#^\\Q$repos_root\\E(/|$)#\\/#;\n+       $intermediate_path .= '/' if $intermediate_path;\n+       $self->{path_regex} ||= qr/^\\/\\Q$intermediate_path$self->{path}\\E\\//;\n        if (grep /$self->{path_regex}/, keys %$paths) {\n                return 1;\n        }\n\n--\n\nOn Tue, Mar 3, 2009 at 8:30 PM, Tim Stoakes <tim@stoakes.net> wrote:\n> Michael Lai(myllai@gmail.com)@030309-17:43:\n>>   After spending some hours struggling with git svn, it would appear\n>> that it does not support svn projects stored in paths similar to\n>> \"http://foo.com/svn/repos/bar/myproject\", where \"myproject\" uses the\n>> standard SVN tags/trunk/branches layout.  I'm currently using git\n>> 1.6.1, though I tried this with 1.6.2-rc2 as well.  The resulting\n>> .git/config looks something like this:\n>>\n>> [svn-remote \"svn\"]\n>>       url = http://foo.com/svn/repos/bar\n>>       fetch = myproject/trunk:refs/remotes/trunk\n>>       branches = bar/myproject/branches/*:refs/remotes/*\n>>       tags = bar/myproject/tags/*:refs/remotes/tags/*\n>>\n>> Yes, that's a redundant \"bar\" directory under \"branches =\" and \"tags\n>> =\".  The issue seems to lie in git-svn doing something intelligent to\n>> extract the appropriate trunk directory.  For the branches and tags,\n>> however, it just takes the full URL and removes the repository root\n>> (http://foo.com/svn/repos/bar) to produce \"bar/myproject/{branches,\n>> tags}/*\".  The second effect is that \"git svn fetch\" will run but exit\n>> quietly without actually pulling anything from the repository.  I\n>> tracked down an existing thread on the mailing list from a while ago\n>> (Feb 4th, title of \"git-svn doesn't fetch anything\"), but there was no\n>> resolution.\n>\n> I've just run into this exact same issue.\n>\n>> There is a quick workaround, which was to make this change to match_paths:\n>> <     $self->{path_regex} ||= qr/^\\/\\Q$self->{path}\\E\\//;\n>> ---\n>> >     $self->{path_regex} ||= qr/\\/\\Q$self->{path}\\E\\//;\n>>\n>> The additional \"bar\" directory gets pulled in when git-svn tries to\n>> determine what paths to pull down, and tries to match\n>> \"/myproject/trunk\" to \"/bar/myproject/trunk\".  I've merely put a\n>> band-aid on the situation.  My perl is rudimentary at best, or I'd\n>> have spent additional time to try to put in a \"proper\" patch, but was\n>> wondering if anyone else had run into this problem and would be\n>> willing to put in a fix (or point me in the right direction, that\n>> works too).\n>\n> I messed about with disabling $Git::SVN::_minimize_url, but that seemed\n> to break other things.\n>\n> Made worse for me was the fact that my 'bar' in the present was renamed\n> from 'baz' in the past, so git-svn couldn't find it at r1. Very\n> confusing!\n>\n> I'd like a nicer solution too.\n>\n> Tim\n>\n> --\n> Tim Stoakes\n>\n"},{"id":"107373","messageId":"20090308044318.GA31205@untitled","threadId":"18124","inReplyTo":"21fc26450903051612u1400b2b4gd71c3eafa4418e37@mail.gmail.com","subject":"Re: [RFC PATCH] git-svn does not support intermediate directories?","fromName":"Eric Wong","fromEmail":"normalperson@yhbt.net","sentAt":"2009-03-08T04:43:18Z","receivedAt":"2009-03-08T04:43:18Z","isPatch":true,"sender":{"key":"e@80x24.org","avatar":null},"body":"Michael Lai <myllai@gmail.com> wrote:\n> I did some additional hacking and may have found a slightly cleaner\n> way of at least fixing the problems with \"git svn fetch\".  The problem\n> with the wrong paths being initialized for branches and tags is fairly\n> minor (since you can just edit the config by hand), so I'll probably\n> address that later, if I have time.  Here's the patch (I hope I'm\n> doing this right):\n\nHi Michael,\n\nYour patch was whitespace damaged and lacked a proposed commit message.\nPlease read Documentation/SubmittingPatches next time.\n\nAnyhow, I fixed your patch up a bit.  Can you sign-off on it\nif its right to you or let me know if it's broken?  Thanks.\n\nFrom cddc7e5bde060eb963534156ae0daaf41c87c21a Mon Sep 17 00:00:00 2001\nFrom: Eric Wong <normalperson@yhbt.net>\nDate: Sat, 7 Mar 2009 20:22:29 -0800\nSubject: [PATCH] git-svn: support intermediate paths when matching tags/branches\nMIME-Version: 1.0\nContent-Type: text/plain; charset=utf-8\nContent-Transfer-Encoding: 8bit\n\nFor repositories laid out like the following:\n\n> [svn-remote \"svn\"]\n>       url = http://foo.com/svn/repos/bar\n>       fetch = myproject/trunk:refs/remotes/trunk\n>       branches = bar/myproject/branches/*:refs/remotes/*\n>       tags = bar/myproject/tags/*:refs/remotes/tags/*\n\nThe \"bar\" component above is considered the intermediate path\nand was not handled correctly.\n\nThis patch was originally by Michael Lai (without a commit\nmessage) with some minor fixes:\n\n  * extraneous slash removed from $intermediate_path,\n    this was causing tests to fail.\n\n  * fixed a case where $intermediate_path could be \"0\" and\n    considered false by Perl, preventing the necessary\n    slash from being appended.\n\nSigned-off-by: Eric Wong <normalperson@yhbt.net>\n---\n git-svn.perl |    6 +++++-\n 1 files changed, 5 insertions(+), 1 deletions(-)\n\ndiff --git a/git-svn.perl b/git-svn.perl\nindex 959eb52..745dd03 100755\n--- a/git-svn.perl\n+++ b/git-svn.perl\n@@ -2351,7 +2351,11 @@ sub match_paths {\n \tif (my $path = $paths->{\"/$self->{path}\"}) {\n \t\treturn ($path->{action} eq 'D') ? 0 : 1;\n \t}\n-\t$self->{path_regex} ||= qr/^\\/\\Q$self->{path}\\E\\//;\n+\tmy $repos_root = $self->ra->{repos_root};\n+\tmy $intermediate_path = $self->{url};\n+\t$intermediate_path =~ s#^\\Q$repos_root\\E(/|$)##;\n+\t$intermediate_path .= '/' if length($intermediate_path) > 0;\n+\t$self->{path_regex} ||= qr/^\\/\\Q$intermediate_path$self->{path}\\E\\//;\n \tif (grep /$self->{path_regex}/, keys %$paths) {\n \t\treturn 1;\n \t}\n-- \nEric Wong\n"},{"id":"107502","messageId":"21fc26450903091402u60d6cfcepd67ba7510af8f4a3@mail.gmail.com","threadId":"18124","inReplyTo":"20090308044318.GA31205@untitled","subject":"Re: [RFC PATCH] git-svn does not support intermediate directories?","fromName":"Michael Lai","fromEmail":"myllai@gmail.com","sentAt":"2009-03-09T21:02:15Z","receivedAt":"2009-03-09T21:02:15Z","isPatch":true,"sender":{"key":"myllai@gmail.com","avatar":null},"body":"> Your patch was whitespace damaged and lacked a proposed commit message.\n> Please read Documentation/SubmittingPatches next time.\nHey Eric,\n\nSorry, I didn't notice that; I've read through it and hopefully my\npatches should conform from now on.\n\n>\n> Anyhow, I fixed your patch up a bit.  Can you sign-off on it\n> if its right to you or let me know if it's broken?  Thanks.\n\nI looked through the patch and that would work, but at the same time I\nhad another idea which may be a little cleaner.  Let me know what you\nthink.\n\nFrom ae38acf85cfc86c075578c1c3f3c204d91d1d1f4 Mon Sep 17 00:00:00 2001\nFrom: Michael Lai <myllai@gmail.com>\nDate: Mon, 9 Mar 2009 11:45:47 -0700\nSubject: [PATCH] git-svn: support intermediate paths when matching tags/branches\n\nFor repositories laid out like the following:\n\n[svn-remote \"svn\"]\n      url = http://foo.com/svn/repos/bar\n      fetch = myproject/trunk:refs/remotes/trunk\n      branches = bar/myproject/branches/*:refs/remotes/*\n      tags = bar/myproject/tags/*:refs/remotes/tags/*\n\nThe \"bar\" component above is considered the intermediate path\nand was not handled correctly.\n\nSigned-off-by: Michael Lai <myllai@gmail.com>\n---\n git-svn.perl |    5 ++++-\n 1 files changed, 4 insertions(+), 1 deletions(-)\n\ndiff --git a/git-svn.perl b/git-svn.perl\nindex 959eb52..8be6be0 100755\n--- a/git-svn.perl\n+++ b/git-svn.perl\n@@ -2351,7 +2351,10 @@ sub match_paths {\n \tif (my $path = $paths->{\"/$self->{path}\"}) {\n \t\treturn ($path->{action} eq 'D') ? 0 : 1;\n \t}\n-\t$self->{path_regex} ||= qr/^\\/\\Q$self->{path}\\E\\//;\n+\tmy $repos_root = $self->ra->{repos_root};\n+\tmy $extended_path = $self->{url} . '/' . $self->{path};\n+\t$extended_path =~ s#^\\Q$repos_root\\E(/|$)##;\n+\t$self->{path_regex} ||= qr/^\\/\\Q$extended_path\\E\\//;\n \tif (grep /$self->{path_regex}/, keys %$paths) {\n \t\treturn 1;\n \t}\n-- \n1.6.2\n\n>\n> From cddc7e5bde060eb963534156ae0daaf41c87c21a Mon Sep 17 00:00:00 2001\n> From: Eric Wong <normalperson@yhbt.net>\n> Date: Sat, 7 Mar 2009 20:22:29 -0800\n> Subject: [PATCH] git-svn: support intermediate paths when matching tags/branches\n> MIME-Version: 1.0\n> Content-Type: text/plain; charset=utf-8\n> Content-Transfer-Encoding: 8bit\n>\n> For repositories laid out like the following:\n>\n>> [svn-remote \"svn\"]\n>>       url = http://foo.com/svn/repos/bar\n>>       fetch = myproject/trunk:refs/remotes/trunk\n>>       branches = bar/myproject/branches/*:refs/remotes/*\n>>       tags = bar/myproject/tags/*:refs/remotes/tags/*\n>\n> The \"bar\" component above is considered the intermediate path\n> and was not handled correctly.\n>\n> This patch was originally by Michael Lai (without a commit\n> message) with some minor fixes:\n>\n>  * extraneous slash removed from $intermediate_path,\n>    this was causing tests to fail.\n>\n>  * fixed a case where $intermediate_path could be \"0\" and\n>    considered false by Perl, preventing the necessary\n>    slash from being appended.\n>\n> Signed-off-by: Eric Wong <normalperson@yhbt.net>\n> ---\n>  git-svn.perl |    6 +++++-\n>  1 files changed, 5 insertions(+), 1 deletions(-)\n>\n> diff --git a/git-svn.perl b/git-svn.perl\n> index 959eb52..745dd03 100755\n> --- a/git-svn.perl\n> +++ b/git-svn.perl\n> @@ -2351,7 +2351,11 @@ sub match_paths {\n>        if (my $path = $paths->{\"/$self->{path}\"}) {\n>                return ($path->{action} eq 'D') ? 0 : 1;\n>        }\n> -       $self->{path_regex} ||= qr/^\\/\\Q$self->{path}\\E\\//;\n> +       my $repos_root = $self->ra->{repos_root};\n> +       my $intermediate_path = $self->{url};\n> +       $intermediate_path =~ s#^\\Q$repos_root\\E(/|$)##;\n> +       $intermediate_path .= '/' if length($intermediate_path) > 0;\n> +       $self->{path_regex} ||= qr/^\\/\\Q$intermediate_path$self->{path}\\E\\//;\n>        if (grep /$self->{path_regex}/, keys %$paths) {\n>                return 1;\n>        }\n> --\n> Eric Wong\n>\n"},{"id":"107510","messageId":"20090309215447.GA25947@dcvr.yhbt.net","threadId":"18124","inReplyTo":"21fc26450903091402u60d6cfcepd67ba7510af8f4a3@mail.gmail.com","subject":"Re: [RFC PATCH] git-svn does not support intermediate directories?","fromName":"Eric Wong","fromEmail":"normalperson@yhbt.net","sentAt":"2009-03-09T21:54:48Z","receivedAt":"2009-03-09T21:54:48Z","isPatch":true,"sender":{"key":"e@80x24.org","avatar":null},"body":"Michael Lai <myllai@gmail.com> wrote:\n> > Your patch was whitespace damaged and lacked a proposed commit message.\n> > Please read Documentation/SubmittingPatches next time.\n> Hey Eric,\n> \n> Sorry, I didn't notice that; I've read through it and hopefully my\n> patches should conform from now on.\n> \n> >\n> > Anyhow, I fixed your patch up a bit.  Can you sign-off on it\n> > if its right to you or let me know if it's broken?  Thanks.\n> \n> I looked through the patch and that would work, but at the same time I\n> had another idea which may be a little cleaner.  Let me know what you\n> think.\n\nThanks Michael, looks good to me,\n\nAcked and pushed out to git://git.bogomips.org/git-svn\n\n> From ae38acf85cfc86c075578c1c3f3c204d91d1d1f4 Mon Sep 17 00:00:00 2001\n> From: Michael Lai <myllai@gmail.com>\n> Date: Mon, 9 Mar 2009 11:45:47 -0700\n> Subject: [PATCH] git-svn: support intermediate paths when matching tags/branches\n> \n> For repositories laid out like the following:\n> \n> [svn-remote \"svn\"]\n>       url = http://foo.com/svn/repos/bar\n>       fetch = myproject/trunk:refs/remotes/trunk\n>       branches = bar/myproject/branches/*:refs/remotes/*\n>       tags = bar/myproject/tags/*:refs/remotes/tags/*\n> \n> The \"bar\" component above is considered the intermediate path\n> and was not handled correctly.\n> \n> Signed-off-by: Michael Lai <myllai@gmail.com>\n> ---\n>  git-svn.perl |    5 ++++-\n>  1 files changed, 4 insertions(+), 1 deletions(-)\n> \n> diff --git a/git-svn.perl b/git-svn.perl\n> index 959eb52..8be6be0 100755\n> --- a/git-svn.perl\n> +++ b/git-svn.perl\n> @@ -2351,7 +2351,10 @@ sub match_paths {\n>  \tif (my $path = $paths->{\"/$self->{path}\"}) {\n>  \t\treturn ($path->{action} eq 'D') ? 0 : 1;\n>  \t}\n> -\t$self->{path_regex} ||= qr/^\\/\\Q$self->{path}\\E\\//;\n> +\tmy $repos_root = $self->ra->{repos_root};\n> +\tmy $extended_path = $self->{url} . '/' . $self->{path};\n> +\t$extended_path =~ s#^\\Q$repos_root\\E(/|$)##;\n> +\t$self->{path_regex} ||= qr/^\\/\\Q$extended_path\\E\\//;\n>  \tif (grep /$self->{path_regex}/, keys %$paths) {\n>  \t\treturn 1;\n>  \t}\n> -- \n> 1.6.2\n"}]}