6363$sha1 = qr / [a-f\d ]{40}/ ;
6464$sha1_short = qr / [a-f\d ]{4,40}/ ;
6565my ($_stdin, $_help, $_edit,
66- $_message, $_file,
66+ $_message, $_file, $_branch_dest,
6767 $_template, $_shared,
6868 $_version, $_fetch_all, $_no_rebase, $_fetch_parent,
6969 $_merge, $_strategy, $_dry_run, $_local,
@@ -92,11 +92,11 @@ BEGIN
9292 ' localtime' => \$Git::SVN::_localtime ,
9393 %remote_opts );
9494
95- my ($_trunk, $ _tags, $ _branches, $_stdlayout);
95+ my ($_trunk, @ _tags, @ _branches, $_stdlayout);
9696my %icv ;
9797my %init_opts = ( ' template=s' => \$_template, ' shared:s' => \$_shared,
98- ' trunk|T=s' => \$_trunk, ' tags|t=s' => \$ _tags,
99- ' branches|b=s' => \$ _branches, ' prefix=s' => \$_prefix,
98+ ' trunk|T=s' => \$_trunk, ' tags|t=s@ ' => \@ _tags,
99+ ' branches|b=s@ ' => \@ _branches, ' prefix=s' => \$_prefix,
100100 ' stdlayout|s' => \$_stdlayout,
101101 ' minimize-url|m' => \$Git::SVN::_minimize_url ,
102102 ' no-metadata' => sub { $icv {noMetadata } = 1 },
@@ -141,11 +141,13 @@ BEGIN
141141 branch => [ \&cmd_branch,
142142 ' Create a branch in the SVN repository' ,
143143 { ' message|m=s' => \$_message,
144+ ' destination|d=s' => \$_branch_dest,
144145 ' dry-run|n' => \$_dry_run,
145146 ' tag|t' => \$_tag } ],
146147 tag => [ sub { $_tag = 1; cmd_branch(@_ ) },
147148 ' Create a tag in the SVN repository' ,
148149 { ' message|m=s' => \$_message,
150+ ' destination|d=s' => \$_branch_dest,
149151 ' dry-run|n' => \$_dry_run } ],
150152 ' set-tree' => [ \&cmd_set_tree,
151153 " Set an SVN repository to a git tree-ish" ,
@@ -365,7 +367,7 @@ sub init_subdir {
365367sub cmd_clone {
366368 my ($url , $path ) = @_ ;
367369 if (!defined $path &&
368- (defined $_trunk || defined $ _branches || defined $ _tags ||
370+ (defined $_trunk || @ _branches || @ _tags ||
369371 defined $_stdlayout) &&
370372 $url !~ m # ^[a-z\+ ] +://# ) {
371373 $path = $url ;
@@ -379,10 +381,10 @@ sub cmd_clone {
379381sub cmd_init {
380382 if (defined $_stdlayout) {
381383 $_trunk = ' trunk' if (!defined $_trunk);
382- $ _tags = ' tags' if (!defined $ _tags);
383- $ _branches = ' branches' if (!defined $ _branches);
384+ @ _tags = ' tags' if (! @ _tags);
385+ @ _branches = ' branches' if (! @ _branches);
384386 }
385- if (defined $_trunk || defined $ _branches || defined $ _tags) {
387+ if (defined $_trunk || @ _branches || @ _tags) {
386388 return cmd_multi_init(@_ );
387389 }
388390 my $url = shift or die " SVN repository location required " ,
@@ -630,7 +632,31 @@ sub cmd_branch {
630632 my ($src , $rev , undef , $gs ) = working_head_info($head );
631633
632634 my $remote = Git::SVN::read_all_remotes()-> {$gs -> {repo_id }};
633- my $glob = $remote -> { $_tag ? ' tags' : ' branches' };
635+ my $allglobs = $remote -> { $_tag ? ' tags' : ' branches' };
636+ my $glob ;
637+ if ($# {$allglobs } == 0) {
638+ $glob = $allglobs -> [0];
639+ } else {
640+ unless (defined $_branch_dest) {
641+ die " Multiple " ,
642+ $_tag ? " tag" : " branch" ,
643+ " paths defined for Subversion repository.\n " ,
644+ " You must specify where you want to create the " ,
645+ $_tag ? " tag" : " branch" ,
646+ " with the --destination argument.\n " ;
647+ }
648+ foreach my $g (@{$allglobs }) {
649+ if ($_branch_dest eq $g -> {path }-> {left }) {
650+ $glob = $g ;
651+ last ;
652+ }
653+ }
654+ unless (defined $glob ) {
655+ die " Unknown " ,
656+ $_tag ? " tag" : " branch" ,
657+ " destination $_branch_dest\n " ;
658+ }
659+ }
634660 my ($lft , $rgt ) = @{ $glob -> {path } }{qw/ left right/ };
635661 my $dst = join ' /' , $remote -> {url }, $lft , $branch_name , ($rgt || ());
636662
@@ -837,7 +863,7 @@ sub cmd_proplist {
837863
838864sub cmd_multi_init {
839865 my $url = shift ;
840- unless (defined $_trunk || defined $ _branches || defined $ _tags) {
866+ unless (defined $_trunk || @ _branches || @ _tags) {
841867 usage(1);
842868 }
843869
@@ -862,10 +888,14 @@ sub cmd_multi_init {
862888 undef , $trunk_ref );
863889 }
864890 }
865- return unless defined $ _branches || defined $ _tags;
891+ return unless @ _branches || @ _tags;
866892 my $ra = $url ? Git::SVN::Ra-> new($url ) : undef ;
867- complete_url_ls_init($ra , $_branches, ' --branches/-b' , $_prefix);
868- complete_url_ls_init($ra , $_tags, ' --tags/-t' , $_prefix . ' tags/' );
893+ foreach my $path (@_branches) {
894+ complete_url_ls_init($ra , $path , ' --branches/-b' , $_prefix);
895+ }
896+ foreach my $path (@_tags) {
897+ complete_url_ls_init($ra , $path , ' --tags/-t' , $_prefix.' tags/' );
898+ }
869899}
870900
871901sub cmd_multi_fetch {
@@ -1150,6 +1180,7 @@ sub complete_url_ls_init {
11501180 die " --prefix='$pfx ' must have a trailing slash '/'\n " ;
11511181 }
11521182 command_noisy(' config' ,
1183+ ' --add' ,
11531184 " svn-remote.$gs ->{repo_id}.$n " ,
11541185 " $remote_path :refs/remotes/$pfx *" .
11551186 (' /*' x (($remote_path =~ tr / */ */ ) - 1)) );
@@ -1616,7 +1647,8 @@ sub fetch_all {
16161647 # read the max revs for wildcard expansion (branches/*, tags/*)
16171648 foreach my $t (qw/ branches tags/ ) {
16181649 defined $remote -> {$t } or next ;
1619- push @globs , $remote -> {$t };
1650+ push @globs , @{$remote -> {$t }};
1651+
16201652 my $max_rev = eval { tmp_config(qw/ --int --get/ ,
16211653 " svn-remote.$repo_id .${t} -maxRev" ) };
16221654 if (defined $max_rev && ($max_rev < $base )) {
@@ -1663,15 +1695,16 @@ sub read_all_remotes {
16631695 } elsif (m ! ^(.+)\. (branches|tags)=
16641696 (.*):refs/remotes/(.+)\s *$ /! x ) {
16651697 my ($p , $g ) = ($3 , $4 );
1666- my $rs = $r -> { $1 } -> { $2 } = {
1667- t => $2 ,
1668- remote => $1 ,
1669- path => Git::SVN::GlobSpec-> new($p ),
1670- ref => Git::SVN::GlobSpec-> new($g ) };
1698+ my $rs = {
1699+ t => $2 ,
1700+ remote => $1 ,
1701+ path => Git::SVN::GlobSpec-> new($p ),
1702+ ref => Git::SVN::GlobSpec-> new($g ) };
16711703 if (length ($rs -> {ref }-> {right }) != 0) {
16721704 die " The '*' glob character must be the last " ,
16731705 " character of '$g '\n " ;
16741706 }
1707+ push @{ $r -> {$1 }-> {$2 } }, $rs ;
16751708 }
16761709 }
16771710
@@ -1811,9 +1844,10 @@ sub find_by_url { # repos_root and, path are optional
18111844 next if defined $repos_root && $repos_root ne $u ;
18121845
18131846 my $fetch = $remotes -> {$repo_id }-> {fetch } || {};
1814- foreach (qw/ branches tags/ ) {
1815- resolve_local_globs($u , $fetch ,
1816- $remotes -> {$repo_id }-> {$_ });
1847+ foreach my $t (qw/ branches tags/ ) {
1848+ foreach my $globspec (@{$remotes -> {$repo_id }-> {$t }}) {
1849+ resolve_local_globs($u , $fetch , $globspec );
1850+ }
18171851 }
18181852 my $p = $path ;
18191853 my $rwr = rewrite_root({repo_id => $repo_id });
0 commit comments