ProcessPipe::CLOSE won't reliably set $? inside the event loop
if waitpid(..., WNOHANG) isn't successful. So use a blocking
waitpid() call, here, and hope "git show-ref" exits promptly
since we've already drained its stdout.
sub fingerprint ($) {
my ($git) = @_;
- my $fh = $git->popen('show-ref') or
+ # TODO: convert to qspawn for fairness when there's
+ # thousands of repos
+ my ($fh, $pid) = $git->popen('show-ref') or
die "popen($git->{git_dir} show-ref) failed: $!";
my $dig = Digest::SHA->new(1);
$dig->add($buf);
}
close $fh;
+ waitpid($pid, 0);
return if $?; # empty, uninitialized git repo
$dig->hexdigest;
}