]> Sergey Matveev's repositories - public-inbox.git/commitdiff
search: index_sync allows specifying alternate HEAD
authorEric Wong <e@80x24.org>
Tue, 18 Aug 2015 06:23:06 +0000 (06:23 +0000)
committerEric Wong <e@80x24.org>
Thu, 20 Aug 2015 04:00:11 +0000 (04:00 +0000)
This should allow us to sync the index to a temporary head
to update the Xapian index before we update the real HEAD
index.

lib/PublicInbox/Search.pm

index abd9db4c4289345200079845a888a94993b42fba..d9e5fd1f13820575dca626c948e54585a92de682 100644 (file)
@@ -541,20 +541,21 @@ sub enquire {
 
 # indexes all unindexed messages
 sub index_sync {
-       my ($self) = @_;
+       my ($self, $head) = @_;
        require PublicInbox::GitCatFile;
        my $db = $self->{xdb};
        my $hex = '[a-f0-9]';
        my $h40 = $hex .'{40}';
        my $addmsg = qr!^:000000 100644 \S+ ($h40) A\t${hex}{2}/${hex}{38}$!;
        my $delmsg = qr!^:100644 000000 ($h40) \S+ D\t${hex}{2}/${hex}{38}$!;
+       $head ||= 'HEAD';
 
        $db->begin_transaction;
        eval {
                my $git = PublicInbox::GitCatFile->new($self->{git_dir});
 
                my $latest = $db->get_metadata('last_commit');
-               my $range = length $latest ? "$latest..HEAD" : 'HEAD';
+               my $range = length $latest ? "$latest..$head" : $head;
                $latest = undef;
 
                # get indexed messages