From: Eric Wong Date: Sat, 15 Feb 2025 11:10:10 +0000 (+0000) Subject: rename Gcf2 -> Lg2 for general libgit2 use X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=f799f94e96c02f6b879363e65649c4777ebdb4a6;p=thirdparty%2Fpublic-inbox.git rename Gcf2 -> Lg2 for general libgit2 use We'll be exploring libgit2 for writing (and possibly reading) config files, so the `gcf2' (git-cat-file-2) name isn't appropriate anymore for the package name. We'll still keep `gcf2_' for subroutine names related to git-cat-file-like behavior. --- diff --git a/Documentation/public-inbox-tuning.pod b/Documentation/public-inbox-tuning.pod index b56c2b100..3f2c08616 100644 --- a/Documentation/public-inbox-tuning.pod +++ b/Documentation/public-inbox-tuning.pod @@ -71,7 +71,7 @@ public-inbox processes. If libgit2 development files are installed and L is enabled (described above), per-inbox C processes are replaced with a single L process running -C in read-only daemons. libgit2 use +C in read-only daemons. libgit2 use will be available in public-inbox 1.7.0+ More (optional) L use will be introduced in the future diff --git a/MANIFEST b/MANIFEST index f0b42826a..8f35c1adb 100644 --- a/MANIFEST +++ b/MANIFEST @@ -203,7 +203,6 @@ lib/PublicInbox/Filter/Mirror.pm lib/PublicInbox/Filter/RubyLang.pm lib/PublicInbox/Filter/SubjectTag.pm lib/PublicInbox/Filter/Vger.pm -lib/PublicInbox/Gcf2.pm lib/PublicInbox/Gcf2Client.pm lib/PublicInbox/GetlineResponse.pm lib/PublicInbox/Git.pm @@ -294,6 +293,7 @@ lib/PublicInbox/LeiUp.pm lib/PublicInbox/LeiViewText.pm lib/PublicInbox/LeiWatch.pm lib/PublicInbox/LeiXSearch.pm +lib/PublicInbox/Lg2.pm lib/PublicInbox/Limiter.pm lib/PublicInbox/Linkify.pm lib/PublicInbox/Listener.pm @@ -388,8 +388,8 @@ lib/PublicInbox/XapHelperCxx.pm lib/PublicInbox/Xapcmd.pm lib/PublicInbox/XhcMset.pm lib/PublicInbox/XhcMsetIterator.pm -lib/PublicInbox/gcf2_libgit2.h lib/PublicInbox/khashl.h +lib/PublicInbox/lg2.h lib/PublicInbox/xap_helper.h lib/PublicInbox/xh_cidx.h lib/PublicInbox/xh_mset.h diff --git a/lib/PublicInbox/Gcf2Client.pm b/lib/PublicInbox/Gcf2Client.pm index 07ff7dcb6..17bf34c7f 100644 --- a/lib/PublicInbox/Gcf2Client.pm +++ b/lib/PublicInbox/Gcf2Client.pm @@ -1,12 +1,12 @@ # Copyright (C) all contributors # License: AGPL-3.0+ -# connects public-inbox processes to PublicInbox::Gcf2::loop() +# connects public-inbox processes to PublicInbox::Lg2::gcf2_loop() package PublicInbox::Gcf2Client; use v5.12; use parent qw(PublicInbox::DS); use PublicInbox::Git; -use PublicInbox::Gcf2; # fails if Inline::C or libgit2-dev isn't available +use PublicInbox::Lg2; # fails if Inline::C or libgit2-dev isn't available use PublicInbox::Spawn qw(spawn); use Socket qw(AF_UNIX SOCK_STREAM); use PublicInbox::Syscall qw(EPOLLIN); @@ -14,10 +14,10 @@ use PublicInbox::IO; use autodie qw(socketpair); # fields: -# sock => socket to Gcf2::loop +# sock => socket to Lg2::gcf2_loop # The rest of these fields are compatible with what PublicInbox::Git # uses code-sharing -# pid => PID of Gcf2::loop process +# pid => PID of Lg2::gcf2_loop process # pid.owner => process which spawned {pid} # in => same as {sock}, for compatibility with PublicInbox::Git # inflight => array (see PublicInbox::Git) @@ -30,7 +30,7 @@ sub new { $s1->blocking(0); $opt->{0} = $opt->{1} = $s2; my $cmd = [$^X, $^W ? ('-w') : (), - qw[-MPublicInbox::Gcf2 -e PublicInbox::Gcf2::loop]]; + qw[-MPublicInbox::Lg2 -e PublicInbox::Lg2::gcf2_loop]]; $self->{inflight} = []; PublicInbox::IO::attach_pid($s1, spawn($cmd, $env, $opt), \&PublicInbox::Git::gcf_drain, $self->{inflight}); diff --git a/lib/PublicInbox/Gcf2.pm b/lib/PublicInbox/Lg2.pm similarity index 92% rename from lib/PublicInbox/Gcf2.pm rename to lib/PublicInbox/Lg2.pm index acc2091c3..0ee9b3544 100644 --- a/lib/PublicInbox/Gcf2.pm +++ b/lib/PublicInbox/Lg2.pm @@ -1,9 +1,8 @@ # Copyright (C) all contributors # License: AGPL-3.0+ -# backend for a git-cat-file-workalike based on libgit2, -# other libgit2 stuff may go here, too. -package PublicInbox::Gcf2; +# including backend for a git-cat-file-workalike based on libgit2, +package PublicInbox::Lg2; use v5.12; use PublicInbox::Spawn qw(which run_qx); # may set PERL_INLINE_DIRECTORY use Fcntl qw(SEEK_SET); @@ -35,7 +34,7 @@ BEGIN { die "E: libgit2 not installed: $err\n" if $?; $vals->{$k} = $val; } - my $f = "$dir/gcf2_libgit2.h"; + my $f = "$dir/lg2.h"; $c_src = PublicInbox::IO::try_cat $f or die "cat $f: $!"; # append pkg-config results to the source to ensure Inline::C # can rebuild if there's changes (it doesn't seem to detect @@ -62,7 +61,7 @@ EOM seek($fh, 0, SEEK_SET); my @msg = <$fh>; truncate($fh, 0); - die "Inline::C Gcf2 build failed:\n", $err, "\n", @msg; + die "Inline::C Lg2 build failed:\n", $err, "\n", @msg; } } @@ -86,9 +85,9 @@ sub add_alt ($$) { 1; } -# Usage: $^X -MPublicInbox::Gcf2 -e PublicInbox::Gcf2::loop [EXPIRE-TIMEOUT] +# Usage: $^X -MPublicInbox::Lg2 -e PublicInbox::Lg2::gcf2_loop [EXPIRE-TIMEOUT] # (see lib/PublicInbox/Gcf2Client.pm) -sub loop (;$) { +sub gcf2_loop (;$) { my $exp = $_[0] || $ARGV[0] || 60; # seconds my $gcf2 = new(); my (%seen, $check_at); diff --git a/lib/PublicInbox/SearchView.pm b/lib/PublicInbox/SearchView.pm index 8ae422f91..8464ae1b6 100644 --- a/lib/PublicInbox/SearchView.pm +++ b/lib/PublicInbox/SearchView.pm @@ -169,7 +169,7 @@ sub path2inc ($) { if (my $short = $rmap_inc{$full}) { return $short; } elsif (!scalar(keys %rmap_inc) && -e $full) { - # n.b. $INC{'PublicInbox::Gcf2'} is undef if libgit2-dev + # n.b. $INC{'PublicInbox::Lg2'} is undef if libgit2-dev # doesn't exist my $f; %rmap_inc = map {; diff --git a/lib/PublicInbox/Spawn.pm b/lib/PublicInbox/Spawn.pm index d818af0f1..f79623b72 100644 --- a/lib/PublicInbox/Spawn.pm +++ b/lib/PublicInbox/Spawn.pm @@ -330,7 +330,7 @@ EOM $all_libc = undef; } } - if (defined $all_libc) { # set for Gcf2 + if (defined $all_libc) { # set for Lg2 $ENV{PERL_INLINE_DIRECTORY} = $inline_dir; %RLIMITS = rlimit_map(); *send_cmd4 = sub ($$$$;$) { diff --git a/lib/PublicInbox/TestCommon.pm b/lib/PublicInbox/TestCommon.pm index e11781491..a9967735f 100644 --- a/lib/PublicInbox/TestCommon.pm +++ b/lib/PublicInbox/TestCommon.pm @@ -266,7 +266,7 @@ sub require_mods (@) { eval "require $mod"; } if ($@) { - diag "require $mod: $@" if $mod =~ /Gcf2/; + diag "require $mod: $@" if $mod =~ /Lg2/; push @need, $mod; } elsif ($mod eq 'IO::Socket::SSL' && # old versions of IO::Socket::SSL aren't supported diff --git a/lib/PublicInbox/ViewVCS.pm b/lib/PublicInbox/ViewVCS.pm index e1e129b11..552e3241b 100644 --- a/lib/PublicInbox/ViewVCS.pm +++ b/lib/PublicInbox/ViewVCS.pm @@ -129,7 +129,7 @@ sub cmt_title { # git->cat_async callback sub do_cat_async { my ($arg, $cb, @req) = @_; - # favor git(1) over Gcf2 (libgit2) for SHA-256 support + # favor git(1) over Lg2 (libgit2) for SHA-256 support my $ctx = ref $arg eq 'ARRAY' ? $arg->[0] : $arg; $ctx->{git}->cat_async($_, $cb, $arg) for @req; if ($ctx->{env}->{'pi-httpd.async'}) { diff --git a/lib/PublicInbox/gcf2_libgit2.h b/lib/PublicInbox/lg2.h similarity index 98% rename from lib/PublicInbox/gcf2_libgit2.h rename to lib/PublicInbox/lg2.h index e1f0ef39a..0b1a33e0c 100644 --- a/lib/PublicInbox/gcf2_libgit2.h +++ b/lib/PublicInbox/lg2.h @@ -29,7 +29,7 @@ SV *new() ref = newSViv((IV)odb); self = newRV_noinc(ref); - sv_bless(self, gv_stashpv("PublicInbox::Gcf2", GV_ADD)); + sv_bless(self, gv_stashpv("PublicInbox::Lg2", GV_ADD)); SvREADONLY_on(ref); return self; diff --git a/t/gcf2.t b/t/gcf2.t index 9f9e8e200..fc687058c 100644 --- a/t/gcf2.t +++ b/t/gcf2.t @@ -10,14 +10,14 @@ use Fcntl qw(:seek); use IO::Handle (); use POSIX qw(_exit); use Cwd qw(abs_path); -require_mods('PublicInbox::Gcf2'); -use_ok 'PublicInbox::Gcf2'; +require_mods('PublicInbox::Lg2'); +use_ok 'PublicInbox::Lg2'; use PublicInbox::Syscall qw($F_SETPIPE_SZ); use PublicInbox::Import; my ($tmpdir, $for_destroy) = tmpdir(); -my $gcf2 = PublicInbox::Gcf2::new(); -is(ref($gcf2), 'PublicInbox::Gcf2', '::new works'); +my $gcf2 = PublicInbox::Lg2::new(); +is(ref($gcf2), 'PublicInbox::Lg2', '::new works'); my $COPYING = 'dba13ed2ddf783ee8118c6a581dbf75305f816a3'; open my $agpl, '<', 'COPYING' or BAIL_OUT "AGPL-3 missing: $!"; $agpl = do { local $/; <$agpl> }; @@ -102,7 +102,7 @@ SKIP: { ok($gcf2->cat_oid(fileno($fh), $COPYING), 'cat_oid normal'); $ck_copying->('regular file'); - $gcf2 = PublicInbox::Gcf2::new(); + $gcf2 = PublicInbox::Lg2::new(); $gcf2->add_alternate("$tmpdir/objects"); open $fh, '+>', undef or BAIL_OUT "open: $!"; ok($gcf2->cat_oid(fileno($fh), $COPYING), 'cat_oid alternate'); @@ -150,7 +150,7 @@ if ($nr) { close $r; my $broken = fileno($w); for (1..$nr) { - my $obj = PublicInbox::Gcf2::new(); + my $obj = PublicInbox::Lg2::new(); if (defined($objdir)) { $obj->add_alternate($objdir); for (1..$cat) { diff --git a/t/gcf2_client.t b/t/gcf2_client.t index 33ee2c912..78921280b 100644 --- a/t/gcf2_client.t +++ b/t/gcf2_client.t @@ -8,7 +8,7 @@ use autodie qw(open close); use PublicInbox::Import; use PublicInbox::DS; -require_mods('PublicInbox::Gcf2'); +require_mods('PublicInbox::Lg2'); use_ok 'PublicInbox::Gcf2Client'; my ($tmpdir, $for_destroy) = tmpdir(); my $git_a = "$tmpdir/a.git";