git-svn: allow a local target directory to be specified for init
PATCH 1/1 git-svn: allow a local target directory to be specified for init
Original patch by Luca Barbato, cleaned up and made to work for the current version of git-svn by me (Eric Wong).
Quoted 9 lines · Luca Barbato
Since I'm lazy I just hacked a bit git-svn in order to create a target dir and init it if is passed as second parameter.
git-svn init url://to/the/repo local-repo
will create the local-repo dir if doesn't exist yet and populate it as expected.
Maybe someone else could find it useful
Signed-off-by Eric Wong <[email protected]>
--- contrib/git-svn/git-svn.perl | 14 ++++++++++++-- 1 files changed, 12 insertions(+), 2 deletions(-)
contrib/git-svn/git-svn.perl +12 -2
@@ -264,9 +264,19 @@ when you have upgraded your tools and ha } 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;
Signature · 1 line
1.4.1.rc1.g7fe3