]> git.ipfire.org Git - thirdparty/public-inbox.git/commitdiff
move read_all, try_cat, and poll_in to PublicInbox::IO
authorEric Wong <e@80x24.org>
Thu, 2 Nov 2023 09:35:38 +0000 (09:35 +0000)
committerEric Wong <e@80x24.org>
Fri, 3 Nov 2023 06:39:44 +0000 (06:39 +0000)
The IO package seems like a better home for I/O subs than the
Git package.  We lose the 60 second read timeout for `git
cat-file --batch-*' processes since it's probably not necessary
given how reliable the code has proven and things would fall
over hard in other ways if the storage device were completely
hosed.

26 files changed:
lib/PublicInbox/Gcf2.pm
lib/PublicInbox/Git.pm
lib/PublicInbox/IO.pm
lib/PublicInbox/IdxStack.pm
lib/PublicInbox/Import.pm
lib/PublicInbox/Inbox.pm
lib/PublicInbox/InboxWritable.pm
lib/PublicInbox/LeiALE.pm
lib/PublicInbox/LeiBlob.pm
lib/PublicInbox/LeiConfig.pm
lib/PublicInbox/LeiMailSync.pm
lib/PublicInbox/LeiMirror.pm
lib/PublicInbox/LeiSucks.pm
lib/PublicInbox/MultiGit.pm
lib/PublicInbox/TestCommon.pm
lib/PublicInbox/ViewVCS.pm
lib/PublicInbox/WWW.pm
lib/PublicInbox/XapHelper.pm
lib/PublicInbox/XapHelperCxx.pm
script/public-inbox-convert
script/public-inbox-edit
script/public-inbox-init
t/cindex.t
t/clone-coderepo.t
t/init.t
t/lei-mirror.t

index 6ee0d7d98579335df07bb4cd517813bb1dc2234d..5490049d485b61b7a4d6bf0f3d450f1d4cc70c13 100644 (file)
@@ -37,7 +37,7 @@ BEGIN {
                $vals->{$k} = $val;
        }
        my $f = "$dir/gcf2_libgit2.h";
-       $c_src = PublicInbox::Git::try_cat($f) or die "cat $f: $!";
+       $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
        # $CFG{CCFLAGSEX} nor $CFG{CPPFLAGS} changes)
index d00f576e40b3aeb8bbaf6e551cf656a3a264c86e..11712db295fa5e10ee90427f146adf5a14019771 100644 (file)
@@ -18,16 +18,14 @@ use Errno qw(EINTR EAGAIN);
 use File::Glob qw(bsd_glob GLOB_NOSORT);
 use File::Spec ();
 use PublicInbox::Spawn qw(spawn popen_rd run_qx which);
-use PublicInbox::IO;
+use PublicInbox::IO qw(poll_in read_all try_cat);
 use PublicInbox::Tmpfile;
-use IO::Poll qw(POLLIN);
 use Carp qw(croak carp);
 use PublicInbox::SHA qw(sha_all);
 our %HEXLEN2SHA = (40 => 1, 64 => 256);
 our %OFMT2HEXLEN = (sha1 => 40, sha256 => 64);
-our @EXPORT_OK = qw(git_unquote git_quote %HEXLEN2SHA %OFMT2HEXLEN read_all);
+our @EXPORT_OK = qw(git_unquote git_quote %HEXLEN2SHA %OFMT2HEXLEN);
 our $in_cleanup;
-our $RDTIMEO = 60_000; # milliseconds
 our $async_warn; # true in read-only daemons
 
 # committerdate:unix is git 2.9.4+ (2017-05-05), so using raw instead
@@ -168,8 +166,6 @@ sub _sock_cmd {
        $self->{sock} = PublicInbox::IO::attach_pid($s1, $pid);
 }
 
-sub poll_in ($) { IO::Poll::_poll($RDTIMEO, fileno($_[0]), my $ev = POLLIN) }
-
 sub my_read ($$$) {
        my ($fh, $rbuf, $len) = @_;
        my $left = $len - length($$rbuf);
@@ -555,22 +551,6 @@ sub modified ($;$) {
        (split(/ /, <$fh> // time))[0] + 0; # integerize for JSON
 }
 
-# read_all/try_cat can probably be moved somewhere else...
-
-sub read_all ($;$$) {
-       my ($fh, $len, $bref) = @_;
-       $bref //= \(my $buf);
-       my $r = read($fh, $$bref, $len //= -s $fh);
-       croak("$fh read ($r != $len)") if $len != $r;
-       $$bref;
-}
-
-sub try_cat {
-       my ($path) = @_;
-       open(my $fh, '<', $path) or return '';
-       read_all($fh);
-}
-
 sub cat_desc ($) {
        my $desc = try_cat($_[0]);
        chomp $desc;
index 4c92566d1316ed1e1e3cce709ce95cfa5947dd97..0d30350049452d3f186b61c8192effb50a68f7bf 100644 (file)
@@ -6,10 +6,9 @@ package PublicInbox::IO;
 use v5.12;
 use parent qw(IO::Handle Exporter);
 use PublicInbox::DS qw(awaitpid);
-our @EXPORT_OK = qw(write_file);
-
-# TODO: this can probably be the new home for read_all, try_cat
-# and maybe even buffered read/readline...
+our @EXPORT_OK = qw(poll_in read_all try_cat write_file);
+use Carp qw(croak);
+use IO::Poll qw(POLLIN);
 
 sub waitcb { # awaitpid callback
        my ($pid, $errref, $cb, @args) = @_;
@@ -59,4 +58,23 @@ sub write_file ($$@) { # mode, filename, LIST (for print)
        defined(wantarray) && !wantarray ? $fh : close $fh;
 }
 
+sub poll_in ($;$) {
+       IO::Poll::_poll($_[1] // -1, fileno($_[0]), my $ev = POLLIN);
+}
+
+sub read_all ($;$$) {
+       use autodie qw(read);
+       my ($io, $len, $bref) = @_;
+       $bref //= \(my $buf);
+       my $r = read($io, $$bref, $len //= -s $io);
+       croak("read($io) ($r != $len)") if $len != $r;
+       $$bref;
+}
+
+sub try_cat ($) {
+       my ($path) = @_;
+       open(my $fh, '<', $path) or return '';
+       read_all $fh;
+}
+
 1;
index cc9e0125d35711342949a95511eff0da8415d7a7..7681ee6f17fe263730328f4e6f1e830a7f5a688d 100644 (file)
@@ -8,7 +8,7 @@ use v5.12;
 use Fcntl qw(:seek);
 use constant PACK_FMT => eval { pack('Q', 1) } ? 'A1QQH*H*' : 'A1IIH*H*';
 use autodie qw(open seek);
-use PublicInbox::Git qw(read_all);
+use PublicInbox::IO qw(read_all);
 
 # start off in write-only mode
 sub new {
index 5b0201c6083f5fe25cc34edccca56c29b03e7065..2d60db55496a6d041ebfbd85ab825cb7c61305f1 100644 (file)
@@ -21,7 +21,7 @@ use POSIX qw(strftime);
 use autodie qw(socketpair);
 use Carp qw(croak);
 use Socket qw(AF_UNIX SOCK_STREAM);
-use PublicInbox::Git qw(read_all);
+use PublicInbox::IO qw(read_all);
 
 sub default_branch () {
        state $default_branch = do {
index b31f3fff71b470ad883091aaa60c2a09ffe9fca0..e71ef6d2a51e806ce9536789fef77a70f79601c6 100644 (file)
@@ -189,7 +189,7 @@ sub cloneurl {
        my ($self) = @_;
        $self->{cloneurl} // do {
                my @urls = split(/\s+/s,
-                 PublicInbox::Git::try_cat("$self->{inboxdir}/cloneurl"));
+                       PublicInbox::IO::try_cat "$self->{inboxdir}/cloneurl");
                scalar(@urls) ? ($self->{cloneurl} = \@urls) : undef;
        } // [];
 }
index 6af72e71a3d70b0dab3f190cdd1e10ecdc7b732b..8e95cb2866403fa195f2ad22717042a18e1fd1b5 100644 (file)
@@ -7,7 +7,7 @@ use strict;
 use v5.10.1;
 use parent qw(PublicInbox::Inbox PublicInbox::Umask Exporter);
 use PublicInbox::Import;
-use PublicInbox::Git qw(read_all);
+use PublicInbox::IO qw(read_all);
 use PublicInbox::Filter::Base qw(REJECT);
 use Errno qw(ENOENT);
 our @EXPORT_OK = qw(eml_from_path);
index 674d897e85be2b099d7ebf98ce94e987bf19e201..528de22c5b4e10f3ce33040eded67924b0ca396a 100644 (file)
@@ -8,7 +8,7 @@
 package PublicInbox::LeiALE;
 use v5.12;
 use parent qw(PublicInbox::LeiSearch PublicInbox::Lock);
-use PublicInbox::Git qw(read_all);
+use PublicInbox::Git;
 use autodie qw(close open rename seek truncate);
 use PublicInbox::Import;
 use PublicInbox::LeiXSearch;
@@ -54,7 +54,7 @@ sub refresh_externals {
        $self->git->cleanup;
        my $lk = $self->lock_for_scope;
        my $cur_lxs = ref($lxs)->new;
-       my $orig = read_all($self->{lockfh});
+       my $orig = PublicInbox::IO::read_all $self->{lockfh};
        my $new = '';
        my $old = '';
        my $gone = 0;
@@ -86,7 +86,7 @@ sub refresh_externals {
        }
        $new = '';
        my $f = $self->git->{git_dir}.'/objects/info/alternates';
-       $old = PublicInbox::Git::try_cat($f);
+       $old = PublicInbox::IO::try_cat $f;
        for my $x (@ibxish) {
                $new .= $lei->canonpath_harder($x->git->{git_dir})."/objects\n";
        }
index 648d35b6ab4d50cc2852d605d501d1d82a08dea9..127cc81ef5654cf2db8298c6ca5ffec75c18faa4 100644 (file)
@@ -10,7 +10,8 @@ use parent qw(PublicInbox::IPC);
 use PublicInbox::Spawn qw(run_wait run_qx which);
 use PublicInbox::DS;
 use PublicInbox::Eml;
-use PublicInbox::Git qw(read_all);
+use PublicInbox::Git;
+use PublicInbox::IO qw(read_all);
 
 sub get_git_dir ($$) {
        my ($lei, $d) = @_;
index b915d787bf282e440d1a7c1603e6f079e0c48e64..a50ff2b600006a8c81ed6145bdc2fd2b76b55b05 100644 (file)
@@ -5,7 +5,7 @@ use v5.12;
 use PublicInbox::PktOp;
 use Fcntl qw(SEEK_SET);
 use autodie qw(open seek);
-use PublicInbox::Git qw(read_all);
+use PublicInbox::IO qw(read_all);
 
 sub cfg_do_edit ($;$) {
        my ($self, $reason) = @_;
index 74ef136261078970d0480473e3d0d26819a059a8..17254a82df21de7a80ce308b377285db8f928d9a 100644 (file)
@@ -10,7 +10,8 @@ use PublicInbox::Compat qw(uniqstr);
 use DBI qw(:sql_types); # SQL_BLOB
 use PublicInbox::ContentHash qw(git_sha);
 use Carp ();
-use PublicInbox::Git qw(%HEXLEN2SHA read_all);
+use PublicInbox::Git qw(%HEXLEN2SHA);
+use PublicInbox::IO qw(read_all);
 
 sub dbh_new {
        my ($self) = @_;
index e4914f75ee832e9bbe14d4cbeff3e2717be770fb..49febe9edb6b2976e699ae55821201c9bbc80e37 100644 (file)
@@ -17,7 +17,6 @@ use Carp qw(croak);
 use URI;
 use PublicInbox::Config qw(glob2re);
 use PublicInbox::Inbox;
-use PublicInbox::Git qw(read_all);
 use PublicInbox::LeiCurl;
 use PublicInbox::OnDestroy;
 use PublicInbox::SHA qw(sha256_hex sha_all);
@@ -174,7 +173,7 @@ sub _get_txt_done { # returns true on error (non-fatal), undef on success
        return warn("# @$cmd failed (non-fatal)\n") if $cerr;
        seek($fh, 0, SEEK_SET);
        $self->{"mtime.$endpoint"} = (stat($fh))[9];
-       $self->{"txt.$endpoint"} = read_all($fh, -s _);
+       $self->{"txt.$endpoint"} = PublicInbox::IO::read_all $fh, -s _;
        undef; # success
 }
 
@@ -207,7 +206,7 @@ sub _write_inbox_config {
 sub set_description ($) {
        my ($self) = @_;
        my $dst = $self->{cur_dst} // $self->{dst};
-       chomp(my $orig = PublicInbox::Git::try_cat("$dst/description"));
+       chomp(my $orig = PublicInbox::IO::try_cat("$dst/description"));
        my $d = $orig;
        while (defined($d) && ($d =~ m!^\(\$INBOX_DIR/description missing\)! ||
                        $d =~ /^Unnamed repository/ || $d !~ /\S/)) {
@@ -806,7 +805,7 @@ sub update_ent {
        }
        if (defined(my $t = $self->{-ent}->{modified})) {
                my ($dn, $bn) = ("$dst/info/web", 'last-modified');
-               my $orig = PublicInbox::Git::try_cat("$dn/$bn");
+               my $orig = PublicInbox::IO::try_cat("$dn/$bn");
                $t = strftime('%F %T', gmtime($t))." +0000\n";
                File::Path::mkpath($dn);
                atomic_write($dn, $bn, $t) if $orig ne $t;
@@ -936,7 +935,7 @@ failed to extract epoch number from $src
 sub decode_manifest ($$$) {
        my ($fh, $fn, $uri) = @_;
        my $js;
-       my $gz = read_all($fh);
+       my $gz = PublicInbox::IO::read_all $fh;
        gunzip(\$gz => \$js, MultiStream => 1) or
                die "gunzip($uri): $GunzipError\n";
        my $m = eval { PublicInbox::Config->json->decode($js) };
@@ -1083,7 +1082,7 @@ sub dump_manifest ($$) {
 sub dump_project_list ($$) {
        my ($self, $m) = @_;
        my $f = $self->{'-project-list'};
-       my $old = defined($f) ? PublicInbox::Git::try_cat($f) : '';
+       my $old = defined($f) ? PublicInbox::IO::try_cat($f) : '';
        my %new;
 
        open my $dh, '<', '.';
index 82aea8d4c4037c3f2ab90e008e5c90299706f7b2..ddb3faf7d7863935d25fea272d7fe43edabdd308 100644 (file)
@@ -12,7 +12,7 @@ use Config;
 use POSIX ();
 use PublicInbox::Config;
 use PublicInbox::IPC;
-use PublicInbox::Git qw(read_all);
+use PublicInbox::IO qw(read_all);
 
 sub lei_sucks {
        my ($lei, @argv) = @_;
index 1e8eb47a5626a235fc23a3f16f3c5e6adbe70c22..b769180600ac5d46207bbc6acfaa3fd25fc0c7f4 100644 (file)
@@ -9,7 +9,7 @@ use PublicInbox::Spawn qw(run_die run_qx);
 use PublicInbox::Import;
 use File::Temp 0.19;
 use List::Util qw(max);
-use PublicInbox::Git qw(read_all);
+use PublicInbox::IO qw(read_all);
 use autodie qw(chmod close rename);
 
 sub new {
index 5ad12942f74848b6afca7a50d4f41a859fbe84c4..83e99b42ba601ee5eb5ffb2f29e3b2a25e787428 100644 (file)
@@ -48,8 +48,8 @@ sub require_bsd (;$) {
 sub xbail (@) { BAIL_OUT join(' ', map { ref() ? (explain($_)) : ($_) } @_) }
 
 sub read_all ($;$$) {
-       require PublicInbox::Git;
-       PublicInbox::Git::read_all($_[0], $_[1], $_[2])
+       require PublicInbox::IO;
+       PublicInbox::IO::read_all($_[0], $_[1], $_[2])
 }
 
 sub eml_load ($) {
index 6c588ddfb603d9d25ad463f2fcf285ed531889d8..be062f36a7a7adc3c58df1f4453bcb61122fbf7f 100644 (file)
@@ -17,7 +17,7 @@ use strict;
 use v5.10.1;
 use File::Temp 0.19 (); # newdir
 use PublicInbox::SolverGit;
-use PublicInbox::Git qw(read_all);
+use PublicInbox::Git;
 use PublicInbox::GitAsyncCat;
 use PublicInbox::WwwStream qw(html_oneshot);
 use PublicInbox::Linkify;
@@ -62,7 +62,7 @@ sub dbg_log ($) {
                warn "seek(log): $!";
                return '<pre>debug log seek error</pre>';
        }
-       $log = eval { read_all($log) } // do {
+       $log = eval { PublicInbox::IO::read_all $log } // do {
                warn "read(log): $@";
                return '<pre>debug log read error</pre>';
        };
@@ -248,7 +248,7 @@ EOM
        if (-s $fh > $MAX_SIZE) {
                print $zfh "---\n patch is too large to show\n";
        } else { # prepare flush_diff:
-               read_all($fh, -s _, \$x);
+               PublicInbox::IO::read_all $fh, -s _, \$x;
                utf8_maybe($x);
                $ctx->{-apfx} = $ctx->{-spfx} = $upfx;
                $x =~ s/\r?\n/\n/gs;
index 183c5df71918af220b432410ef9c7c74ac64a84e..d2bd68ea03f98705b3cef2c862c204725fd0c65a 100644 (file)
@@ -588,7 +588,7 @@ sub stylesheets_prepare ($$) {
                                next;
                        };
                        my $ctime = 0;
-                       my $local = PublicInbox::Git::read_all($fh, -s $fh);
+                       my $local = PublicInbox::IO::read_all $fh; # sets _
                        if ($local =~ /\S/) {
                                $ctime = sprintf('%x',(stat(_))[10]);
                                $local = $mini->($local);
index 41c66a121b49097ae83ea0a1e211094692bf2f8d..1ee918e3f7f5bafcb8e5609c30d861293b0dd6fc 100644 (file)
@@ -10,7 +10,7 @@ $GLP->configure(qw(require_order bundling no_ignore_case no_auto_abbrev));
 use PublicInbox::Search qw(xap_terms);
 use PublicInbox::CodeSearch;
 use PublicInbox::IPC;
-use PublicInbox::Git qw(read_all);
+use PublicInbox::IO qw(read_all);
 use Socket qw(SOL_SOCKET SO_TYPE SOCK_SEQPACKET AF_UNIX);
 use PublicInbox::DS qw(awaitpid);
 use autodie qw(open getsockopt);
@@ -125,9 +125,8 @@ sub cmd_dump_roots {
        $req->{A} or return warn('dump_roots requires -A PREFIX');
        open my $fh, '<', $root2id_file;
        my $root2id; # record format: $OIDHEX "\0" uint32_t
-       my @x = split(/\0/, read_all($fh));
-       while (@x) {
-               my $oidhex = shift @x;
+       my @x = split(/\0/, read_all $fh);
+       while (defined(my $oidhex = shift @x)) {
                $root2id->{$oidhex} = shift @x;
        }
        my $opt = { relevance => -1, limit => $req->{'m'},
index 835030350c233f6a7f0b3b1d00fd5befae540d42..908a71f4b5a57372febed4c37b1d2052cac715a8 100644 (file)
@@ -8,7 +8,6 @@
 package PublicInbox::XapHelperCxx;
 use v5.12;
 use PublicInbox::Spawn qw(run_qx which);
-use PublicInbox::Git qw(read_all);
 use PublicInbox::Search;
 use Fcntl qw(SEEK_SET);
 use Config;
@@ -67,7 +66,7 @@ sub build () {
        for (@srcs) {
                say $fh qq(# line 1 "$_");
                open my $rfh, '<', $_;
-               print $fh read_all($rfh);
+               print $fh PublicInbox::IO::read_all $rfh;
        }
        print $fh PublicInbox::Search::generate_cxx();
        print $fh PublicInbox::CodeSearch::generate_cxx();
index d8186809d165688fee563591ce8be1ed05ba3db2..713c288159787d73225e2402167185ae1dd7849e 100755 (executable)
@@ -131,7 +131,7 @@ while (<$rd>) {
                $state = 'commit';
        } elsif (/^data ([0-9]+)/) {
                print $io $_ or $im->wfail;
-               print $io PublicInbox::Git::read_all($rd, $1) or $im->wfail;
+               print $io PublicInbox::IO::read_all($rd, $1) or $im->wfail;
                next;
        } elsif ($state eq 'commit') {
                if (m{^M 100644 :([0-9]+) (${h}{2}/${h}{38})}o) {
index 7702881769d572cfa133ea671b6905711b801022..88115d7cc7757cfea89908a63691089cf31d7219 100755 (executable)
@@ -15,7 +15,6 @@ PublicInbox::Admin::check_require('-index');
 use PublicInbox::Eml;
 use PublicInbox::InboxWritable qw(eml_from_path);
 use PublicInbox::Import;
-use PublicInbox::Git qw(read_all);
 
 my $help = <<'EOF';
 usage: public-inbox-edit -m MESSAGE-ID [--all] [INBOX_DIRS]
@@ -185,7 +184,7 @@ retry_edit:
        # rename/relink $edit_fn
        open my $new_fh, '<', $edit_fn or
                die "can't read edited file ($edit_fn): $!\n";
-       my $new_raw = read_all($new_fh);
+       my $new_raw = PublicInbox::IO::read_all $new_fh;
 
        if (!$opt->{raw}) {
                PublicInbox::Eml::strip_from($new_raw);
index 6420db7e202022a20d0e1592aa431d8c919dd59d..8915cf31914ec75955f41a953bfb2c0979e15982 100755 (executable)
@@ -126,12 +126,12 @@ my $auto_unlink = PublicInbox::OnDestroy->new($$, sub { unlink $lockfile });
 my $perm = 0644 & ~umask;
 my %seen;
 if (-e $pi_config) {
-       require PublicInbox::Git;
+       require PublicInbox::IO;
        open(my $oh, '<', $pi_config);
        my @st = stat($oh) or die "(f)stat failed on $pi_config: $!\n";
        $perm = $st[2];
        chmod($perm & 07777, $fh);
-       print $fh PublicInbox::Git::read_all($oh);
+       print $fh PublicInbox::IO::read_all($oh);
        close $oh;
 
        # yes, this conflict checking is racy if multiple instances of this
index 091835188d2ae0e3ecb5cf308b52cb08f0dce35f..2033945e3fa84360c068ac92c0a9097824e9f78b 100644 (file)
@@ -46,7 +46,7 @@ ok(run_script([qw(-cindex --dangerous -q), "$tmp/wt0"]), 'cindex internal');
 # (see c4201214cbf10636e2c1ab9131573f735b42c8d4 in linux.git)
 my $zp = create_coderepo 'NUL in patch', sub {
        require PublicInbox::Git;
-       my $src = PublicInbox::Git::try_cat("$pwd/COPYING");
+       my $src = PublicInbox::IO::try_cat("$pwd/COPYING");
        xsys_e([qw(git init -q)]);
 
        # needs to be further than FIRST_FEW_BYTES (8000) in git.git
index bce4ecd9fe3130a5f520140c2e5e0875fe5b91b8..0e6b4ac73ad9bf01072a32cc4f5e52aa8dad0827 100644 (file)
@@ -95,7 +95,7 @@ is(xqx([qw(git config gitweb.owner)], { GIT_DIR => "$tmpdir/dst/a.git" }),
        "\xc4\x80lice\n", 'a.git gitweb.owner set');
 is(xqx([qw(git config gitweb.owner)], { GIT_DIR => "$tmpdir/dst/b.git" }),
        "Bob\n", 'b.git gitweb.owner set');
-my $desc = PublicInbox::Git::try_cat("$tmpdir/dst/a.git/description");
+my $desc = PublicInbox::IO::try_cat("$tmpdir/dst/a.git/description");
 is($desc, "\xc4\x80lice's repo\n", 'description set');
 
 my $dst_pl = "$tmpdir/dst/projects.list";
@@ -104,7 +104,7 @@ ok(!-d "$tmpdir/dst/objstore", 'no objstore created w/o forkgroups');
 my $r = $read_manifest->($dst_mf);
 is_deeply($r, $m, 'manifest matches');
 
-is(PublicInbox::Git::try_cat($dst_pl), "a.git\nb.git\n",
+is(PublicInbox::IO::try_cat($dst_pl), "a.git\nb.git\n",
        'wrote projects.list');
 
 { # check symlinks
@@ -113,7 +113,7 @@ is(PublicInbox::Git::try_cat($dst_pl), "a.git\nb.git\n",
        utime($t0, $t0, $dst_mf) or xbail "utime: $!";
        ok(run_script($cmd), 'clone again +symlinks');
        ok(-l "$tmpdir/dst/old/a.git", 'symlink created');
-       is(PublicInbox::Git::try_cat($dst_pl), "a.git\nb.git\n",
+       is(PublicInbox::IO::try_cat($dst_pl), "a.git\nb.git\n",
                'projects.list does not include symlink by default');
 
        $r = $read_manifest->($dst_mf);
@@ -127,7 +127,7 @@ is(PublicInbox::Git::try_cat($dst_pl), "a.git\nb.git\n",
        utime($t0, $t0, $dst_mf) or xbail "utime: $!";
        my $rdr = { 2 => \(my $err = '') };
        ok(run_script($cmd, undef, $rdr), 'clone again for expired gone.git');
-       is(PublicInbox::Git::try_cat($dst_pl), "a.git\nb.git\n",
+       is(PublicInbox::IO::try_cat($dst_pl), "a.git\nb.git\n",
                'project list cleaned');
        like($err, qr/no longer exist.*\bgone\.git\b/s, 'gone.git noted');
 }
@@ -146,7 +146,7 @@ is(PublicInbox::Git::try_cat($dst_pl), "a.git\nb.git\n",
        my $rdr = { 2 => \(my $err = '') };
        my $xcmd = [ @$cmd, '--purge' ];
        ok(run_script($xcmd, undef, $rdr), 'clone again for expired gone.git');
-       is(PublicInbox::Git::try_cat($dst_pl), "a.git\nb.git\n",
+       is(PublicInbox::IO::try_cat($dst_pl), "a.git\nb.git\n",
                'project list cleaned');
        like($err, qr!ignored/gone.*?\bgone-rdonly\.git\b!s,
                'gone-rdonly.git noted');
index 3d2c7873c43e7a26c1893b5f415944988ed091a2..275192cfefcde079ddabed62ff7e8c07652942a0 100644 (file)
--- a/t/init.t
+++ b/t/init.t
@@ -107,7 +107,7 @@ sub quiet_fail {
        umask($umask) // xbail "umask: $!";
        ok(-d "$tmpdir/a/b/c/d", 'directory created');
        my $desc = "$tmpdir/a/b/c/d/description";
-       is(PublicInbox::Git::try_cat($desc),
+       is(PublicInbox::IO::try_cat($desc),
                "public inbox for abcd\@example.com\n", 'description set');
        my $mode = (stat($desc))[2];
        is(sprintf('0%03o', $mode & 0777), '0644',
index 0896149135b977df2a75d73b24f8a3a0482a5a68..37c9751ba2a3736daad13f73357d83920809b672 100644 (file)
@@ -23,7 +23,7 @@ test_lei({ tmpdir => $tmpdir }, sub {
        lei_ok('add-external', $t1, '--mirror', "$http/t1/", \'--mirror v1');
        my $mm_dup = "$t1/public-inbox/msgmap.sqlite3";
        ok(-f $mm_dup, 't1-mirror indexed');
-       is(PublicInbox::Git::try_cat("$t1/description"),
+       is(PublicInbox::IO::try_cat("$t1/description"),
                "mirror of $http/t1/\n", 'description set');
        ok(-f "$t1/Makefile", 'convenience Makefile added (v1)');
        SKIP: {
@@ -51,7 +51,7 @@ test_lei({ tmpdir => $tmpdir }, sub {
        ok(-f $mm_dup, 't2-mirror indexed');
        ok(-f "$t2/description", 't2 description');
        ok(-f "$t2/Makefile", 'convenience Makefile added (v2)');
-       is(PublicInbox::Git::try_cat("$t2/description"),
+       is(PublicInbox::IO::try_cat("$t2/description"),
                "mirror of $http/t2/\n", 'description set');
        $tb = PublicInbox::Msgmap->new_file($mm_dup)->created_at;
        is($tb, $created{v2}, 'created_at matched in v2 mirror');
@@ -207,14 +207,14 @@ $td->join;
        my $exp = "mirror of https://example.com/src/\n";
        my $f = "$tmpdir/description";
        PublicInbox::LeiMirror::set_description($mrr);
-       is(PublicInbox::Git::try_cat($f), $exp, 'description set on ENOENT');
+       is(PublicInbox::IO::try_cat($f), $exp, 'description set on ENOENT');
 
        my $fh;
        (open($fh, '>', $f) and close($fh)) or xbail $!;
        PublicInbox::LeiMirror::set_description($mrr);
-       is(PublicInbox::Git::try_cat($f), $exp, 'description set on empty');
+       is(PublicInbox::IO::try_cat($f), $exp, 'description set on empty');
        (open($fh, '>', $f) and print $fh "x\n" and close($fh)) or xbail $!;
-       is(PublicInbox::Git::try_cat($f), "x\n",
+       is(PublicInbox::IO::try_cat($f), "x\n",
                'description preserved if non-default');
 }