]> Sergey Matveev's repositories - public-inbox.git/blobdiff - lib/PublicInbox/V2Writable.pm
wwwstream: discard single-use $ctx fields after use
[public-inbox.git] / lib / PublicInbox / V2Writable.pm
index 6021de4496a5e08b2504bbf5498a0d0d112427c6..9073d9ef89a8db95dd3db2d7c1b76cc26b758194 100644 (file)
@@ -16,7 +16,7 @@ use PublicInbox::ContentId qw(content_id content_digest);
 use PublicInbox::Inbox;
 use PublicInbox::OverIdx;
 use PublicInbox::Msgmap;
-use PublicInbox::Spawn qw(spawn);
+use PublicInbox::Spawn qw(spawn popen_rd);
 use PublicInbox::SearchIdx;
 use IO::Handle; # ->autoflush
 use File::Temp qw(tempfile);
@@ -471,17 +471,12 @@ sub git_hash_raw ($$) {
        print $tmp_fh $$raw or die "print \$tmp_fh: $!";
        sysseek($tmp_fh, 0, 0) or die "seek failed: $!";
 
-       my ($r, $w);
-       pipe($r, $w) or die "failed to create pipe: $!";
-       my $rdr = { 0 => $tmp_fh, 1 => $w };
        my $git_dir = $self->{-inbox}->git->{git_dir};
        my $cmd = ['git', "--git-dir=$git_dir", qw(hash-object --stdin)];
-       my $pid = spawn($cmd, undef, $rdr);
-       close $w;
+       my $r = popen_rd($cmd, undef, { 0 => $tmp_fh });
        local $/ = "\n";
        chomp(my $oid = <$r>);
-       waitpid($pid, 0) == $pid or die "git hash-object did not finish";
-       die "git hash-object failed: $?" if $?;
+       close $r or die "git hash-object failed: $?";
        $oid =~ /\A[a-f0-9]{40}\z/ or die "OID not expected: $oid";
        $oid;
 }
@@ -777,7 +772,6 @@ sub diff ($$$) {
        my $cmd = [ qw(diff -u), $an, $bn ];
        print STDERR "# MID conflict <$mid>\n";
        my $pid = spawn($cmd, undef, { 1 => 2 });
-       defined $pid or die "diff failed to spawn $!";
        waitpid($pid, 0) == $pid or die "diff did not finish";
        unlink($an, $bn);
 }