]> git.ipfire.org Git - thirdparty/public-inbox.git/commitdiff
cindex: quiet --prune when checking objectFormat
authorEric Wong <e@80x24.org>
Wed, 25 Oct 2023 15:33:48 +0000 (15:33 +0000)
committerEric Wong <e@80x24.org>
Wed, 25 Oct 2023 20:32:02 +0000 (20:32 +0000)
Most coderepos don't have extensions.objectFormat set,
so it's senseless to emit warnings on failures.

Fixes: 709fcf00c4d5 (cindex: use run_await to read extensions.objectFormat)
lib/PublicInbox/CodeSearchIdx.pm
t/cindex.t

index f2fd28e390586423cc11865e6be9ee6f983d9420..80636270b81f89d1a8d75d3759f538f191f5e44f 100644 (file)
@@ -858,7 +858,8 @@ sub prep_alternate_start {
        }
        my $cmd = [ 'git', "--git-dir=$git_dir",
                        qw(config extensions.objectFormat) ];
-       run_await($cmd, undef, undef, \&prep_alternate_end, $o, $run_prune);
+       my $opt = { quiet => 1 };
+       run_await($cmd, undef, $opt, \&prep_alternate_end, $o, $run_prune);
 }
 
 sub cmd_done { # run_await cb for sort, xapian-delve, sed failures
index c7de150541d9ca8234208a735b515ee5d8bf95f5..091835188d2ae0e3ecb5cf308b52cb08f0dce35f 100644 (file)
@@ -13,6 +13,7 @@ my ($tmp, $for_destroy) = tmpdir();
 my $pwd = getcwd();
 my @unused_keys = qw(last_commit has_threadid skip_docdata);
 local $ENV{PI_CONFIG} = '/dev/null';
+my $opt = { 1 => \(my $cidx_out), 2 => \(my $cidx_err) };
 
 # I reworked CodeSearchIdx->shard_worker to handle empty trees
 # in the initial commit generated by cvs2svn for xapian.git
@@ -166,7 +167,9 @@ SKIP: { # --prune
        is(scalar($csrch->mset('s:hi')->items), 1, 'got hit');
 
        rename("$tmp/wt0/.git", "$tmp/wt0/.giit");
-       ok(run_script([qw(-cindex -q --prune -d), "$tmp/ext"]), 'prune');
+       ok(run_script([qw(-cindex -q --prune -d), "$tmp/ext"], undef, $opt),
+               'prune');
+       is(${$opt->{2}}, '', 'nothing in stderr') or diag explain($opt);
        $csrch->reopen;
        is(scalar($csrch->mset('s:hi')->items), 0, 'hit pruned');
 
@@ -213,7 +216,7 @@ EOM
        close $fh;
        my $cmd = [ qw(-cindex -u --all --associate -d), "$tmp/ext",
                '-I', $basic->{inboxdir} ];
-       my $opt = { 1 => \(my $cidx_out), 2 => \(my $cidx_err) };
+       $cidx_out = $cidx_err = '';
        ok(run_script($cmd, $env, $opt), 'associate w/o search');
        like($cidx_err, qr/W: \Q$basic->{inboxdir}\E not indexed for search/,
                'non-Xapian-enabled inbox noted');