use Fcntl qw(SEEK_SET);
use Time::Local qw(timegm);
use PublicInbox::OverIdx;
-use PublicInbox::Spawn qw(run_wait run_qx);
+use PublicInbox::Spawn qw(run_wait popen_rd);
use PublicInbox::Git qw(git_unquote);
use PublicInbox::MsgTime qw(msg_timestamp msg_datestamp);
use PublicInbox::Address;
index_text($self, join("\n", @$xnq), 1, 'XNQ');
}
-sub patch_id {
- my ($self, $sref) = @_;
- my $git = ($self->{ibx} // $self->{eidx} // $self)->git;
- my $opt = { 0 => [ ':utf8', $sref ], 2 => \(my $err) };
- my $id = run_qx($git->cmd(qw(patch-id --stable)), undef, $opt);
- warn $err if $err;
- $id =~ /\A([a-f0-9]{40,})/ ? $1 : undef;
-}
-
sub index_body_text {
my ($self, $doc, $sref) = @_;
- if ($$sref =~ /^(?:diff|---|\+\+\+) /ms) {
- my $id = patch_id($self, $sref);
- $doc->add_term('XDFID'.$id) if defined($id);
+ my $rd;
+ if ($$sref =~ /^(?:diff|---|\+\+\+) /ms) { # start patch-id in parallel
+ my $git = ($self->{ibx} // $self->{eidx} // $self)->git;
+ $rd = popen_rd($git->cmd(qw(patch-id --stable)), undef,
+ { 0 => [ ':utf8', $sref ] });
}
# split off quoted and unquoted blocks:
}
undef $txt; # free memory
}
+ if (defined $rd) { # reap `git patch-id'
+ (readline($rd) // '') =~ /\A([a-f0-9]{40,})/ and
+ $doc->add_term('XDFID'.$1);
+ $rd->close or warn "W: git patch-id failed: \$?=$? (non-fatal)"
+ }
}
sub index_xapian { # msg_iter callback