]> Sergey Matveev's repositories - public-inbox.git/blobdiff - lib/PublicInbox/SolverGit.pm
solver: try the next patch on apply failures
[public-inbox.git] / lib / PublicInbox / SolverGit.pm
index 17a430606dfc64678583fd85a16b217a399213d8..3e3a5899f25523ca58605d5710207dcb5cfa1c1f 100644 (file)
@@ -259,7 +259,7 @@ sub prepare_index ($) {
        sysseek($in, 0, 0) or die "seek: $!";
 
        dbg($self, 'preparing index');
-       my $rdr = { 0 => fileno($in), -hold => $in };
+       my $rdr = { 0 => $in };
        my $cmd = [ qw(git update-index -z --index-info) ];
        my $qsp = PublicInbox::Qspawn->new($cmd, $self->{git_env}, $rdr);
        $path_a = git_quote($path_a);
@@ -452,6 +452,7 @@ sub apply_result ($$) {
                if ($nxt && oids_same_ish($nxt->{oid_b}, $di->{oid_b})) {
                        dbg($self, $msg);
                        dbg($self, 'trying '.di_url($self, $nxt));
+                       return do_git_apply($self);
                } else {
                        ERR($self, $msg);
                }
@@ -472,7 +473,7 @@ sub do_git_apply ($) {
        my $patches = $self->{patches};
 
        # we need --ignore-whitespace because some patches are CRLF
-       my @cmd = (qw(git -C), $dn, qw(apply --cached --ignore-whitespace
+       my @cmd = (qw(git apply --cached --ignore-whitespace
                        --unidiff-zero --whitespace=warn --verbose));
        my $len = length(join(' ', @cmd));
        my $total = $self->{tot};
@@ -491,8 +492,8 @@ sub do_git_apply ($) {
        } while (@$patches && $len < $ARG_SIZE_MAX &&
                 !oids_same_ish($patches->[0]->{oid_b}, $prv_oid_b));
 
-       my $rdr = { 2 => 1 };
-       my $qsp = PublicInbox::Qspawn->new(\@cmd, $self->{git_env}, $rdr);
+       my $opt = { 2 => 1, -C => $dn };
+       my $qsp = PublicInbox::Qspawn->new(\@cmd, $self->{git_env}, $opt);
        $self->{-cur_di} = $di;
        $self->{-qsp} = $qsp;
        $qsp->psgi_qx($self->{psgi_env}, undef, \&apply_result, $self);