@matheusbsbs / matheus-bagliano / commits / 03e0ea8712
Fork 0

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>

Eric Wong committed Jun 30, 2006 at 21:42 UTC 03e0ea871206e50bcd1c5167c6fc9a41c6642abb
1 file changed +12 -2
contrib/git-svn/git-svn.perl
+12 -2
@@ -264,9 +264,19 @@ when you have upgraded your tools and habits to use refs/remotes/$GIT_SVN
264 }
265
266 sub init {
267 - $SVN_URL = shift or die "SVN repository location required " .
267 + my $url = shift or die "SVN repository location required " .
268 "as a command-line argument\n";
269 - $SVN_URL =~ s!/+$!!; # strip trailing slash
269 + $url =~ s!/+$!!; # strip trailing slash
270 +
271 + if (my $repo_path = shift) {
272 + unless (-d $repo_path) {
273 + mkpath([$repo_path]);
274 + }
275 + $GIT_DIR = $ENV{GIT_DIR} = $repo_path . "/.git";
276 + init_vars();
277 + }
278 +
279 + $SVN_URL = $url;
280 unless (-d $GIT_DIR) {
281 my @init_db = ('git-init-db');
282 push @init_db, "--template=$_template" if defined $_template;