dumping ground for random patches and texts
 help / color / mirror / Atom feed
From: Eric Wong <e@80x24.org>
To: spew@80x24.org
Subject: [PATCH] viewvcs: faster
Date: Mon, 12 Feb 2024 13:02:24 +0000	[thread overview]
Message-ID: <20240212130224.1531052-1-e@80x24.org> (raw)

---
 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...

                 reply	other threads:[~2024-02-12 13:02 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20240212130224.1531052-1-e@80x24.org \
    --to=e@80x24.org \
    --cc=spew@80x24.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).