* [PATCH 2/3] viewvcs: use git(1) for coderepo access
2023-01-13 10:35 5% [PATCH 0/3] coderepo-related cleanups + sha256 Eric Wong
@ 2023-01-13 10:35 7% ` Eric Wong
0 siblings, 0 replies; 2+ results
From: Eric Wong @ 2023-01-13 10:35 UTC (permalink / raw)
To: meta
libgit2 development has fallen behind git.git and I've been
using objectformat=sha256 somewhere else for over 18 months.
Hoist out do_cat_async() into it's own sub to hide generic PSGI
vs -httpd differences while we're at it to save us some code.
---
lib/PublicInbox/ViewVCS.pm | 36 +++++++++++++---------------------
lib/PublicInbox/WwwCoderepo.pm | 9 +--------
2 files changed, 15 insertions(+), 30 deletions(-)
diff --git a/lib/PublicInbox/ViewVCS.pm b/lib/PublicInbox/ViewVCS.pm
index e0fdf639..eae5b7f4 100644
--- a/lib/PublicInbox/ViewVCS.pm
+++ b/lib/PublicInbox/ViewVCS.pm
@@ -125,6 +125,17 @@ sub cmt_title { # git->cat_async callback
cmt_finalize($ctx);
}
+sub do_cat_async {
+ my ($ctx, $cb, @oids) = @_;
+ # favor git(1) over Gcf2 (libgit2) for SHA-256 support
+ $ctx->{git}->cat_async($_, $cb, $ctx) for @oids;
+ if ($ctx->{env}->{'pi-httpd.async'}) {
+ PublicInbox::GitAsyncCat::watch_cat($ctx->{git});
+ } else { # synchronous, generic PSGI
+ $ctx->{git}->cat_async_wait;
+ }
+}
+
sub show_commit_start { # ->psgi_qx callback
my ($bref, $ctx) = @_;
if (my $qsp_err = delete $ctx->{-qsp_err}) {
@@ -142,16 +153,7 @@ sub show_commit_start { # ->psgi_qx callback
return cmt_finalize($ctx) if !$P;
@{$ctx->{-cmt_P}} = split(/ /, $P);
@{$ctx->{-cmt_p}} = split(/ /, $p); # abbreviated
- if ($ctx->{env}->{'pi-httpd.async'}) {
- for (@{$ctx->{-cmt_P}}) {
- ibx_async_cat($ctx, $_, \&cmt_title, $ctx);
- }
- } else { # synchronous
- for (@{$ctx->{-cmt_P}}) {
- $ctx->{git}->cat_async($_, \&cmt_title, $ctx);
- }
- $ctx->{git}->cat_async_wait;
- }
+ do_cat_async($ctx, \&cmt_title, @{$ctx->{-cmt_P}});
}
sub ibx_url_for {
@@ -473,12 +475,7 @@ sub show_tag ($$) {
my ($ctx, $res) = @_;
my ($git, $oid) = @$res;
$ctx->{git} = $git;
- if ($ctx->{env}->{'pi-httpd.async'}) {
- ibx_async_cat($ctx, $oid, \&show_tag_result, $ctx);
- } else { # synchronous (generic PSGI)
- $git->cat_async($oid, \&show_tag_result, $ctx);
- $git->cat_async_wait;
- }
+ do_cat_async($ctx, \&show_tag_result, $oid);
}
# user_cb for SolverGit, called as: user_cb->($result_or_error, $uarg)
@@ -508,12 +505,7 @@ EOM
}
bless $ctx, 'PublicInbox::WwwStream'; # for DESTROY
$ctx->{git} = $git;
- if ($ctx->{env}->{'pi-httpd.async'}) {
- ibx_async_cat($ctx, $oid, \&show_blob, $ctx);
- } else { # synchronous
- $git->cat_async($oid, \&show_blob, $ctx);
- $git->cat_async_wait;
- }
+ do_cat_async($ctx, \&show_blob, $oid);
}
sub show_blob { # git->cat_async callback
diff --git a/lib/PublicInbox/WwwCoderepo.pm b/lib/PublicInbox/WwwCoderepo.pm
index f9c150c0..5ca8ef55 100644
--- a/lib/PublicInbox/WwwCoderepo.pm
+++ b/lib/PublicInbox/WwwCoderepo.pm
@@ -11,8 +11,6 @@ use File::Temp 0.19 (); # newdir
use PublicInbox::ViewVCS;
use PublicInbox::WwwStatic qw(r);
use PublicInbox::GitHTTPBackend;
-use PublicInbox::Git;
-use PublicInbox::GitAsyncCat;
use PublicInbox::WwwStream;
use PublicInbox::Hval qw(ascii_html);
use PublicInbox::ViewDiff qw(uri_escape_path);
@@ -199,12 +197,7 @@ sub summary {
$tip //= 'HEAD';
my @try = ("$tip:README", "$tip:README.md"); # TODO: configurable
$ctx->{-nr_readme_tries} = [ @try ];
- $ctx->{git}->cat_async($_, \&set_readme, $ctx) for @try;
- if ($ctx->{env}->{'pi-httpd.async'}) {
- PublicInbox::GitAsyncCat::watch_cat($ctx->{git});
- } else { # synchronous
- $ctx->{git}->cat_async_wait;
- }
+ PublicInbox::ViewVCS::do_cat_async($ctx, \&set_readme, @try);
sub { # $_[0] => PublicInbox::HTTP::{Identity,Chunked}
$ctx->{env}->{'qspawn.wcb'} = $_[0];
$qsp->psgi_qx($ctx->{env}, undef, \&capture_refs, $ctx);
^ permalink raw reply related [relevance 7%]
* [PATCH 0/3] coderepo-related cleanups + sha256
@ 2023-01-13 10:35 5% Eric Wong
2023-01-13 10:35 7% ` [PATCH 2/3] viewvcs: use git(1) for coderepo access Eric Wong
0 siblings, 1 reply; 2+ results
From: Eric Wong @ 2023-01-13 10:35 UTC (permalink / raw)
To: meta
libgit2 on my system can't handle sha256 git repos, and I need
it for one of my projects. So stick to git(1) for now and
simplify our code.
Eric Wong (3):
qspawn: import Scalar::Util::blessed properly
viewvcs: use git(1) for coderepo access
coderepo: consolidate git --batch-check users
lib/PublicInbox/Qspawn.pm | 6 ++--
lib/PublicInbox/RepoSnapshot.pm | 51 +++++++++++++--------------------
lib/PublicInbox/RepoTree.pm | 8 +-----
lib/PublicInbox/ViewVCS.pm | 46 +++++++++++++++--------------
lib/PublicInbox/WwwCoderepo.pm | 9 +-----
5 files changed, 50 insertions(+), 70 deletions(-)
^ permalink raw reply [relevance 5%]
Results 1-2 of 2 | reverse | options above
-- pct% links below jump to the message on this page, permalinks otherwise --
2023-01-13 10:35 5% [PATCH 0/3] coderepo-related cleanups + sha256 Eric Wong
2023-01-13 10:35 7% ` [PATCH 2/3] viewvcs: use git(1) for coderepo access Eric Wong
Code repositories for project(s) associated with this public inbox
https://80x24.org/public-inbox.git
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).