X-Git-Url: http://www.git.stargrave.org/?a=blobdiff_plain;f=lib%2FPublicInbox%2FGit.pm;h=218846f3d1d25d42699a4a4be55351394c6a5341;hb=f9fc5cf2e8cefda4a56d937ed217e47689fd7e49;hp=f5c7a95c34d7aedad7860a1189f8e121167eb1fb;hpb=4bb34fb8f29530f6bda5f0d563a74f6289ac312d;p=public-inbox.git
diff --git a/lib/PublicInbox/Git.pm b/lib/PublicInbox/Git.pm
index f5c7a95c..218846f3 100644
--- a/lib/PublicInbox/Git.pm
+++ b/lib/PublicInbox/Git.pm
@@ -1,4 +1,4 @@
-# Copyright (C) 2014-2018 all contributors
+# Copyright (C) 2014-2019 all contributors
# License: GPLv2 or later
#
# Used to read files from a git repository without excessive forking.
@@ -12,6 +12,7 @@ use warnings;
use POSIX qw(dup2);
require IO::Handle;
use PublicInbox::Spawn qw(spawn popen_rd);
+use PublicInbox::Tmpfile;
use base qw(Exporter);
our @EXPORT_OK = qw(git_unquote git_quote);
@@ -110,7 +111,8 @@ sub _bidi_pipe {
qw(-c core.abbrev=40 cat-file), $batch);
my $redir = { 0 => fileno($out_r), 1 => fileno($in_w) };
if ($err) {
- open(my $fh, '+>', undef) or fail($self, "open.err failed: $!");
+ my $id = "git.$self->{git_dir}$batch.err";
+ my $fh = tmpfile($id) or fail($self, "tmpfile($id): $!");
$self->{$err} = $fh;
$redir->{2} = fileno($fh);
}
@@ -198,7 +200,10 @@ sub _destroy {
my $p = delete $self->{$pid} or return;
delete @$self{($in, $out)};
delete $self->{$err} if $err; # `err_c'
- waitpid $p, 0;
+
+ # PublicInbox::DS may not be loaded
+ eval { PublicInbox::DS::dwaitpid($p, undef, undef) };
+ waitpid($p, 0) if $@; # wait synchronously if not in event loop
}
sub fail {
@@ -256,17 +261,6 @@ sub local_nick ($) {
wantarray ? ($ret) : $ret;
}
-# show the blob URL for cgit/gitweb/whatever
-sub src_blob_url {
- my ($self, $oid) = @_;
- # blob_url_format = "https://example.com/foo.git/blob/%s"
- if (my $bfu = $self->{blob_url_format}) {
- return map { sprintf($_, $oid) } @$bfu if wantarray;
- return sprintf($bfu->[0], $oid);
- }
- local_nick($self);
-}
-
sub host_prefix_url ($$) {
my ($env, $url) = @_;
return $url if index($url, '//') >= 0;