user/dev discussion of public-inbox itself
 help / color / mirror / code / Atom feed
From: Eric Wong <e@80x24.org>
To: meta@public-inbox.org
Subject: [PATCH] lei_mirror: allow `git show-ref' failures
Date: Fri, 23 Dec 2022 06:05:39 +0000	[thread overview]
Message-ID: <20221223060539.932395-1-e@80x24.org> (raw)

`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 | 13 ++++++++++---
 1 file changed, 10 insertions(+), 3 deletions(-)

diff --git a/lib/PublicInbox/LeiMirror.pm b/lib/PublicInbox/LeiMirror.pm
index 92156cf1..9843d1a6 100644
--- a/lib/PublicInbox/LeiMirror.pm
+++ b/lib/PublicInbox/LeiMirror.pm
@@ -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 {

                 reply	other threads:[~2022-12-23  6:05 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://public-inbox.org/README

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20221223060539.932395-1-e@80x24.org \
    --to=e@80x24.org \
    --cc=meta@public-inbox.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://80x24.org/public-inbox.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).