From 88c732d8af5dde98fbf1af611bf4865b0534093c Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Tue, 18 Aug 2015 06:23:06 +0000 Subject: search: index_sync allows specifying alternate HEAD 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 | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'lib') diff --git a/lib/PublicInbox/Search.pm b/lib/PublicInbox/Search.pm index abd9db4c..d9e5fd1f 100644 --- a/lib/PublicInbox/Search.pm +++ b/lib/PublicInbox/Search.pm @@ -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 -- cgit v1.2.3-24-ge0c7