about summary refs log tree commit homepage
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/PublicInbox/Gcf2Client.pm13
-rw-r--r--lib/PublicInbox/Git.pm5
-rw-r--r--lib/PublicInbox/GitAsyncCat.pm24
3 files changed, 18 insertions, 24 deletions
diff --git a/lib/PublicInbox/Gcf2Client.pm b/lib/PublicInbox/Gcf2Client.pm
index a048cd1a..30f85c71 100644
--- a/lib/PublicInbox/Gcf2Client.pm
+++ b/lib/PublicInbox/Gcf2Client.pm
@@ -23,19 +23,6 @@ sub new {
         $self;
 }
 
-sub add_git_dir {
-        my ($self, $git_dir) = @_;
-
-        # ensure buffers are drained, length($git_dir) may exceed
-        # PIPE_BUF on platforms where PIPE_BUF is only 512 bytes
-        my $inflight = $self->{inflight};
-        while (scalar(@$inflight)) {
-                $self->cat_async_step($inflight);
-        }
-        print { $self->{out} } $git_dir, "\n" or
-                                $self->fail("write error: $!");
-}
-
 # always false, since -gcf2 retries internally
 sub alternates_changed {}
 
diff --git a/lib/PublicInbox/Git.pm b/lib/PublicInbox/Git.pm
index b49b5bd3..6bb82b6b 100644
--- a/lib/PublicInbox/Git.pm
+++ b/lib/PublicInbox/Git.pm
@@ -190,7 +190,8 @@ sub cat_async_step ($$) {
                 $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$/) {
+        } elsif ($head =~ s/ missing\n//s) {
+                $oid = $head;
                 # ref($req) indicates it's already been retried
                 # -gcf2 retries internally, so it never hits this path:
                 if (!ref($req) && !$in_cleanup && $self->alternates_changed) {
@@ -198,7 +199,7 @@ sub cat_async_step ($$) {
                                                 $req, $cb, $arg);
                 }
                 $type = 'missing';
-                $oid = ref($req) ? $$req : $req;
+                $oid = ref($req) ? $$req : $req if $oid eq '';
         } else {
                 fail($self, "Unexpected result from async git cat-file: $head");
         }
diff --git a/lib/PublicInbox/GitAsyncCat.pm b/lib/PublicInbox/GitAsyncCat.pm
index db1a7f94..8a54c608 100644
--- a/lib/PublicInbox/GitAsyncCat.pm
+++ b/lib/PublicInbox/GitAsyncCat.pm
@@ -16,21 +16,27 @@ our @EXPORT = qw(git_async_cat);
 
 sub event_step {
         my ($self) = @_;
-        my $git = $self->{git};
-        return $self->close if ($git->{in} // 0) != ($self->{sock} // 1);
-        my $inflight = $git->{inflight};
+        my $gitish = $self->{gitish};
+        return $self->close if ($gitish->{in} // 0) != ($self->{sock} // 1);
+        my $inflight = $gitish->{inflight};
         if ($inflight && @$inflight) {
-                $git->cat_async_step($inflight);
-                $self->requeue if @$inflight || exists $git->{cat_rbuf};
+                $gitish->cat_async_step($inflight);
+                $self->requeue if @$inflight || exists $gitish->{cat_rbuf};
         }
 }
 
 sub git_async_cat ($$$$) {
         my ($git, $oid, $cb, $arg) = @_;
-        $git->cat_async($oid, $cb, $arg);
-        $git->{async_cat} //= do {
-                my $self = bless { git => $git }, __PACKAGE__;
-                $self->SUPER::new($git->{in}, EPOLLIN|EPOLLET);
+        my $gitish = $git->{gcf2c}; # PublicInbox::Gcf2Client
+        if ($gitish) {
+                $oid .= " $git->{git_dir}";
+        } else {
+                $gitish = $git;
+        }
+        $gitish->cat_async($oid, $cb, $arg);
+        $gitish->{async_cat} //= do {
+                my $self = bless { gitish => $gitish }, __PACKAGE__;
+                $self->SUPER::new($gitish->{in}, EPOLLIN|EPOLLET);
                 \undef; # this is a true ref()
         };
 }