about summary refs log tree commit homepage
path: root/lib/PublicInbox/LeiBlob.pm
diff options
context:
space:
mode:
Diffstat (limited to 'lib/PublicInbox/LeiBlob.pm')
-rw-r--r--lib/PublicInbox/LeiBlob.pm20
1 files changed, 11 insertions, 9 deletions
diff --git a/lib/PublicInbox/LeiBlob.pm b/lib/PublicInbox/LeiBlob.pm
index 127cc81e..7b2ea434 100644
--- a/lib/PublicInbox/LeiBlob.pm
+++ b/lib/PublicInbox/LeiBlob.pm
@@ -36,14 +36,13 @@ sub solver_user_cb { # called by solver when done
         ref($res) eq 'ARRAY' or return $lei->child_error(0, $$log_buf);
         $lei->qerr($$log_buf);
         my ($git, $oid, $type, $size, $di) = @$res;
-        my $gd = $git->{git_dir};
 
         # don't try to support all the git-show(1) options for non-blob,
         # this is just a convenience:
-        $type ne 'blob' and
-                warn "# $oid is a $type of $size bytes in:\n#\t$gd\n";
-
-        my $cmd = [ 'git', "--git-dir=$gd", 'show', $oid ];
+        $type ne 'blob' and warn <<EOM;
+# $oid is a $type of $size bytes in:\n#\t$git->{git_dir}
+EOM
+        my $cmd = $git->cmd('show', $oid);
         my $rdr = { 1 => $lei->{1}, 2 => $lei->{2} };
         run_wait($cmd, $lei->{env}, $rdr) and $lei->child_error($?);
 }
@@ -119,14 +118,17 @@ sub lei_blob {
                 } else {
                         open $rdr->{2}, '>', '/dev/null' or die "open: $!";
                 }
-                my $cmd = [ 'git', '--git-dir='.$lei->ale->git->{git_dir},
-                                'cat-file', 'blob', $blob ];
+                my $cmd = $lei->ale->git->cmd('cat-file', 'blob', $blob);
+                my $cerr;
                 if (defined $lei->{-attach_idx}) {
                         my $buf = run_qx($cmd, $lei->{env}, $rdr);
                         return extract_attach($lei, $blob, \$buf) unless $?;
+                        $cerr = $?;
+                } else {
+                        $rdr->{1} = $lei->{1}; # write directly to client
+                        $cerr = run_wait($cmd, $lei->{env}, $rdr) or return;
                 }
-                $rdr->{1} = $lei->{1};
-                my $cerr = run_wait($cmd, $lei->{env}, $rdr) or return;
+                # fall back to unimported ('lei index') and inflight blobs
                 my $lms = $lei->lms;
                 my $bref = ($lms ? $lms->local_blob($blob, 1) : undef) // do {
                         my $sto = $lei->{sto} // $lei->_lei_store;