git-svn: make multi-init less confusing
It now requires at least one of the (trunk|branch|tags) arguments (either from the command-line or in .git/config). Also we make sure that anything that is passed as a URL ('help') in David's case is actually a URL. Thanks to David Kågedal for reporting this issue. Signed-off-by: Eric Wong <normalperson@yhbt.net> Signed-off-by: Junio C Hamano <junkio@cox.net>
This commit is contained in:
parent
4fe2cc0c89
commit
98327e5891
64
git-svn.perl
64
git-svn.perl
@ -571,18 +571,11 @@ sub graft_branches {
|
|||||||
|
|
||||||
sub multi_init {
|
sub multi_init {
|
||||||
my $url = shift;
|
my $url = shift;
|
||||||
$_trunk ||= 'trunk';
|
unless (defined $_trunk || defined $_branches || defined $_tags) {
|
||||||
$_trunk =~ s#/+$##;
|
usage(1);
|
||||||
$url =~ s#/+$## if $url;
|
|
||||||
if ($_trunk !~ m#^[a-z\+]+://#) {
|
|
||||||
$_trunk = '/' . $_trunk if ($_trunk !~ m#^/#);
|
|
||||||
unless ($url) {
|
|
||||||
print STDERR "E: '$_trunk' is not a complete URL ",
|
|
||||||
"and a separate URL is not specified\n";
|
|
||||||
exit 1;
|
|
||||||
}
|
|
||||||
$_trunk = $url . $_trunk;
|
|
||||||
}
|
}
|
||||||
|
if (defined $_trunk) {
|
||||||
|
my $trunk_url = complete_svn_url($url, $_trunk);
|
||||||
my $ch_id;
|
my $ch_id;
|
||||||
if ($GIT_SVN eq 'git-svn') {
|
if ($GIT_SVN eq 'git-svn') {
|
||||||
$ch_id = 1;
|
$ch_id = 1;
|
||||||
@ -590,9 +583,13 @@ sub multi_init {
|
|||||||
}
|
}
|
||||||
init_vars();
|
init_vars();
|
||||||
unless (-d $GIT_SVN_DIR) {
|
unless (-d $GIT_SVN_DIR) {
|
||||||
print "GIT_SVN_ID set to 'trunk' for $_trunk\n" if $ch_id;
|
if ($ch_id) {
|
||||||
init($_trunk);
|
print "GIT_SVN_ID set to 'trunk' for ",
|
||||||
command_noisy('repo-config', 'svn.trunk', $_trunk);
|
"$trunk_url ($_trunk)\n";
|
||||||
|
}
|
||||||
|
init($trunk_url);
|
||||||
|
command_noisy('repo-config', 'svn.trunk', $trunk_url);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
complete_url_ls_init($url, $_branches, '--branches/-b', '');
|
complete_url_ls_init($url, $_branches, '--branches/-b', '');
|
||||||
complete_url_ls_init($url, $_tags, '--tags/-t', 'tags/');
|
complete_url_ls_init($url, $_tags, '--tags/-t', 'tags/');
|
||||||
@ -872,29 +869,34 @@ sub rec_fetch {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
sub complete_svn_url {
|
||||||
|
my ($url, $path) = @_;
|
||||||
|
$path =~ s#/+$##;
|
||||||
|
$url =~ s#/+$## if $url;
|
||||||
|
if ($path !~ m#^[a-z\+]+://#) {
|
||||||
|
$path = '/' . $path if ($path !~ m#^/#);
|
||||||
|
if (!defined $url || $url !~ m#^[a-z\+]+://#) {
|
||||||
|
fatal("E: '$path' is not a complete URL ",
|
||||||
|
"and a separate URL is not specified\n");
|
||||||
|
}
|
||||||
|
$path = $url . $path;
|
||||||
|
}
|
||||||
|
return $path;
|
||||||
|
}
|
||||||
|
|
||||||
sub complete_url_ls_init {
|
sub complete_url_ls_init {
|
||||||
my ($url, $var, $switch, $pfx) = @_;
|
my ($url, $path, $switch, $pfx) = @_;
|
||||||
unless ($var) {
|
unless ($path) {
|
||||||
print STDERR "W: $switch not specified\n";
|
print STDERR "W: $switch not specified\n";
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
$var =~ s#/+$##;
|
my $full_url = complete_svn_url($url, $path);
|
||||||
if ($var !~ m#^[a-z\+]+://#) {
|
my @ls = libsvn_ls_fullurl($full_url);
|
||||||
$var = '/' . $var if ($var !~ m#^/#);
|
|
||||||
unless ($url) {
|
|
||||||
print STDERR "E: '$var' is not a complete URL ",
|
|
||||||
"and a separate URL is not specified\n";
|
|
||||||
exit 1;
|
|
||||||
}
|
|
||||||
$var = $url . $var;
|
|
||||||
}
|
|
||||||
my @ls = libsvn_ls_fullurl($var);
|
|
||||||
my $old = $GIT_SVN;
|
|
||||||
defined(my $pid = fork) or croak $!;
|
defined(my $pid = fork) or croak $!;
|
||||||
if (!$pid) {
|
if (!$pid) {
|
||||||
foreach my $u (map { "$var/$_" } (grep m!/$!, @ls)) {
|
foreach my $u (map { "$full_url/$_" } (grep m!/$!, @ls)) {
|
||||||
$u =~ s#/+$##;
|
$u =~ s#/+$##;
|
||||||
if ($u !~ m!\Q$var\E/(.+)$!) {
|
if ($u !~ m!\Q$full_url\E/(.+)$!) {
|
||||||
print STDERR "W: Unrecognized URL: $u\n";
|
print STDERR "W: Unrecognized URL: $u\n";
|
||||||
die "This should never happen\n";
|
die "This should never happen\n";
|
||||||
}
|
}
|
||||||
@ -912,7 +914,7 @@ sub complete_url_ls_init {
|
|||||||
waitpid $pid, 0;
|
waitpid $pid, 0;
|
||||||
croak $? if $?;
|
croak $? if $?;
|
||||||
my ($n) = ($switch =~ /^--(\w+)/);
|
my ($n) = ($switch =~ /^--(\w+)/);
|
||||||
command_noisy('repo-config', "svn.$n", $var);
|
command_noisy('repo-config', "svn.$n", $full_url);
|
||||||
}
|
}
|
||||||
|
|
||||||
sub common_prefix {
|
sub common_prefix {
|
||||||
|
Loading…
Reference in New Issue
Block a user