- my $regen_max = 0;
- # can't use 'rev-list --count' if we use --diff-filter
- my $fh = $git->popen(qw(log --pretty=tformat:%h
- --no-notes --no-color --no-renames
- --diff-filter=AM), $range);
- ++$regen_max while <$fh>;
- my (undef, $max) = $self->{mm}->minmax;
-
- if ($max && $max == $regen_max) {
+ # don't show annoying git errrors to users who run -index
+ # on empty inboxes
+ $git->qx(qw(rev-parse -q --verify), "$range^0");
+ if ($?) {
+ open my $fh, '<', '/dev/null' or
+ die "failed to open /dev/null: $!\n";
+ return $fh;
+ }
+ }
+
+ # Count the new files so they can be added newest to oldest
+ # and still have numbers increasing from oldest to newest
+ my $fcount = 0;
+ # can't use 'rev-list --count' if we use --diff-filter
+ my $fh = $git->popen(qw(log --pretty=tformat:%h
+ --no-notes --no-color --no-renames
+ --diff-filter=AM), $range);
+ ++$fcount while <$fh>;
+ my $high = $self->{mm}->num_highwater;
+
+ if (index($range, '..') < 0) {
+ if ($high && $high == $fcount) {