git-svn: add 'clone' command, an alias for init + fetch
Signed-off-by: Eric Wong <normalperson@yhbt.net>
Eric Wong committed
Feb 16, 2007 at 18:45 UTC
0425ea90889f967c3966ace3e5a85b9a5a44c358
1 file changed
+20
-1
git-svn.perl
+20
-1
@@ -90,6 +90,9 @@ my %cmd = (
90
{ 'revision|r=s' => \$_revision,
91
'fetch-all|all' => \$_fetch_all,
92
%fc_opts } ],
93
+ clone => [ \&cmd_clone, "Initialize and fetch revisions",
94
+ { 'revision|r=s' => \$_revision,
95
+ %fc_opts, %init_opts } ],
96
init => [ \&cmd_init, "Initialize a repo for tracking" .
97
" (requires URL argument)",
98
\%init_opts ],
@@ -167,7 +170,7 @@ usage(0) if $_help;
170
version() if $_version;
171
usage(1) unless defined $cmd;
172
load_authors() if $_authors;
170
-unless ($cmd =~ /^(?:init|multi-init|commit-diff)$/) {
173
+unless ($cmd =~ /^(?:clone|init|multi-init|commit-diff)$/) {
174
Git::SVN::Migration::migration_check();
175
}
176
Git::SVN::init_vars();
@@ -237,6 +240,22 @@ sub init_subdir {
240
$ENV{GIT_DIR} = $repo_path . "/.git";
241
}
242
243
+sub cmd_clone {
244
+ my ($url, $path) = @_;
245
+ if (!defined $path &&
246
+ (defined $_trunk || defined $_branches || defined $_tags) &&
247
+ $url !~ m#^[a-z\+]+://#) {
248
+ $path = $url;
249
+ }
250
+ warn "--path: $path\n" if defined $path;
251
+ $path = basename($url) if !defined $path || !length $path;
252
+ warn "++path: $path\n" if defined $path;
253
+ mkpath([$path]);
254
+ chdir $path or die "Couldn't chdir to $path\n";
255
+ cmd_init(@_);
256
+ Git::SVN::fetch_all($Git::SVN::default_repo_id);
257
+}
258
+
259
sub cmd_init {
260
if (defined $_trunk || defined $_branches || defined $_tags) {
261
return cmd_multi_init(@_);