63
63
$sha1 = qr / [a-f\d ]{40}/ ;
64
64
$sha1_short = qr / [a-f\d ]{4,40}/ ;
65
65
my ($_stdin, $_help, $_edit,
66
- $_message, $_file,
66
+ $_message, $_file, $_branch_dest,
67
67
$_template, $_shared,
68
68
$_version, $_fetch_all, $_no_rebase, $_fetch_parent,
69
69
$_merge, $_strategy, $_dry_run, $_local,
@@ -92,11 +92,11 @@ BEGIN
92
92
' localtime' => \$Git::SVN::_localtime ,
93
93
%remote_opts );
94
94
95
- my ($_trunk, $ _tags, $ _branches, $_stdlayout);
95
+ my ($_trunk, @ _tags, @ _branches, $_stdlayout);
96
96
my %icv ;
97
97
my %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,
100
100
' stdlayout|s' => \$_stdlayout,
101
101
' minimize-url|m' => \$Git::SVN::_minimize_url ,
102
102
' no-metadata' => sub { $icv {noMetadata } = 1 },
@@ -141,11 +141,13 @@ BEGIN
141
141
branch => [ \&cmd_branch,
142
142
' Create a branch in the SVN repository' ,
143
143
{ ' message|m=s' => \$_message,
144
+ ' destination|d=s' => \$_branch_dest,
144
145
' dry-run|n' => \$_dry_run,
145
146
' tag|t' => \$_tag } ],
146
147
tag => [ sub { $_tag = 1; cmd_branch(@_ ) },
147
148
' Create a tag in the SVN repository' ,
148
149
{ ' message|m=s' => \$_message,
150
+ ' destination|d=s' => \$_branch_dest,
149
151
' dry-run|n' => \$_dry_run } ],
150
152
' set-tree' => [ \&cmd_set_tree,
151
153
" Set an SVN repository to a git tree-ish" ,
@@ -365,7 +367,7 @@ sub init_subdir {
365
367
sub cmd_clone {
366
368
my ($url , $path ) = @_ ;
367
369
if (!defined $path &&
368
- (defined $_trunk || defined $ _branches || defined $ _tags ||
370
+ (defined $_trunk || @ _branches || @ _tags ||
369
371
defined $_stdlayout) &&
370
372
$url !~ m # ^[a-z\+ ] +://# ) {
371
373
$path = $url ;
@@ -379,10 +381,10 @@ sub cmd_clone {
379
381
sub cmd_init {
380
382
if (defined $_stdlayout) {
381
383
$_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);
384
386
}
385
- if (defined $_trunk || defined $ _branches || defined $ _tags) {
387
+ if (defined $_trunk || @ _branches || @ _tags) {
386
388
return cmd_multi_init(@_ );
387
389
}
388
390
my $url = shift or die " SVN repository location required " ,
@@ -630,7 +632,31 @@ sub cmd_branch {
630
632
my ($src , $rev , undef , $gs ) = working_head_info($head );
631
633
632
634
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
+ }
634
660
my ($lft , $rgt ) = @{ $glob -> {path } }{qw/ left right/ };
635
661
my $dst = join ' /' , $remote -> {url }, $lft , $branch_name , ($rgt || ());
636
662
@@ -837,7 +863,7 @@ sub cmd_proplist {
837
863
838
864
sub cmd_multi_init {
839
865
my $url = shift ;
840
- unless (defined $_trunk || defined $ _branches || defined $ _tags) {
866
+ unless (defined $_trunk || @ _branches || @ _tags) {
841
867
usage(1);
842
868
}
843
869
@@ -862,10 +888,14 @@ sub cmd_multi_init {
862
888
undef , $trunk_ref );
863
889
}
864
890
}
865
- return unless defined $ _branches || defined $ _tags;
891
+ return unless @ _branches || @ _tags;
866
892
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
+ }
869
899
}
870
900
871
901
sub cmd_multi_fetch {
@@ -1150,6 +1180,7 @@ sub complete_url_ls_init {
1150
1180
die " --prefix='$pfx ' must have a trailing slash '/'\n " ;
1151
1181
}
1152
1182
command_noisy(' config' ,
1183
+ ' --add' ,
1153
1184
" svn-remote.$gs ->{repo_id}.$n " ,
1154
1185
" $remote_path :refs/remotes/$pfx *" .
1155
1186
(' /*' x (($remote_path =~ tr / */ */ ) - 1)) );
@@ -1616,7 +1647,8 @@ sub fetch_all {
1616
1647
# read the max revs for wildcard expansion (branches/*, tags/*)
1617
1648
foreach my $t (qw/ branches tags/ ) {
1618
1649
defined $remote -> {$t } or next ;
1619
- push @globs , $remote -> {$t };
1650
+ push @globs , @{$remote -> {$t }};
1651
+
1620
1652
my $max_rev = eval { tmp_config(qw/ --int --get/ ,
1621
1653
" svn-remote.$repo_id .${t} -maxRev" ) };
1622
1654
if (defined $max_rev && ($max_rev < $base )) {
@@ -1663,15 +1695,16 @@ sub read_all_remotes {
1663
1695
} elsif (m ! ^(.+)\. (branches|tags)=
1664
1696
(.*):refs/remotes/(.+)\s *$ /! x ) {
1665
1697
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 ) };
1671
1703
if (length ($rs -> {ref }-> {right }) != 0) {
1672
1704
die " The '*' glob character must be the last " ,
1673
1705
" character of '$g '\n " ;
1674
1706
}
1707
+ push @{ $r -> {$1 }-> {$2 } }, $rs ;
1675
1708
}
1676
1709
}
1677
1710
@@ -1811,9 +1844,10 @@ sub find_by_url { # repos_root and, path are optional
1811
1844
next if defined $repos_root && $repos_root ne $u ;
1812
1845
1813
1846
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
+ }
1817
1851
}
1818
1852
my $p = $path ;
1819
1853
my $rwr = rewrite_root({repo_id => $repo_id });
0 commit comments