{"thread":{"id":"22761","subject":"[PATCH/RFC] git-svn: Allow multiple branch and tag patterns","startedAt":"2010-02-22T22:29:34Z","lastAt":"2010-02-23T14:41:23Z","messageCount":4,"participants":["Michael Olson","Tim Stoakes","Michael J Gruber"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"135355","messageId":"c8b3bef91002221429l3b277429l56f4e4cac4fdeb43@mail.gmail.com","threadId":"22761","inReplyTo":null,"subject":"[PATCH/RFC] git-svn: Allow multiple branch and tag patterns","fromName":"Michael Olson","fromEmail":"mwolson@gnu.org","sentAt":"2010-02-22T22:29:34Z","receivedAt":"2010-02-22T22:29:34Z","isPatch":true,"sender":{"key":"mwolson@gnu.org","avatar":"https://avatars.githubusercontent.com/u/1510193?v=4"},"body":"This change allows multiple branch and tag patterns to be specified in\n.git/config for git-svn projects.  This is useful for fetching several\ndifferent parts out of the namespace of an svn repository.\nAdditionally, a new repeatable directive called \"skip\" has been added\nto specify a specific tag or branch to ignore.\n\nSigned-off-by: Michael W. Olson <mwolson@gnu.org>\n---\nI've been using this patch regularly for over a year on a very large\nsvn repository.\n\nThis patch is known to work on git 1.6.3.3 specifically.  Once I get a\nfew responses about whether or not it is useful, I'll rebase it\nagainst the git.git master branch.  Some further documentation\n(perhaps just a relevant example or two) would also need to be added\nto the git-svn manpage.\n\nHere is an example ~/.git/config file which works with these changes.\nThe example upstream svn repository has branches in tags in 2\ndifferent namespaces.  Originally all tags/branches were directly\nunder /root/mod/branches and /root/mod/tags.  Later on, they created\nnew branches and tags in subdirectories such as\n/root/mod/branches/myorg/bugs/BUGID.  This config file forces\nold-style branches and tags into the \"old/\" namespace in git, and puts\nnew-style branches and tags into (for example) \"myorg/bugs/BUGID\".\nThe \"skip\" directives prevent the first level of the new namespace\n(\"myorg\", in particular) from being replicated underneath \"old/\" in\ngit, which is for cosmetic purposes.\n\n[core]\n\trepositoryformatversion = 0\n\tfilemode = true\n\tbare = false\n\tlogallrefupdates = true\n[svn-remote \"svn\"]\n\turl = https://svn.my.org/svn/root\n\tfetch = mod/trunk:refs/remotes/trunk\n\tbranches = mod/branches/*:refs/remotes/old/*\n        skip = branches:old/myorg\n\ttags = mod/tags/*:refs/remotes/tags/old/*\n        skip = tags:old/myorg\n\tbranches = mod/branches/myorg/bugs/*:refs/remotes/myorg/bugs/*\n\ttags = mod/tags/myorg/bugs/*:refs/remotes/tags/myorg/bugs/*\n\tbranches = mod/branches/myorg/projects/*:refs/remotes/myorg/projects/*\n\ttags = mod/tags/myorg/projects/*:refs/remotes/tags/myorg/projects/*\n\tbranches = mod/branches/myorg/releases/*:refs/remotes/myorg/releases/*\n\ttags = mod/tags/myorg/releases/*:refs/remotes/tags/myorg/releases/*\n\n git-svn.perl |   25 ++++++++++++++++++++-----\n 1 files changed, 20 insertions(+), 5 deletions(-)\n\ndiff --git a/git-svn.perl b/git-svn.perl\nindex ef1d30d..f7ec70c 100755\n--- a/git-svn.perl\n+++ b/git-svn.perl\n@@ -1548,7 +1548,7 @@ sub fetch_all {\n \t# read the max revs for wildcard expansion (branches/*, tags/*)\n \tforeach my $t (qw/branches tags/) {\n \t\tdefined $remote->{$t} or next;\n-\t\tpush @globs, $remote->{$t};\n+\t\tpush @globs, @{$remote->{$t}};\n \t\tmy $max_rev = eval { tmp_config(qw/--int --get/,\n \t\t                         \"svn-remote.$repo_id.${t}-maxRev\") };\n \t\tif (defined $max_rev && ($max_rev < $base)) {\n@@ -1592,14 +1592,17 @@ sub read_all_remotes {\n \t\t\t$r->{$1}->{svm} = {};\n \t\t} elsif (m!^(.+)\\.url=\\s*(.*)\\s*$!) {\n \t\t\t$r->{$1}->{url} = $2;\n+\t\t} elsif (m!^(.+)\\.skip=(branches|tags):\\s*(.*)\\s*$!) {\n+\t\t\tpush @{$r->{$1}->{skip}->{$2}}, $3;\n \t\t} elsif (m!^(.+)\\.(branches|tags)=\n \t\t           (.*):refs/remotes/(.+)\\s*$/!x) {\n \t\t\tmy ($p, $g) = ($3, $4);\n-\t\t\tmy $rs = $r->{$1}->{$2} = {\n+\t\t\tmy $rs = {\n \t\t\t                  t => $2,\n \t\t\t\t\t  remote => $1,\n \t\t\t                  path => Git::SVN::GlobSpec->new($p),\n \t\t\t                  ref => Git::SVN::GlobSpec->new($g) };\n+\t\t\tpush @{$r->{$1}->{$2}}, $rs;\n \t\t\tif (length($rs->{ref}->{right}) != 0) {\n \t\t\t\tdie \"The '*' glob character must be the last \",\n \t\t\t\t    \"character of '$g'\\n\";\n@@ -1623,6 +1626,14 @@ sub read_all_remotes {\n \t\t}\n \t} keys %$r;\n\n+\tfor my $rname (keys %$r) {\n+\t\tmap { $_->{skip} = $r->{$rname}->{skip}->{branches} }\n+\t\t    @{$r->{$rname}->{branches}};\n+\t\tmap { $_->{skip} =\n+\t\t\t[ map { \"tags/$_\" } @{$r->{$rname}->{skip}->{tags}} ] }\n+\t\t    @{$r->{$rname}->{tags}};\n+\t}\n+\n \t$r;\n }\n\n@@ -1744,8 +1755,9 @@ sub find_by_url { # repos_root and, path are optional\n\n \t\tmy $fetch = $remotes->{$repo_id}->{fetch} || {};\n \t\tforeach (qw/branches tags/) {\n-\t\t\tresolve_local_globs($u, $fetch,\n-\t\t\t                    $remotes->{$repo_id}->{$_});\n+\t\t\tfor my $p (@{$remotes->{$repo_id}->{$_}}) {\n+\t\t\t\tresolve_local_globs($u, $fetch, $p);\n+\t\t\t}\n \t\t}\n \t\tmy $p = $path;\n \t\tmy $rwr = rewrite_root({repo_id => $repo_id});\n@@ -4586,12 +4598,15 @@ sub match_globs {\n \t\t\tnext unless /$g->{path}->{regex}/;\n \t\t\tmy $p = $1;\n \t\t\tmy $pathname = $g->{path}->full_path($p);\n+\t\t\tmy $refname = $g->{ref}->full_path($p);\n+\t\t\tnext if $g->{skip} && grep { $refname eq $_ }\n+\t\t\t\t\t\t   @{$g->{skip}};\n \t\t\tnext if $exists->{$pathname};\n \t\t\tnext if ($self->check_path($pathname, $r) !=\n \t\t\t         $SVN::Node::dir);\n \t\t\t$exists->{$pathname} = Git::SVN->init(\n \t\t\t                      $self->{url}, $pathname, undef,\n-\t\t\t                      $g->{ref}->full_path($p), 1);\n+\t\t\t                      $refname, 1);\n \t\t}\n \t\tmy $c = '';\n \t\tforeach (split m#/#, $g->{path}->{left}) {\n-- \n1.6.3.3\n"},{"id":"135391","messageId":"20100223025017.GB4906@mail.stoakes.net","threadId":"22761","inReplyTo":"c8b3bef91002221429l3b277429l56f4e4cac4fdeb43@mail.gmail.com","subject":"Re: [PATCH/RFC] git-svn: Allow multiple branch and tag patterns","fromName":"Tim Stoakes","fromEmail":"tim@stoakes.net","sentAt":"2010-02-23T02:50:17Z","receivedAt":"2010-02-23T02:50:17Z","isPatch":true,"sender":{"key":"tim@stoakes.net","avatar":null},"body":"Michael Olson(mwolson@gnu.org)@220210-14:29:\n> This change allows multiple branch and tag patterns to be specified in\n> .git/config for git-svn projects.  This is useful for fetching several\n> different parts out of the namespace of an svn repository.\n> Additionally, a new repeatable directive called \"skip\" has been added\n> to specify a specific tag or branch to ignore.\n> \n> Signed-off-by: Michael W. Olson <mwolson@gnu.org>\n> ---\n> I've been using this patch regularly for over a year on a very large\n> svn repository.\n> \n> This patch is known to work on git 1.6.3.3 specifically.  Once I get a\n> few responses about whether or not it is useful, I'll rebase it\n> against the git.git master branch.\n\nYes please!\n\nTim\n\n-- \nTim Stoakes\n"},{"id":"135412","messageId":"4B83B303.50408@drmicha.warpmail.net","threadId":"22761","inReplyTo":"c8b3bef91002221429l3b277429l56f4e4cac4fdeb43@mail.gmail.com","subject":"Re: [PATCH/RFC] git-svn: Allow multiple branch and tag patterns","fromName":"Michael J Gruber","fromEmail":"git@drmicha.warpmail.net","sentAt":"2010-02-23T10:50:43Z","receivedAt":"2010-02-23T10:50:43Z","isPatch":true,"sender":{"key":"git@grubix.eu","avatar":"https://avatars.githubusercontent.com/u/233215?v=4"},"body":"Michael Olson venit, vidit, dixit 22.02.2010 23:29:\n> This change allows multiple branch and tag patterns to be specified in\n> .git/config for git-svn projects.  This is useful for fetching several\n> different parts out of the namespace of an svn repository.\n> Additionally, a new repeatable directive called \"skip\" has been added\n> to specify a specific tag or branch to ignore.\n> \n> Signed-off-by: Michael W. Olson <mwolson@gnu.org>\n> ---\n> I've been using this patch regularly for over a year on a very large\n> svn repository.\n> \n> This patch is known to work on git 1.6.3.3 specifically.  Once I get a\n> few responses about whether or not it is useful, I'll rebase it\n> against the git.git master branch.  Some further documentation\n> (perhaps just a relevant example or two) would also need to be added\n> to the git-svn manpage.\n\nI'm sorry, but we have this (multiple branch/tag lines) since 1.6.4, see\n\n6224406 (git svn: Support multiple branch and tag paths in the svn\nrepository., 2009-06-23)\n\nThe skip directive may be obsoleted by\n\n0757620 (git-svn: allow subset of branches/tags to be specified in glob\nspec, 2010-01-23)\n\nCheers,\nMichael\n"},{"id":"135429","messageId":"c8b3bef91002230641u3f831470m2b887e9479ca6cb2@mail.gmail.com","threadId":"22761","inReplyTo":"4B83B303.50408@drmicha.warpmail.net","subject":"Re: [PATCH/RFC] git-svn: Allow multiple branch and tag patterns","fromName":"Michael Olson","fromEmail":"mwolson@gnu.org","sentAt":"2010-02-23T14:41:23Z","receivedAt":"2010-02-23T14:41:23Z","isPatch":true,"sender":{"key":"mwolson@gnu.org","avatar":"https://avatars.githubusercontent.com/u/1510193?v=4"},"body":"> I'm sorry, but we have this (multiple branch/tag lines) since 1.6.4, see\n>\n> 6224406 (git svn: Support multiple branch and tag paths in the svn\n> repository., 2009-06-23)\n\nNeat, that definitely does what I want.\n\n> The skip directive may be obsoleted by\n>\n> 0757620 (git-svn: allow subset of branches/tags to be specified in glob\n> spec, 2010-01-23)\n\nThis, not as much, since I want to be able to exclude a specific\npattern rather than include specific patterns.  I'll have to try out a\nnewer git version to see if that workaround is still needed for my\n(admittedly bizarre) setup.\n\n-- \nMichael Olson  |  http://mwolson.org/\n"}]}