- } else {
- PublicInbox::Import::init_bare($ALL) unless $old;
- }
- my $info_dir = "$ALL/objects/info";
- my $alt = "$info_dir/alternates";
- my (@old, @new, %seen); # seen: st_dev + st_ino
- if (-e $alt) {
- open(my $fh, '<', $alt) or die "open $alt: $!";
- $mode = (stat($fh))[2] & 07777;
- while (my $line = <$fh>) {
- chomp(my $d = $line);
-
- # expand relative path (/local/ stuff)
- substr($d, 0, 3) eq '../' and
- $d = "$ALL/objects/$d";
- if (my @st = stat($d)) {
- next if $seen{"$st[0]\0$st[1]"}++;
- } else {
- warn "W: stat($d) failed (from $alt): $!\n";
- next if $opt->{-idx_gc};
- }
- push @old, $line;
- }
+ ($alt, $seen) = $self->{mg}->read_alternates(\$mode);
+ $has_new = $self->{mg}->merge_epochs($alt, $seen);
+ } else { # extindex has no epochs
+ $self->{mg} //= PublicInbox::MultiGit->new($self->{topdir},
+ 'ALL.git');
+ ($alt, $seen) = $self->{mg}->read_alternates(\$mode,
+ $opt->{-idx_gc});
+ PublicInbox::Import::init_bare($ALL);