Remove uncontested renamed files during merge.
[gitweb.git] / git-svn.perl
index 06e89ffecfd998c680da9e91282cbb2dfa4fb9c5..15254e479595de047258188e0979bea322869696 100755 (executable)
@@ -31,7 +31,7 @@
              'svn:entry:committed-date' => 1,
 );
 
-sub fatal (@) { print STDERR $@; exit 1 }
+sub fatal (@) { print STDERR @_; exit 1 }
 # If SVN:: library support is added, please make the dependencies
 # optional and preserve the capability to use the command-line client.
 # use eval { require SVN::... } to make it lazy load
@@ -604,8 +604,9 @@ sub commit_lib {
 }
 
 sub dcommit {
+       my $head = shift || 'HEAD';
        my $gs = "refs/remotes/$GIT_SVN";
-       chomp(my @refs = safe_qx(qw/git-rev-list --no-merges/, "$gs..HEAD"));
+       chomp(my @refs = safe_qx(qw/git-rev-list --no-merges/, "$gs..$head"));
        my $last_rev;
        foreach my $d (reverse @refs) {
                if (quiet_run('git-rev-parse','--verify',"$d~1") != 0) {
@@ -632,16 +633,16 @@ sub dcommit {
        }
        return if $_dry_run;
        fetch();
-       my @diff = safe_qx(qw/git-diff-tree HEAD/, $gs);
+       my @diff = safe_qx('git-diff-tree', $head, $gs);
        my @finish;
        if (@diff) {
                @finish = qw/rebase/;
                push @finish, qw/--merge/ if $_merge;
                push @finish, "--strategy=$_strategy" if $_strategy;
-               print STDERR "W: HEAD and $gs differ, using @finish:\n", @diff;
+               print STDERR "W: $head and $gs differ, using @finish:\n", @diff;
        } else {
-               print "No changes between current HEAD and $gs\n",
-                     "Hard resetting to the latest $gs\n";
+               print "No changes between current $head and $gs\n",
+                     "Resetting to the latest $gs\n";
                @finish = qw/reset --mixed/;
        }
        sys('git', @finish, $gs);
@@ -2026,9 +2027,17 @@ sub git_commit {
 
        # just in case we clobber the existing ref, we still want that ref
        # as our parent:
-       if (my $cur = eval { file_to_s("$GIT_DIR/refs/remotes/$GIT_SVN") }) {
+       open my $null, '>', '/dev/null' or croak $!;
+       open my $stderr, '>&', \*STDERR or croak $!;
+       open STDERR, '>&', $null or croak $!;
+       if (my $cur = eval { safe_qx('git-rev-parse',
+                                    "refs/remotes/$GIT_SVN^0") }) {
+               chomp $cur;
                push @tmp_parents, $cur;
        }
+       open STDERR, '>&', $stderr or croak $!;
+       close $stderr or croak $!;
+       close $null or croak $!;
 
        if (exists $tree_map{$tree}) {
                foreach my $p (@{$tree_map{$tree}}) {