user/dev discussion of public-inbox itself
 help / color / mirror / code / Atom feed
* [PATCH] lei_mirror: allow `git show-ref' failures
@ 2022-12-23  6:05 Eric Wong
  0 siblings, 0 replies; only message in thread
From: Eric Wong @ 2022-12-23  6:05 UTC (permalink / raw)
  To: meta

`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 {

^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2022-12-23  6:05 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-12-23  6:05 [PATCH] lei_mirror: allow `git show-ref' failures Eric Wong

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).