- require PublicInbox::Git;
- my $git = $ctx->{git} ||= PublicInbox::Git->new($ctx->{git_dir});
- if ($flat) {
- pre_anchor_entry($seen, $_) for (@$msgs);
- __thread_entry(\$cb, $git, $state, $_, 0) for (@$msgs);
- } else {
- my $th = thread_results($msgs);
- thread_entry(\$cb, $git, $state, $_, 0) for $th->rootset;
- if (my $max = $state->{max_level}) {
- my $x = $max > 1 ? ('</ul></li>' x ($max-1)) : '';
- $cb->write($x . '</ul>');
- }
- }
- $git = undef;
- Email::Address->purge_cache;
-
- # there could be a race due to a message being deleted in git
- # but still being in the Xapian index:
- return missing_thread($cb, $ctx) if ($orig_cb eq $cb);
-
- my $final_anchor = $state->{anchor_idx};
- my $next = "<a\nid=s$final_anchor>";
- $next .= $final_anchor == 1 ? 'only message in' : 'end of';
- $next .= " thread</a>, back to <a\nhref=\"../../\">index</a>";
- $next .= "\ndownload thread: ";
- $next .= "<a\nhref=\"../t.mbox.gz\">mbox.gz</a>";
- $next .= " / follow: <a\nhref=\"../t.atom\">Atom feed</a>";
- $cb->write('<hr /><pre>' . $next . "\n\n".
- $foot . '</pre></body></html>');
- $cb->close;
-}
-
-sub index_walk {
- my ($fh, $part, $enc, $part_nr, $fhref, $more) = @_;
- my $s = add_text_body($enc, $part, $part_nr, $fhref);
-
- if ($more) {
- my $m = 0;
- # drop the remainder of git patches, they're usually better
- # to review when the full message is viewed
- $s =~ s!^---+\n.*\z!!ms and $m = 1;
-
- # Drop signatures
- $s =~ s/^-- \n.*\z//ms and $m = 1;
- $$more = "<b>More...</b>\n\n$$more" if $m;
- }
-
- # kill any leading or trailing whitespace lines
- $s =~ s/^\s*$//sgm;
- $s =~ s/\s+\z//s;