summaryrefslogtreecommitdiff
path: root/git-svn.perl
diff options
context:
space:
mode:
authorTobias Schulte <tobias.schulte@gliderpilot.de>2013-05-15 22:14:43 +0200
committerEric Wong <normalperson@yhbt.net>2013-05-20 22:05:54 +0000
commitf4f4c7fc00e8acf91150c717cf005fc36c1dd120 (patch)
tree73e91bb9aa07d678e030b9da193c13bf4672056b /git-svn.perl
parent7d82b4af1cefe55b825f524f250cd0002dbba4ab (diff)
downloadgit-f4f4c7fc00e8acf91150c717cf005fc36c1dd120.tar.gz
git-svn: introduce --parents parameter for commands branch and tag
This parameter is equivalent to the parameter --parents on svn cp commands and is useful for non-standard repository layouts. Signed-off-by: Tobias Schulte <tobias.schulte@gliderpilot.de> Signed-off-by: Eric Wong <normalperson@yhbt.net>
Diffstat (limited to 'git-svn.perl')
-rwxr-xr-xgit-svn.perl19
1 files changed, 18 insertions, 1 deletions
diff --git a/git-svn.perl b/git-svn.perl
index ccabe065f3..d070de012c 100755
--- a/git-svn.perl
+++ b/git-svn.perl
@@ -113,7 +113,7 @@ my ($_stdin, $_help, $_edit,
$_template, $_shared,
$_version, $_fetch_all, $_no_rebase, $_fetch_parent,
$_before, $_after,
- $_merge, $_strategy, $_preserve_merges, $_dry_run, $_local,
+ $_merge, $_strategy, $_preserve_merges, $_dry_run, $_parents, $_local,
$_prefix, $_no_checkout, $_url, $_verbose,
$_commit_url, $_tag, $_merge_info, $_interactive);
@@ -203,6 +203,7 @@ my %cmd = (
{ 'message|m=s' => \$_message,
'destination|d=s' => \$_branch_dest,
'dry-run|n' => \$_dry_run,
+ 'parents' => \$_parents,
'tag|t' => \$_tag,
'username=s' => \$Git::SVN::Prompt::_username,
'commit-url=s' => \$_commit_url } ],
@@ -211,6 +212,7 @@ my %cmd = (
{ 'message|m=s' => \$_message,
'destination|d=s' => \$_branch_dest,
'dry-run|n' => \$_dry_run,
+ 'parents' => \$_parents,
'username=s' => \$Git::SVN::Prompt::_username,
'commit-url=s' => \$_commit_url } ],
'set-tree' => [ \&cmd_set_tree,
@@ -1172,6 +1174,10 @@ sub cmd_branch {
$ctx->ls($dst, 'HEAD', 0);
} and die "branch ${branch_name} already exists\n";
+ if ($_parents) {
+ mk_parent_dirs($ctx, $dst);
+ }
+
print "Copying ${src} at r${rev} to ${dst}...\n";
$ctx->copy($src, $rev, $dst)
unless $_dry_run;
@@ -1179,6 +1185,17 @@ sub cmd_branch {
$gs->fetch_all;
}
+sub mk_parent_dirs {
+ my ($ctx, $parent) = @_;
+ $parent =~ s{/[^/]*$}{};
+
+ if (!eval{$ctx->ls($parent, 'HEAD', 0)}) {
+ mk_parent_dirs($ctx, $parent);
+ print "Creating parent folder ${parent} ...\n";
+ $ctx->mkdir($parent) unless $_dry_run;
+ }
+}
+
sub cmd_find_rev {
my $revision_or_hash = shift or die "SVN or git revision required ",
"as a command-line argument\n";