+sub cat_async_step ($$) {
+ my ($self, $inflight) = @_;
+ die 'BUG: inflight empty or odd' if scalar(@$inflight) < 3;
+ my ($req, $cb, $arg) = splice(@$inflight, 0, 3);
+ my $rbuf = delete($self->{cat_rbuf}) // \(my $new = '');
+ my ($bref, $oid, $type, $size);
+ my $head = my_readline($self->{in}, $rbuf);
+ if ($head =~ /^([0-9a-f]{40}) (\S+) ([0-9]+)$/) {
+ ($oid, $type, $size) = ($1, $2, $3 + 0);
+ $bref = my_read($self->{in}, $rbuf, $size + 1) or
+ fail($self, defined($bref) ? 'read EOF' : "read: $!");
+ chop($$bref) eq "\n" or fail($self, 'LF missing after blob');
+ } elsif ($head =~ / missing$/) {
+ # ref($req) indicates it's already been retried
+ if (!ref($req) && !$in_cleanup && alternates_changed($self)) {
+ return cat_async_retry($self, $inflight,
+ $req, $cb, $arg);
+ }
+ $type = 'missing';
+ $oid = ref($req) ? $$req : $req;
+ } else {