+ if (!$regen) {
+ my (undef, $max) = $mm_tmp->minmax;
+ unless (defined $max) {
+ $regen = 1;
+ warn
+"empty msgmap.sqlite3, regenerating article numbers\n";
+ }
+ }
+ my $tip; # latest commit out of all git repos
+ if ($regen) {
+ my $regen_max = 0;
+ for (my $cur = $max_git; $cur >= 0; $cur--) {
+ die "already reindexing!\n" if $self->{reindex_pipe};
+ my $git = PublicInbox::Git->new("$pfx/$cur.git");
+ chomp($tip = $git->qx('rev-parse', $head)) unless $tip;
+ my $h = $cur == $max_git ? $tip : $head;
+ my @count = ('rev-list', '--count', $h, '--', 'm');
+ $regen_max += $git->qx(@count);
+ }
+ die "No messages found in $pfx/*.git, bug?\n" unless $regen_max;
+ $regen = \$regen_max;
+ }