Skip to content

Commit 03e0ea8

Browse files
Eric WongJunio C Hamano
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 560b25a commit 03e0ea8

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

contrib/git-svn/git-svn.perl

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -264,9 +264,19 @@ sub rebuild {
264264
}
265265

266266
sub init {
267-
$SVN_URL = shift or die "SVN repository location required " .
267+
my $url = shift or die "SVN repository location required " .
268268
"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;
270280
unless (-d $GIT_DIR) {
271281
my @init_db = ('git-init-db');
272282
push @init_db, "--template=$_template" if defined $_template;

0 commit comments

Comments
 (0)