- do {
- if ($xlog) {
- close($xlog) or die "git log failed: \$?=$?";
- $xlog = undef;
- }
- $last_commit = _last_x_commit($self, $mm);
- $lx = reindex_from($opts->{reindex}, $last_commit);
-
- $self->{over}->rollback_lazy;
- $self->{over}->disconnect;
- $git->cleanup;
- delete $self->{txn};
- $xdb->cancel_transaction if $xdb;
- $xdb = _xdb_release($self);
-
- # ensure we leak no FDs to "git log" with Xapian <= 1.2
- my $range = $lx eq '' ? $tip : "$lx..$tip";
- $xlog = _git_log($self, $opts, $range);
-
- $xdb = $self->begin_txn_lazy;
- } while (_last_x_commit($self, $mm) ne $last_commit);
-
- my $dbh = $mm->{dbh} if $mm;
- my $cb = sub {
- my ($nr, $commit, $newest) = @_;
- if ($dbh) {
- if ($newest) {
- my $cur = $mm->last_commit || '';
- if (need_update($self, $cur, $newest)) {
- $mm->last_commit($newest);
- }
- }
- $dbh->commit;
- }
- if ($newest && need_xapian($self)) {
- my $cur = $xdb->get_metadata('last_commit');
- if (need_update($self, $cur, $newest)) {
- $xdb->set_metadata('last_commit', $newest);
- }
- }
- $self->commit_txn_lazy;
- $git->cleanup;
- $xdb = _xdb_release($self);
- # let another process do some work... <
- $pr->("indexed $nr/$self->{ntodo}\n") if $pr && $nr;
- if (!$newest) {
- $xdb = $self->begin_txn_lazy;
- $dbh->begin_work if $dbh;
+ if ($sync->{reindex}) {
+ my $last = $mm->last_commit;
+ if ($last) {
+ $tip = $last;
+ } else {
+ # somebody just blindly added --reindex when indexing
+ # for the first time, allow it:
+ undef $sync->{reindex};