]> Sergey Matveev's repositories - public-inbox.git/commitdiff
lei_mirror: allow `git show-ref' failures
authorEric Wong <e@80x24.org>
Fri, 23 Dec 2022 06:05:39 +0000 (06:05 +0000)
committerEric Wong <e@80x24.org>
Fri, 23 Dec 2022 06:52:02 +0000 (06:52 +0000)
`git show-ref' may fail on initialized-but-empty repositories.
So just unconditionally fetch those repos if we're in that
situation.

lib/PublicInbox/LeiMirror.pm

index 92156cf1cca8b250675bbbebba67971059ac7459..9843d1a67e3ab964d8e08a78d583a5ec4afcf527 100644 (file)
@@ -461,7 +461,11 @@ EOM
 }
 
 sub fp_done {
-       my ($self, $cb, @arg) = @_;
+       my ($self, $cmd, $cb, @arg) = @_;
+       if ($?) {
+               $self->{lei}->err("@$cmd failed (\$?=$?) (non-fatal)");
+               $? = 0; # don't let it influence normal exit
+       }
        return if !keep_going($self);
        my $fh = delete $self->{-show_ref} // die 'BUG: no show-ref output';
        seek($fh, SEEK_SET, 0) or die "seek(show_ref): $!";
@@ -487,8 +491,11 @@ sub cmp_fp_do {
        my $opt = { 2 => $self->{lei}->{2} };
        open($opt->{1}, '+>', undef) or die "open(tmp): $!";
        $self->{-show_ref} = $opt->{1};
-       my $done = PublicInbox::OnDestroy->new($$, \&fp_done, $self, $cb, @arg);
-       start_cmd($self, $cmd, $opt, $done);
+       do_reap($self);
+       $self->{lei}->qerr("# @$cmd");
+       return if $self->{dry_run};
+       $LIVE->{spawn($cmd, undef, $opt)} = [ \&fp_done, $self, $cmd,
+                                               $cb, @arg ];
 }
 
 sub resume_fetch {