builtin/merge.c: drop a parameter that is never used
[gitweb.git] / git-svn.perl
index 6c7bd95032b890d2f79cff0d18ac6aa688a74757..7349ffea5ad36f5677e7127fd693a72d155b1fa5 100755 (executable)
@@ -113,7 +113,7 @@ sub _req_svn {
        $_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);
 
@@ -126,6 +126,7 @@ sub _req_svn {
                     'config-dir=s' => \$Git::SVN::Ra::config_dir,
                     'no-auth-cache' => \$Git::SVN::Prompt::_no_auth_cache,
                     'ignore-paths=s' => \$Git::SVN::Fetcher::_ignore_regex,
+                    'include-paths=s' => \$Git::SVN::Fetcher::_include_regex,
                     'ignore-refs=s' => \$Git::SVN::Ra::_ignore_refs_regex );
 my %fc_opts = ( 'follow-parent|follow!' => \$Git::SVN::_follow_parent,
                'authors-file|A=s' => \$_authors,
@@ -202,6 +203,7 @@ sub _req_svn {
                    { '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 } ],
@@ -210,6 +212,7 @@ sub _req_svn {
                 { '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,
@@ -470,6 +473,9 @@ sub do_git_init_db {
        my $ignore_paths_regex = \$Git::SVN::Fetcher::_ignore_regex;
        command_noisy('config', "$pfx.ignore-paths", $$ignore_paths_regex)
                if defined $$ignore_paths_regex;
+       my $include_paths_regex = \$Git::SVN::Fetcher::_include_regex;
+       command_noisy('config', "$pfx.include-paths", $$include_paths_regex)
+               if defined $$include_paths_regex;
        my $ignore_refs_regex = \$Git::SVN::Ra::_ignore_refs_regex;
        command_noisy('config', "$pfx.ignore-refs", $$ignore_refs_regex)
                if defined $$ignore_refs_regex;
@@ -669,12 +675,14 @@ sub merge_revs_into_hash {
 }
 
 sub merge_merge_info {
-       my ($mergeinfo_one, $mergeinfo_two) = @_;
+       my ($mergeinfo_one, $mergeinfo_two, $ignore_branch) = @_;
        my %result_hash = ();
 
        merge_revs_into_hash(\%result_hash, $mergeinfo_one);
        merge_revs_into_hash(\%result_hash, $mergeinfo_two);
 
+       delete $result_hash{$ignore_branch} if $ignore_branch;
+
        my $result = '';
        # Sort below is for consistency's sake
        for my $branchname (sort keys(%result_hash)) {
@@ -695,6 +703,7 @@ sub populate_merge_info {
                my $all_parents_ok = 1;
                my $aggregate_mergeinfo = '';
                my $rooturl = $gs->repos_root;
+               my ($target_branch) = $gs->full_pushurl =~ /^\Q$rooturl\E(.*)/;
 
                if (defined($rewritten_parent)) {
                        # Replace first parent with newly-rewritten version
@@ -726,7 +735,8 @@ sub populate_merge_info {
                        # Merge previous mergeinfo values
                        $aggregate_mergeinfo =
                                merge_merge_info($aggregate_mergeinfo,
-                                                                $par_mergeinfo, 0);
+                                                               $par_mergeinfo,
+                                                               $target_branch);
 
                        next if $parent eq $parents[0]; # Skip first parent
                        # Add new changes being placed in tree by merge
@@ -769,7 +779,8 @@ sub populate_merge_info {
                        my $newmergeinfo = "$branchpath:" . join(',', @revsin);
                        $aggregate_mergeinfo =
                                merge_merge_info($aggregate_mergeinfo,
-                                                                $newmergeinfo, 1);
+                                                               $newmergeinfo,
+                                                               $target_branch);
                }
                if ($all_parents_ok and $aggregate_mergeinfo) {
                        return $aggregate_mergeinfo;
@@ -820,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';
@@ -1163,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;
@@ -1170,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";
@@ -1220,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;
        }
@@ -1363,7 +1389,17 @@ sub cmd_multi_init {
                usage(1);
        }
 
-       $_prefix = '' unless defined $_prefix;
+       unless (defined $_prefix) {
+               $_prefix = '';
+               warn <<EOF
+WARNING: --prefix is not given, defaulting to empty prefix.
+         This is probably not what you want! In order to stay compatible
+         with regular remote-tracking refs, provide a prefix like
+         --prefix=origin/ (remember the trailing slash), which will cause
+         the SVN-tracking refs to be placed at refs/remotes/origin/*.
+NOTE: In Git v2.0, the default prefix will change from empty to 'origin/'.
+EOF
+       }
        if (defined $url) {
                $url = canonicalize_url($url);
                init_subdir(@_);
@@ -1733,7 +1769,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
@@ -1906,7 +1942,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>) {