]> Sergey Matveev's repositories - public-inbox.git/blobdiff - lib/PublicInbox/Inbox.pm
search: support alt-ID for mapping legacy serial numbers
[public-inbox.git] / lib / PublicInbox / Inbox.pm
index 4fbbb522f9c9d208dd54a240a3b68662f90163a5..922ca9bbdc78c297e8c690fee95cd7c6b34243bb 100644 (file)
@@ -87,7 +87,7 @@ sub search {
        my ($self) = @_;
        $self->{search} ||= eval {
                _weaken_later($self);
-               PublicInbox::Search->new($self->{mainrepo});
+               PublicInbox::Search->new($self->{mainrepo}, $self->{altid});
        };
 }
 
@@ -162,6 +162,18 @@ sub msg_by_path ($$;$) {
        $str;
 }
 
+sub msg_by_smsg ($$;$) {
+       my ($self, $smsg, $ref) = @_;
+
+       # backwards compat to fallback to msg_by_mid
+       # TODO: remove if we bump SCHEMA_VERSION in Search.pm:
+       defined(my $blob = $smsg->blob) or return msg_by_mid($self, $smsg->mid);
+
+       my $str = git($self)->cat_file($blob, $ref);
+       $$str =~ s/\A[\r\n]*From [^\r\n]*\r?\n//s if $str;
+       $str;
+}
+
 sub path_check {
        my ($self, $path) = @_;
        git($self)->check('HEAD:'.$path);