aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEric Wong <normalperson@yhbt.net>2007-02-16 18:45:01 -0800
committerEric Wong <normalperson@yhbt.net>2007-02-23 00:57:13 -0800
commit0425ea90889f967c3966ace3e5a85b9a5a44c358 (patch)
tree021e2090e13c7ee7dcf15ff67f4bd90f65e2ce97
parentb7e5348c7f6369554813207a24cf841f48bd8b23 (diff)
downloadgit-0425ea90889f967c3966ace3e5a85b9a5a44c358.tar.gz
git-0425ea90889f967c3966ace3e5a85b9a5a44c358.tar.xz
git-svn: add 'clone' command, an alias for init + fetch
Signed-off-by: Eric Wong <normalperson@yhbt.net>
-rwxr-xr-xgit-svn.perl21
1 files changed, 20 insertions, 1 deletions
diff --git a/git-svn.perl b/git-svn.perl
index 571259fd0..2cc7c3338 100755
--- a/git-svn.perl
+++ b/git-svn.perl
@@ -90,6 +90,9 @@ my %cmd = (
{ 'revision|r=s' => \$_revision,
'fetch-all|all' => \$_fetch_all,
%fc_opts } ],
+ clone => [ \&cmd_clone, "Initialize and fetch revisions",
+ { 'revision|r=s' => \$_revision,
+ %fc_opts, %init_opts } ],
init => [ \&cmd_init, "Initialize a repo for tracking" .
" (requires URL argument)",
\%init_opts ],
@@ -167,7 +170,7 @@ usage(0) if $_help;
version() if $_version;
usage(1) unless defined $cmd;
load_authors() if $_authors;
-unless ($cmd =~ /^(?:init|multi-init|commit-diff)$/) {
+unless ($cmd =~ /^(?:clone|init|multi-init|commit-diff)$/) {
Git::SVN::Migration::migration_check();
}
Git::SVN::init_vars();
@@ -237,6 +240,22 @@ sub init_subdir {
$ENV{GIT_DIR} = $repo_path . "/.git";
}
+sub cmd_clone {
+ my ($url, $path) = @_;
+ if (!defined $path &&
+ (defined $_trunk || defined $_branches || defined $_tags) &&
+ $url !~ m#^[a-z\+]+://#) {
+ $path = $url;
+ }
+ warn "--path: $path\n" if defined $path;
+ $path = basename($url) if !defined $path || !length $path;
+ warn "++path: $path\n" if defined $path;
+ mkpath([$path]);
+ chdir $path or die "Couldn't chdir to $path\n";
+ cmd_init(@_);
+ Git::SVN::fetch_all($Git::SVN::default_repo_id);
+}
+
sub cmd_init {
if (defined $_trunk || defined $_branches || defined $_tags) {
return cmd_multi_init(@_);