From 36a7d8d92fb0e7474095c927de1d2d3f5f0292a5 Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Mon, 13 Nov 2023 13:15:43 +0000 Subject: cindex: imply --all with --associate w/o -I/--only I just forgot to use --all with --associate and it wasn't easily apparent what was wrong. We'll also show some extra progress while we're at it. --- lib/PublicInbox/CodeSearchIdx.pm | 26 +++++++++++++++++++++----- 1 file changed, 21 insertions(+), 5 deletions(-) (limited to 'lib/PublicInbox') diff --git a/lib/PublicInbox/CodeSearchIdx.pm b/lib/PublicInbox/CodeSearchIdx.pm index 3601176c..0bd26af2 100644 --- a/lib/PublicInbox/CodeSearchIdx.pm +++ b/lib/PublicInbox/CodeSearchIdx.pm @@ -1033,7 +1033,8 @@ sub init_associate_prefork ($) { $self->{-pi_cfg} = PublicInbox::Config->new; my @unknown; my @pfx = @{$self->{-opt}->{'associate-prefixes'} // [ 'patchid' ]}; - for (map { split(/\s*,\s*/) } @pfx) { + @pfx = map { split(/\s*,\s*/) } @pfx; + for (@pfx) { my $v = $PublicInbox::Search::PATCH_BOOL_COMMON{$_} // push(@unknown, $_); push(@ASSOC_PFX, split(/ /, $v)); @@ -1045,13 +1046,28 @@ EOM my %incl = map { rel2abs_collapsed($_) => undef; } (@{$self->{-opt}->{include} // []}); - $self->{-pi_cfg}->each_inbox(\&_prep_ibx, $self, \%incl); + my $all = $self->{-opt}->{all}; + if (my $only = $self->{-opt}->{only}) { + die <<'' if $all; +E: --all is incompatible with --only + + $incl{rel2abs_collapsed($_)} = undef for @$only; + } + unless (keys(%incl)) { + $all = 1; + warn <{opt}->{quiet}; +# --all implied since no inboxes were specified with --only or --include +EOM + } + $self->{-pi_cfg}->each_inbox(\&_prep_ibx, $self, \%incl, $all); + my $nr = scalar(@IBX) or die "E: no inboxes to associate\n"; + progress($self, "will associate $nr inboxes in ", + $self->{-pi_cfg}->{-f}, " using: @pfx"); } sub _prep_ibx { # each_inbox callback - my ($ibx, $self, $incl) = @_; - ($self->{-opt}->{all} || exists($incl->{$ibx->{inboxdir}})) and - push @IBX, $ibx; + my ($ibx, $self, $incl, $all) = @_; + ($all || exists($incl->{$ibx->{inboxdir}})) and push @IBX, $ibx; } sub show_roots { # for diagnostics -- cgit v1.2.3-24-ge0c7