aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEric Wong <normalperson@yhbt.net>2006-06-30 21:42:53 -0700
committerJunio C Hamano <junkio@cox.net>2006-06-30 22:50:47 -0700
commit03e0ea871206e50bcd1c5167c6fc9a41c6642abb (patch)
tree6dd752fb343a0831a0d568a9165e852aa1f2e1f5
parent560b25a86f30ad81d2bc3a383da19c3b7e631b8b (diff)
downloadgit-03e0ea871206e50bcd1c5167c6fc9a41c6642abb.tar.gz
git-03e0ea871206e50bcd1c5167c6fc9a41c6642abb.tar.xz
git-svn: allow a local target directory to be specified for init
git-svn init url://to/the/repo local-repo will create the local-repo dirrectory if doesn't exist yet and populate it as expected. Original patch by Luca Barbato, cleaned up and made to work for the current version of git-svn by me (Eric Wong). Signed-off-by: Eric Wong <normalperson@yhbt.net> Signed-off-by: Junio C Hamano <junkio@cox.net>
-rwxr-xr-xcontrib/git-svn/git-svn.perl14
1 files changed, 12 insertions, 2 deletions
diff --git a/contrib/git-svn/git-svn.perl b/contrib/git-svn/git-svn.perl
index b3d3f479d..1e19aa19b 100755
--- a/contrib/git-svn/git-svn.perl
+++ b/contrib/git-svn/git-svn.perl
@@ -264,9 +264,19 @@ when you have upgraded your tools and habits to use refs/remotes/$GIT_SVN
}
sub init {
- $SVN_URL = shift or die "SVN repository location required " .
+ my $url = shift or die "SVN repository location required " .
"as a command-line argument\n";
- $SVN_URL =~ s!/+$!!; # strip trailing slash
+ $url =~ s!/+$!!; # strip trailing slash
+
+ if (my $repo_path = shift) {
+ unless (-d $repo_path) {
+ mkpath([$repo_path]);
+ }
+ $GIT_DIR = $ENV{GIT_DIR} = $repo_path . "/.git";
+ init_vars();
+ }
+
+ $SVN_URL = $url;
unless (-d $GIT_DIR) {
my @init_db = ('git-init-db');
push @init_db, "--template=$_template" if defined $_template;