{"thread":{"id":"28642","subject":"[PATCH v2] git-svn: Allow certain refs to be ignored","startedAt":"2011-10-10T23:27:37Z","lastAt":"2011-10-16T08:23:21Z","messageCount":2,"participants":["Michael Olson","Eric Wong"],"isPatch":true,"patchVersion":2,"patchTotal":null},"messages":[{"id":"177340","messageId":"CAN4ruPjaWgrk1HKmDR8XYdQcVOaYtj=RQ1R9=KYjGzOZ0-B_vA@mail.gmail.com","threadId":"28642","inReplyTo":null,"subject":"[PATCH v2] git-svn: Allow certain refs to be ignored","fromName":"Michael Olson","fromEmail":"mwolson@gnu.org","sentAt":"2011-10-10T23:27:37Z","receivedAt":"2011-10-10T23:27:37Z","isPatch":true,"sender":{"key":"mwolson@gnu.org","avatar":"https://avatars.githubusercontent.com/u/1510193?v=4"},"body":"Implement a new --ignore-refs option which specifies a regex of refs\nto ignore while importing svn history.\n\nThis is a useful supplement to the --ignore-paths option, as that\noption only operates on the contents of branches and tags, not the\nbranches and tags themselves.\n\nSigned-off-by: Michael Olson <mwolson@gnu.org>\n---\nRebased against git master.\n\n git-svn.perl |   38 +++++++++++++++++++++++++++++++++-----\n 1 files changed, 33 insertions(+), 5 deletions(-)\n\ndiff --git a/git-svn.perl b/git-svn.perl\nindex 351e743..fed1734 100755\n--- a/git-svn.perl\n+++ b/git-svn.perl\n@@ -94,7 +94,8 @@ $_q ||= 0;\n my %remote_opts = ( 'username=s' => \\$Git::SVN::Prompt::_username,\n                     'config-dir=s' => \\$Git::SVN::Ra::config_dir,\n                     'no-auth-cache' => \\$Git::SVN::Prompt::_no_auth_cache,\n-                    'ignore-paths=s' => \\$SVN::Git::Fetcher::_ignore_regex );\n+                    'ignore-paths=s' => \\$SVN::Git::Fetcher::_ignore_regex,\n+                    'ignore-refs=s' => \\$Git::SVN::Ra::_ignore_refs_regex );\n my %fc_opts = ( 'follow-parent|follow!' => \\$Git::SVN::_follow_parent,\n \t\t'authors-file|A=s' => \\$_authors,\n \t\t'authors-prog=s' => \\$_authors_prog,\n@@ -388,9 +389,12 @@ sub do_git_init_db {\n \t\tcommand_noisy('config', \"$pfx.$i\", $icv{$i});\n \t\t$set = $i;\n \t}\n-\tmy $ignore_regex = \\$SVN::Git::Fetcher::_ignore_regex;\n-\tcommand_noisy('config', \"$pfx.ignore-paths\", $$ignore_regex)\n-\t\tif defined $$ignore_regex;\n+\tmy $ignore_paths_regex = \\$SVN::Git::Fetcher::_ignore_regex;\n+\tcommand_noisy('config', \"$pfx.ignore-paths\", $$ignore_paths_regex)\n+\t\tif defined $$ignore_paths_regex;\n+\tmy $ignore_refs_regex = \\$Git::SVN::Ra::_ignore_refs_regex;\n+\tcommand_noisy('config', \"$pfx.ignore-refs\", $$ignore_refs_regex)\n+\t\tif defined $$ignore_refs_regex;\n\n \tif (defined $SVN::Git::Fetcher::_preserve_empty_dirs) {\n \t\tmy $fname = \\$SVN::Git::Fetcher::_placeholder_filename;\n@@ -2119,6 +2123,8 @@ sub read_all_remotes {\n \t\t\t$r->{$1}->{url} = $2;\n \t\t} elsif (m!^(.+)\\.pushurl=\\s*(.*)\\s*$!) {\n \t\t\t$r->{$1}->{pushurl} = $2;\n+\t\t} elsif (m!^(.+)\\.ignore-refs=\\s*(.*)\\s*$!) {\n+\t\t\t$r->{$1}->{ignore_refs_regex} = $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@@ -2155,6 +2161,16 @@ sub read_all_remotes {\n \t\t}\n \t} keys %$r;\n\n+\tforeach my $remote (keys %$r) {\n+\t\tforeach ( grep { defined $_ }\n+\t\t\t  map { $r->{$remote}->{$_} } qw(branches tags) ) {\n+\t\t\tforeach my $rs ( @$_ ) {\n+\t\t\t\t$rs->{ignore_refs_regex} =\n+\t\t\t\t    $r->{$remote}->{ignore_refs_regex};\n+\t\t\t}\n+\t\t}\n+\t}\n+\n \t$r;\n }\n\n@@ -5310,7 +5326,7 @@ sub apply_diff {\n }\n\n package Git::SVN::Ra;\n-use vars qw/@ISA $config_dir $_log_window_size/;\n+use vars qw/@ISA $config_dir $_ignore_refs_regex $_log_window_size/;\n use strict;\n use warnings;\n my ($ra_invalid, $can_do_switch, %ignored_err, $RA);\n@@ -5768,6 +5784,17 @@ sub get_dir_globbed {\n \t@finalents;\n }\n\n+# return value: 0 -- don't ignore, 1 -- ignore\n+sub is_ref_ignored {\n+\tmy ($g, $p) = @_;\n+\tmy $refname = $g->{ref}->full_path($p);\n+\treturn 1 if defined($g->{ignore_refs_regex}) &&\n+\t            $refname =~ m!$g->{ignore_refs_regex}!;\n+\treturn 0 unless defined($_ignore_refs_regex);\n+\treturn 1 if $refname =~ m!$_ignore_refs_regex!o;\n+\treturn 0;\n+}\n+\n sub match_globs {\n \tmy ($self, $exists, $paths, $globs, $r) = @_;\n\n@@ -5804,6 +5831,7 @@ 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\tnext if is_ref_ignored($g, $p);\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-- \n1.7.4.1\n"},{"id":"177765","messageId":"20111016082321.GA24210@dcvr.yhbt.net","threadId":"28642","inReplyTo":"CAN4ruPjaWgrk1HKmDR8XYdQcVOaYtj=RQ1R9=KYjGzOZ0-B_vA@mail.gmail.com","subject":"Re: [PATCH v2] git-svn: Allow certain refs to be ignored","fromName":"Eric Wong","fromEmail":"normalperson@yhbt.net","sentAt":"2011-10-16T08:23:21Z","receivedAt":"2011-10-16T08:23:21Z","isPatch":true,"sender":{"key":"e@80x24.org","avatar":null},"body":"Michael Olson <mwolson@gnu.org> wrote:\n> Signed-off-by: Michael Olson <mwolson@gnu.org>\n> ---\n> Rebased against git master.\n\nThanks, acked and pushed to git://bogomips.org/git-svn\n"}]}