]> Sergey Matveev's repositories - public-inbox.git/blobdiff - lib/PublicInbox/LeiMirror.pm
lei_mirror: allow `git show-ref' failures
[public-inbox.git] / lib / PublicInbox / LeiMirror.pm
index d6d2c69eb90e981b57eeafbf7f8f8bf7576c769d..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 {
@@ -960,9 +967,13 @@ sub clone_all {
                        # resolve multi-level references
                        while ($m && defined($nxt = $m->{$x}->{reference})) {
                                exists($todo->{$nxt}) or last;
-                               die <<EOM if ++$nr > 1000;
-E: dependency loop detected (`$x' => `$nxt')
+                               if (++$nr > 1000) {
+                                       $m->{$x}->{reference} = undef;
+                                       $m->{$nxt}->{reference} = undef;
+                                       warn <<EOM
+E: dependency loop detected (`$x' => `$nxt'), breaking
 EOM
+                               }
                                $x = $nxt;
                        }
                        my $y = delete $todo->{$x} // next; # already done