- unless ($ENV{FAST}) {
- local $ENV{GIT_INDEX_FILE} = $index;
- system('git', "--git-dir=$git_dir", qw(read-tree -m -v -i),
- $self->{ref}) == 0 or
- die "failed to update $git_dir/ssoma.index: $?\n";
+ my @cmd = ('git', "--git-dir=$git_dir");
+ if ($nchg && !$ENV{FAST}) {
+ my $index = "$git_dir/ssoma.index";
+ my $env = { GIT_INDEX_FILE => $index };
+ run_die([@cmd, qw(read-tree -m -v -i), $self->{ref}], $env);
+ }
+ if ($nchg) {
+ run_die([@cmd, 'update-server-info'], undef);
+ eval {
+ require PublicInbox::SearchIdx;
+ my $inbox = $self->{inbox} || $git_dir;
+ my $s = PublicInbox::SearchIdx->new($inbox);
+ $s->index_sync({ ref => $self->{ref} });
+ };
+
+ eval { run_die([@cmd, qw(gc --auto)], undef) };