+sub max_git_epoch {
+ my ($self) = @_;
+ my $v = $self->{version};
+ return unless defined($v) && $v == 2;
+ my $cur = $self->{-max_git_epoch};
+ my $changed = git($self)->alternates_changed;
+ if (!defined($cur) || $changed) {
+ $self->git->cleanup if $changed;
+ my $gits = "$self->{inboxdir}/git";
+ if (opendir my $dh, $gits) {
+ my $max = -1;
+ while (defined(my $git_dir = readdir($dh))) {
+ $git_dir =~ m!\A([0-9]+)\.git\z! or next;
+ $max = $1 if $1 > $max;
+ }
+ $cur = $self->{-max_git_epoch} = $max if $max >= 0;
+ } else {
+ warn "opendir $gits failed: $!\n";
+ }
+ }
+ $cur;
+}
+