From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: X-Spam-Status: No, score=-4.1 required=3.0 tests=ALL_TRUSTED,AWL,BAYES_00, T_SCC_BODY_TEXT_LINE shortcircuit=no autolearn=ham autolearn_force=no version=3.4.6 Received: from localhost (dcvr.yhbt.net [127.0.0.1]) by dcvr.yhbt.net (Postfix) with ESMTP id 5E4E01F44D for ; Mon, 12 Feb 2024 13:02:24 +0000 (UTC) From: Eric Wong To: spew@80x24.org Subject: [PATCH] viewvcs: faster Date: Mon, 12 Feb 2024 13:02:24 +0000 Message-ID: <20240212130224.1531052-1-e@80x24.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit List-Id: --- 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...