unofficial mirror of meta@public-inbox.org
 help / color / mirror / Atom feed
* [PATCH] search: index_sync allows specifying alternate HEAD
@ 2015-08-18  6:23 Eric Wong
  0 siblings, 0 replies; only message in thread
From: Eric Wong @ 2015-08-18  6:23 UTC (permalink / raw)
  To: meta

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(-)

diff --git a/lib/PublicInbox/Search.pm b/lib/PublicInbox/Search.pm
index 8395e68..2e12020 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
-- 
EW


^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2015-08-18  6:23 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-08-18  6:23 [PATCH] search: index_sync allows specifying alternate HEAD Eric Wong

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).