- my @cmd = qw(log --reverse --raw -r --pretty=tformat:%H.%at.%ct
- --no-notes --no-color --no-abbrev --no-renames);
- my $fh = $self->{reindex_pipe} = $git->popen(@cmd, $range);
- my $cmt;
- my $D = $sync->{D};
- while (<$fh>) {
- chomp;
- $self->{current_info} = "$i.git $_";
- if (/\A($x40)\.([0-9]+)\.([0-9]+)$/o) {
- $cmt = $1;
- $self->{autime} = $2;
- $self->{cotime} = $3;
- } elsif (/\A:\d{6} 100644 $x40 ($x40) [AM]\tm$/o) {
- reindex_oid($self, $sync, $git, $1);
- } elsif (/\A:\d{6} 100644 $x40 ($x40) [AM]\td$/o) {
- # allow re-add if there was user error
- my $oid = $1;
- if ($D) {
- my $oid_bin = pack('H*', $oid);
- my $nr = --$D->{$oid_bin};
- delete($D->{$oid_bin}) if $nr <= 0;
+ for (my $num = $beg; $num <= $end; $num += $step) {
+ last if $sync->{quit};
+ my $smsg = $ibx->over->get_art($num) or next;
+ $smsg->{self} = $self;
+ $ibx->git->cat_async($smsg->{blob}, \&index_xap_only, $smsg);
+ if ($self->{transact_bytes} >= $self->{batch_bytes}) {
+ ${$sync->{nr}} = $num;
+ reindex_checkpoint($self, $sync);
+ }
+ }
+}
+
+sub index_todo ($$$) {
+ my ($self, $sync, $unit) = @_;
+ return if $sync->{quit};
+ unindex_todo($self, $sync, $unit);
+ my $stk = delete($unit->{stack}) or return;
+ my $all = $self->git;
+ my $index_oid = $self->can('index_oid');
+ my $unindex_oid = $self->can('unindex_oid');
+ my $pfx;
+ if ($unit->{git}->{git_dir} =~ m!/([^/]+)/git/([0-9]+\.git)\z!) {
+ $pfx = "$1 $2"; # v2
+ } else { # v1
+ ($pfx) = ($unit->{git}->{git_dir} =~ m!/([^/]+)\z!g);
+ $pfx //= $unit->{git}->{git_dir};
+ }
+ local $self->{current_info} = "$pfx ";
+ local $sync->{latest_cmt} = \(my $latest_cmt);
+ local $sync->{unit} = $unit;
+ while (my ($f, $at, $ct, $oid, $cmt) = $stk->pop_rec) {
+ if ($sync->{quit}) {
+ warn "waiting to quit...\n";
+ $all->async_wait_all;
+ $self->update_last_commit($sync);
+ return;
+ }
+ my $req = {
+ %$sync,
+ autime => $at,
+ cotime => $ct,
+ oid => $oid,
+ cur_cmt => $cmt
+ };
+ if ($f eq 'm') {
+ if ($sync->{max_size}) {
+ $all->check_async($oid, \&check_size, $req);
+ } else {
+ $all->cat_async($oid, $index_oid, $req);