]> Sergey Matveev's repositories - public-inbox.git/blobdiff - lib/PublicInbox/Inbox.pm
searchmsg: add git object ID to doc_data
[public-inbox.git] / lib / PublicInbox / Inbox.pm
index 4fbbb522f9c9d208dd54a240a3b68662f90163a5..e552cd4f2ff38696bee4d2370f5b33aa10011561 100644 (file)
@@ -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);