about summary refs log tree commit homepage
path: root/lib
diff options
context:
space:
mode:
authorEric Wong <e@80x24.org>2023-12-06 21:12:25 +0000
committerEric Wong <e@80x24.org>2023-12-06 23:48:27 +0000
commit5f99c1620f44bd06679009f462364186c139cdec (patch)
treeed949873494d2926f88ce66e4dd2fe09ca9a6713 /lib
parent499ceaa18ac3fe5135f683938cb471df96e22c8b (diff)
downloadpublic-inbox-5f99c1620f44bd06679009f462364186c139cdec.tar.gz
There's no need to recurse and trigger deep recursion warnings
when we hit a coderepo with a known hash (SHA-1 vs SHA-256).
Noticed while pruning the 1200+ repos on a git.kernel.org
mirror.
Diffstat (limited to 'lib')
-rw-r--r--lib/PublicInbox/CodeSearchIdx.pm16
1 files changed, 9 insertions, 7 deletions
diff --git a/lib/PublicInbox/CodeSearchIdx.pm b/lib/PublicInbox/CodeSearchIdx.pm
index 20aac584..967933f2 100644
--- a/lib/PublicInbox/CodeSearchIdx.pm
+++ b/lib/PublicInbox/CodeSearchIdx.pm
@@ -909,21 +909,23 @@ sub prep_alternate_read { # run_git cb for config extensions.objectFormat
 
 sub prep_alternate_start {
         my ($self, $git, $run_prune) = @_;
-        my $o = $git->git_path('objects');
+        local $self->{xdb};
+        my ($o, $n, @ids, @fmt);
+start:
+        $o = $git->git_path('objects');
         while (!-d $o) {
                 $git = shift(@PRUNEQ) // return;
                 $o = $git->git_path('objects');
         }
-        my $n = git_dir_hash($git->{git_dir}) % scalar(@RDONLY_XDB);
-        local $self->{xdb} = $RDONLY_XDB[$n] // croak("BUG: no shard[$n]");
-        my @ids = $self->docids_by_postlist('P'.$git->{git_dir});
-        my @fmt = @ids ? xap_terms('H', $self->{xdb}, $ids[0]) : ();
+        $n = git_dir_hash($git->{git_dir}) % scalar(@RDONLY_XDB);
+        $self->{xdb} = $RDONLY_XDB[$n] // croak("BUG: no shard[$n]");
+        @ids = $self->docids_by_postlist('P'.$git->{git_dir});
+        @fmt = @ids ? xap_terms('H', $self->{xdb}, $ids[0]) : ();
         @fmt > 1 and warn "BUG? multi `H' for shard[$n] #$ids[0]: @fmt";
 
         if (@fmt) { # cache hit
-                @PRUNEQ and
-                        prep_alternate_start($self, shift(@PRUNEQ), $run_prune);
                 prep_alternate_end $o, $fmt[0];
+                $git = shift(@PRUNEQ) and goto start;
         } else { # compatibility w/ early cidx format
                 run_git([qw(config extensions.objectFormat)], { quiet => 1 },
                         \&prep_alternate_read, $self, $git, $o, $ids[0], $n,