X-Git-Url: http://www.git.stargrave.org/?a=blobdiff_plain;f=lib%2FPublicInbox%2FSearchIdx.pm;h=6e6c6424a2468e3e3051ee270aa72813d906c15a;hb=87678710135973f72722258e171fc00f85c86ec8;hp=f03e290eb7eb60becb62d32fddfaa5f7e9672579;hpb=9aa510cd3c4563b375ca4fc9a821db832ab88081;p=public-inbox.git diff --git a/lib/PublicInbox/SearchIdx.pm b/lib/PublicInbox/SearchIdx.pm index f03e290e..6e6c6424 100644 --- a/lib/PublicInbox/SearchIdx.pm +++ b/lib/PublicInbox/SearchIdx.pm @@ -1,4 +1,4 @@ -# Copyright (C) 2015-2019 all contributors +# Copyright (C) 2015-2020 all contributors # License: AGPL-3.0+ # based on notmuch, but with no concept of folders, files or flags # @@ -19,6 +19,7 @@ use POSIX qw(strftime); use PublicInbox::OverIdx; use PublicInbox::Spawn qw(spawn); use PublicInbox::Git qw(git_unquote); +use PublicInbox::MsgTime qw(msg_timestamp msg_datestamp); my $X = \%PublicInbox::Search::X; my ($DB_CREATE_OR_OPEN, $DB_OPEN); use constant { @@ -220,12 +221,12 @@ sub index_diff ($$$) { next unless $opt =~ /[uU]/; $in_diff = index_old_diff_fn($self, \%seen, $fa, $fb, $xnq); - } elsif (m!^--- ("?a/.+)!) { + } elsif (m!^--- ("?[^/]+/.+)!) { my $fn = $1; $fn = (split('/', git_unquote($fn), 2))[1]; $seen{$fn}++ or index_diff_inc($self, $fn, 'XDFN', $xnq); $in_diff = 1; - } elsif (m!^\+\+\+ ("?b/.+)!) { + } elsif (m!^\+\+\+ ("?[^/]+/.+)!) { my $fn = $1; $fn = (split('/', git_unquote($fn), 2))[1]; $seen{$fn}++ or index_diff_inc($self, $fn, 'XDFN', $xnq); @@ -307,11 +308,14 @@ sub index_xapian { # msg_iter callback sub add_xapian ($$$$$$) { my ($self, $mime, $num, $oid, $mids, $mid0) = @_; - my $smsg = PublicInbox::SearchMsg->new($mime); + my $smsg = PublicInbox::Smsg->new($mime); + my $hdr = $mime->header_obj; + $smsg->{ds} = msg_datestamp($hdr, $self->{autime}); + $smsg->{ts} = msg_timestamp($hdr, $self->{cotime}); my $doc = $X->{Document}->new; my $subj = $smsg->subject; - add_val($doc, PublicInbox::Search::TS(), $smsg->ts); - my @ds = gmtime($smsg->ds); + add_val($doc, PublicInbox::Search::TS(), $smsg->{ts}); + my @ds = gmtime($smsg->{ds}); my $yyyymmdd = strftime('%Y%m%d', @ds); add_val($doc, PublicInbox::Search::YYYYMMDD(), $yyyymmdd); my $dt = strftime('%Y%m%d%H%M%S', @ds); @@ -375,7 +379,8 @@ sub add_message { add_xapian($self, $mime, $num, $oid, $mids, $mid0); } if (my $over = $self->{over}) { - $over->add_overview($mime, $bytes, $num, $oid, $mid0); + $over->add_overview($mime, $bytes, $num, $oid, $mid0, + $self); } }; @@ -460,7 +465,7 @@ sub remove_by_oid { for (; $head != $tail; $head++) { my $docid = $head->get_docid; my $doc = $db->get_document($docid); - my $smsg = PublicInbox::SearchMsg->wrap($mid); + my $smsg = PublicInbox::Smsg->wrap($mid); $smsg->load_expand($doc); if ($smsg->{blob} eq $oid) { push(@delete, $docid); @@ -596,6 +601,10 @@ sub read_log { } elsif ($line =~ /^commit ($h40)/o) { $latest = $1; $newest ||= $latest; + } elsif ($line =~ /^author .*? ([0-9]+) [\-\+][0-9]+$/) { + $self->{over}->{autime} = $self->{autime} = $1; + } elsif ($line =~ /^committer .*? ([0-9]+) [\-\+][0-9]+$/) { + $self->{over}->{cotime} = $self->{cotime} = $1; } } close($log) or die "git log failed: \$?=$?"; @@ -651,7 +660,7 @@ sub _git_log { $self->{regen_down} = $high + $fcount; } - $git->popen(qw/log --no-notes --no-color --no-renames + $git->popen(qw/log --pretty=raw --no-notes --no-color --no-renames --raw -r --no-abbrev/, $range); }