git-svn: fix clone when a target directory has been specified
Several bugs caused this to fail: * GIT_DIR was set incorrectly after entering the target directory * Avoid double chdir-ing when clone is called with an explicit path * create target subdirectory *before* running git-init when using the multi-init path Signed-off-by: Eric Wong <normalperson@yhbt.net>
Eric Wong committed
Feb 23, 2007 at 01:26 UTC
f30603fcf37f44942a2173386c0f580a508158df
1 file changed
+3
-7
git-svn.perl
+3
-7
@@ -276,7 +276,7 @@ sub init_subdir {
276
my $repo_path = shift or return;
277
mkpath([$repo_path]) unless -d $repo_path;
278
chdir $repo_path or die "Couldn't chdir to $repo_path: $!\n";
279
- $ENV{GIT_DIR} = $repo_path . "/.git";
279
+ $ENV{GIT_DIR} = '.git';
280
}
281
282
sub cmd_clone {
@@ -286,12 +286,8 @@ sub cmd_clone {
286
$url !~ m#^[a-z\+]+://#) {
287
$path = $url;
288
}
289
- warn "--path: $path\n" if defined $path;
289
$path = basename($url) if !defined $path || !length $path;
291
- warn "++path: $path\n" if defined $path;
292
- mkpath([$path]);
293
- chdir $path or die "Couldn't chdir to $path\n";
294
- cmd_init(@_);
290
+ cmd_init($url, $path);
291
Git::SVN::fetch_all($Git::SVN::default_repo_id);
292
}
293
@@ -459,12 +455,12 @@ sub cmd_multi_init {
455
unless (defined $_trunk || defined $_branches || defined $_tags) {
456
usage(1);
457
}
462
- do_git_init_db();
458
$_prefix = '' unless defined $_prefix;
459
if (defined $url) {
460
$url =~ s#/+$##;
461
init_subdir(@_);
462
}
463
+ do_git_init_db();
464
if (defined $_trunk) {
465
my $trunk_ref = $_prefix . 'trunk';
466
# try both old-style and new-style lookups: