about summary refs log tree commit homepage
path: root/lib/PublicInbox/RepoGitRaw.pm
diff options
context:
space:
mode:
Diffstat (limited to 'lib/PublicInbox/RepoGitRaw.pm')
-rw-r--r--lib/PublicInbox/RepoGitRaw.pm20
1 files changed, 11 insertions, 9 deletions
diff --git a/lib/PublicInbox/RepoGitRaw.pm b/lib/PublicInbox/RepoGitRaw.pm
index 858034a3..717ca71f 100644
--- a/lib/PublicInbox/RepoGitRaw.pm
+++ b/lib/PublicInbox/RepoGitRaw.pm
@@ -36,15 +36,17 @@ sub git_raw_check_res ($$$) {
                 my $buf = '';
                 $req->{-repo}->{git}->cat_async($req->{env}, $hex, sub {
                         my ($r) = @_;
-                        return if ref($r) ne 'SCALAR';
-                        $buf .= $$r;
-                        return if bytes::length($buf) < $size;
-                        $ct ||= index($buf, "\0") >= 0 ?
-                                        'application/octet-stream' :
-                                        'text/plain; charset=UTF-8';
-                        $res->([200, ['Content-Type', $ct,
-                                        'Content-Length', $size ],
-                                [ $buf ]]);
+                        if (ref($r) eq 'SCALAR') {
+                                $buf .= $$r;
+                        } elsif ($r == 0) {
+                                return if bytes::length($buf) < $size;
+                                $ct ||= index($buf, "\0") >= 0 ?
+                                                'application/octet-stream' :
+                                                'text/plain; charset=UTF-8';
+                                $res->([200, ['Content-Type', $ct,
+                                                'Content-Length', $size ],
+                                        [ $buf ]]);
+                        }
                 });
         }
 }