]> git.ipfire.org Git - thirdparty/public-inbox.git/commitdiff
cindex: --prune + --exclude= drops repo information
authorEric Wong <e@80x24.org>
Wed, 3 May 2023 11:42:15 +0000 (11:42 +0000)
committerEric Wong <e@80x24.org>
Thu, 4 May 2023 10:57:11 +0000 (10:57 +0000)
--exclude= alone only prevents a coderepo from being indexed in
a particular invocation, but --prune will purge all traces of it
to ensure --update doesn't pick it up again w/o --exclude=
(unless --project-list= includes it).

lib/PublicInbox/CodeSearchIdx.pm

index 671134bf6ee7111ed5b8c89ecb1e21479a23c722..d92d87fc46d9ae35b7b9eb40a4137c39780e874e 100644 (file)
@@ -648,9 +648,7 @@ sub prune_do { # via wq_io_do in IDX_SHARDS
        local $/ = "\0";
        while (my $p = <$gone>) { # Q$cmt or P$git_dir
                chomp $p;
-               my @docids = docids_by_postlist($self, $p) or warn <<EOM;
-W: no docids for `$p' [$self->{shard}]
-EOM
+               my @docids = docids_by_postlist($self, $p);
                for (@docids) {
                        $TXN_BYTES -= $xdb->get_doclength($_) * 42;
                        $xdb->delete_document($_);
@@ -914,9 +912,13 @@ sub cidx_run { # main entry point
                my $re = '(?:'.join('\\z|', map {
                                glob2re($_) // qr/\A\Q$_\E/
                        } @$excl).'\\z)';
+               my @excl;
                @{$self->{git_dirs}} = grep {
-                       $_ =~ /$re/ ? (warn("# excluding $_\n"), 0) : 1;
+                       $_ =~ /$re/ ? (push(@excl, $_), 0) : 1;
                } @{$self->{git_dirs}};
+               warn("# excluding $_\n") for @excl;
+               my %uniq; # List::Util::uniq requires Perl 5.26+
+               @GIT_DIR_GONE = grep { !$uniq{$_}++ } (@GIT_DIR_GONE, @excl);
        }
        local $NCHANGE = 0;
        local $LIVE_JOBS = $self->{-opt}->{jobs} ||