* [PATCH] viewvcs: faster
@ 2024-02-12 13:02 Eric Wong
0 siblings, 0 replies; only message in thread
From: Eric Wong @ 2024-02-12 13:02 UTC (permalink / raw)
To: spew
---
lib/PublicInbox/ViewVCS.pm | 26 ++++++++++++--------------
1 file changed, 12 insertions(+), 14 deletions(-)
diff --git a/lib/PublicInbox/ViewVCS.pm b/lib/PublicInbox/ViewVCS.pm
index f755bf1e..7e13312e 100644
--- a/lib/PublicInbox/ViewVCS.pm
+++ b/lib/PublicInbox/ViewVCS.pm
@@ -28,7 +28,7 @@ use PublicInbox::Eml;
use Text::Wrap qw(wrap);
use PublicInbox::Hval qw(ascii_html to_filename prurl utf8_maybe);
use POSIX qw(strftime);
-use autodie qw(open seek);
+use autodie qw(open seek truncate);
use Fcntl qw(SEEK_SET);
my $hl = eval {
require PublicInbox::HlMod;
@@ -158,7 +158,14 @@ sub cmt_hdr_prep { # psgi_qx cb
utf8_maybe($buf); # non-UTF-8 commits exist
chomp $buf;
(my $P, my $p, @{$ctx->{cmt_info}}) = split(/\n/, $buf, 9);
+ truncate $fh, 0;
return unless $P;
+ seek $fh, 0, SEEK_SET;
+ my $qsp_p = PublicInbox::Qspawn->new($ctx->{git}->cmd(qw(show
+ --encoding=UTF-8 --pretty=format:%n -M --stat -p), $ctx->{oid}),
+ undef, { 1 => $fh });
+ $qsp_p->{qsp_err} = \($ctx->{-qsp_err_p} = '');
+ $qsp_p->psgi_qx($ctx->{env}, undef, \&cmt_patch_prep, $ctx, $cmt_fin);
@{$ctx->{-cmt_P}} = split / /, $P;
@{$ctx->{-cmt_p}} = split / /, $p; # abbreviated
do_cat_async([$ctx, $cmt_fin], \&cmt_title, @{$ctx->{-cmt_P}});
@@ -372,24 +379,15 @@ sub show_commit ($$) {
# patch-id needs two passes, and we use the initial show to ensure
# a patch embedded inside the commit message body doesn't get fed
# to patch-id:
- my $genv = { GIT_DIR => $git->{git_dir} };
- my $dir = "$ctx->{-tmp}";
- my ($opt_h, $opt_p) = ({ -C => $dir }, { -C => $dir });
- open $opt_h->{1}, '+>', "$dir/h";
- open $opt_p->{1}, '+>', "$dir/p";
- $ctx->{patch_fh} = $opt_p->{1};
+ open $ctx->{patch_fh}, '+>', "$ctx->{-tmp}/show";
my $qsp_h = PublicInbox::Qspawn->new($git->cmd('show', $SHOW_FMT,
- qw(--encoding=UTF-8 -z --no-notes --no-patch), $oid),
- $genv, $opt_h);
- my $qsp_p = PublicInbox::Qspawn->new($git->cmd(qw(show
- --encoding=UTF-8 --pretty=format:%n -M --stat -p), $oid),
- $genv, $opt_p);
+ qw(--encoding=UTF-8 -z --no-notes --no-patch), $oid),
+ undef, { 1 => $ctx->{patch_fh} });
$qsp_h->{qsp_err} = \($ctx->{-qsp_err_h} = '');
- $qsp_p->{qsp_err} = \($ctx->{-qsp_err_p} = '');
my $cmt_fin = PublicInbox::OnDestroy->new($$, \&cmt_fin, $ctx);
$ctx->{git} = $git;
+ $ctx->{oid} = $oid;
$qsp_h->psgi_qx($ctx->{env}, undef, \&cmt_hdr_prep, $ctx, $cmt_fin);
- $qsp_p->psgi_qx($ctx->{env}, undef, \&cmt_patch_prep, $ctx, $cmt_fin);
}
sub show_other ($$) { # just in case...
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2024-02-12 13:02 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-02-12 13:02 [PATCH] viewvcs: faster Eric Wong
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).