[PATCH v4 0/2] revision.c: implement --reverse=before for walks
- From
Mirko Faina <mroik@delayed.space>
- Date
- Apr 27, 2026, 00:24 UTC
- Message-ID
- <cover.1777249165.git.mroik@delayed.space>
- In-Reply-To
- <cover.1776984666.git.mroik@delayed.space>
v4 aligns the behaviour for --reverse=before and --reverse=after on negative numbers that are less than -1 to treat them the same as -1, which is current behaviour (before this series).
[1/2] revision.c: implement --reverse=before for walks (Mirko Faina) [2/2] revision.c: reduce memory usage on reverse before (Mirko Faina)
Documentation/rev-list-options.adoc | 16 +++++-- revision.c | 73 +++++++++++++++++++++++++++-- revision.h | 8 +++- t/t4202-log.sh | 66 ++++++++++++++++++++++++++ 4 files changed, 153 insertions(+), 10 deletions(-)
Range-diff against v3:
1: 4864ac46dd = 1: 4864ac46dd revision.c: implement --reverse=before for walks
2: 00489b0e52 ! 2: 7c0bab5d14 revision.c: reduce memory usage on reverse before
@@ Commit message
revision with --reverse=before and --max-count=<k>. We do this through a
simple queue. With N nodes and K as the --max-count argument, assuming K
< N, we go from a space complexity of O(N) to O(K). When it comes down
- to time complexity, the queue has an ammortized time of O(1) for pops,
- so the complexity remains O(N).
+ to time complexity, the queue has an amortized time of O(1) for pops, so
+ the complexity remains O(N).
Signed-off-by: Mirko Faina <mroik@delayed.space>
@@ revision.c: struct commit *get_revision(struct rev_info *revs)
reversed = NULL;
- while ((c = get_revision_internal(revs)))
- commit_list_insert(c, &reversed);
-+ if (revs->reverse == REVERSE_BEFORE && max_count != -1) {
++ if (revs->reverse == REVERSE_BEFORE && max_count >= 0) {
+ retrieve_with_window(revs, max_count, &reversed);
+ } else {
+ while ((c = get_revision_internal(revs)))base-commit: e8955061076952cc5eab0300424fc48b601fe12d
-- 2.54.0