]> git.ipfire.org Git - thirdparty/public-inbox.git/commitdiff
cindex: attempt to give oldest commits lowest docids
authorEric Wong <e@80x24.org>
Tue, 21 Mar 2023 23:07:35 +0000 (23:07 +0000)
committerEric Wong <e@80x24.org>
Sat, 25 Mar 2023 09:37:56 +0000 (09:37 +0000)
Monotonically increasing docids may help us avoid sorting output
for the web and CLI, since recent commits are generally the most
desired search results.

`git log --reverse' incurs no extra overhead in this case, since
`--stdin' will mean git buffers the commit list in memory before
attempting to emit anything.

lib/PublicInbox/CodeSearchIdx.pm

index 176422d0d5b2cc69a2ed5b0334256befdf9f6315..f0b506da08cec37456694f27d7c25a43e41fcd24 100644 (file)
@@ -52,8 +52,12 @@ our $SEEN_MAX = 100000;
 
 # TODO: do we care about committer name + email? or tree OID?
 my @FMT = qw(H P ct an ae at s b); # (b)ody must be last
+
+# git log --stdin buffers all commits before emitting, thus --reverse
+# doesn't incur extra overhead.  We use --reverse to keep Xapian docids
+# increasing so we may be able to avoid sorting results in some cases
 my @LOG_STDIN = (qw(log --no-decorate --no-color --no-notes -p --stat -M
-       --stdin --no-walk=unsorted), '--pretty=format:%n%x00'.
+       --reverse --stdin --no-walk=unsorted), '--pretty=format:%n%x00'.
        join('%n', map { "%$_" } @FMT));
 
 sub new {