diff options
Diffstat (limited to 'git-svn.perl')
-rwxr-xr-x | git-svn.perl | 29 |
1 files changed, 23 insertions, 6 deletions
diff --git a/git-svn.perl b/git-svn.perl index ccabe065f3..0a323722a6 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, @@ -829,7 +831,7 @@ sub dcommit_rebase { sub cmd_dcommit { my $head = shift; command_noisy(qw/update-index --refresh/); - git_cmd_try { command_oneline(qw/diff-index --quiet HEAD/) } + git_cmd_try { command_oneline(qw/diff-index --quiet HEAD --/) } 'Cannot dcommit with a dirty index. Commit your changes first, ' . "or stash them with `git stash'.\n"; $head ||= 'HEAD'; @@ -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"; @@ -1229,7 +1246,7 @@ sub cmd_rebase { return; } if (command(qw/diff-index HEAD --/)) { - print STDERR "Cannot rebase with uncommited changes:\n"; + print STDERR "Cannot rebase with uncommitted changes:\n"; command_noisy('status'); exit 1; } @@ -1372,7 +1389,7 @@ sub cmd_multi_init { usage(1); } - $_prefix = '' unless defined $_prefix; + $_prefix = 'origin/' unless defined $_prefix; if (defined $url) { $url = canonicalize_url($url); init_subdir(@_); @@ -1742,7 +1759,7 @@ sub get_commit_entry { my $msgbuf = ""; while (<$msg_fh>) { if (!$in_msg) { - $in_msg = 1 if (/^\s*$/); + $in_msg = 1 if (/^$/); $author = $1 if (/^author (.*>)/); } elsif (/^git-svn-id: /) { # skip this for now, we regenerate the @@ -1915,7 +1932,7 @@ sub cmt_sha2rev_batch { sub working_head_info { my ($head, $refs) = @_; my @args = qw/rev-list --first-parent --pretty=medium/; - my ($fh, $ctx) = command_output_pipe(@args, $head); + my ($fh, $ctx) = command_output_pipe(@args, $head, "--"); my $hash; my %max; while (<$fh>) { |