about summary refs log tree commit homepage
path: root/lib/PublicInbox
diff options
context:
space:
mode:
authorEric Wong <e@80x24.org>2023-11-13 13:15:43 +0000
committerEric Wong <e@80x24.org>2023-11-13 21:55:03 +0000
commit36a7d8d92fb0e7474095c927de1d2d3f5f0292a5 (patch)
tree90fd7ee2c8c33ba663253d76ef057b4438cd4e55 /lib/PublicInbox
parentda87331b60ec182e939081eb16effa2b9aa8be3c (diff)
downloadpublic-inbox-36a7d8d92fb0e7474095c927de1d2d3f5f0292a5.tar.gz
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.
Diffstat (limited to 'lib/PublicInbox')
-rw-r--r--lib/PublicInbox/CodeSearchIdx.pm26
1 files changed, 21 insertions, 5 deletions
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 <<EOM unless $self->{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