From: Mirko Faina Date: Thu, 23 Apr 2026 22:51:58 GMT Subject: [PATCH v3 0/2] revision.c: implement --reverse=before for walks Message-ID: In-Reply-To: <20260422002840.303477-4-mroik@delayed.space> I've fixed the docs with the suggested changes by Jeff and applied some styling fixes. [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 v2: 1: 599a247d82 ! 1: 4864ac46dd revision.c: implement --reverse=before for walks @@ Documentation/rev-list-options.adoc: With `--topo-order`, they would show 8 6 5 + `--walk-reflogs`. If `after`, output the commits chosen to be + shown (see 'Commit Limiting' section above) in reverse order. If + `before`, reverse the commits before filtering with `Commit -+ Limiting` options. This option can be used multiple times, last -+ one is applied. When the argument for `--reverse` is omitted, if -+ the current state is in no reverse, it defaults to `after`. If -+ it is in any reversed state, it restores the original ordering -+ by removing the reverse state. ++ Limiting` options. When multiple `--reverse=` options are given, ++ the final option overrides any previous options. The `--reverse` ++ option (with no specifier) behaves as `--reverse=after`, except ++ that, for historical reasons, it negates any previous reversed ++ state (so `--reverse --reverse` does nothing, nor does ++ `--reverse=before --reverse`. Note that `--reverse=before ++ --reverse --reverse` is the same as `--reverse=after`). endif::git-shortlog[] ifndef::git-shortlog[] 2: 480b322cf8 ! 2: 00489b0e52 revision.c: reduce memory usage on reverse before @@ revision.c: static struct commit *get_revision_internal(struct rev_info *revs) } +static void retrieve_with_window(struct rev_info *revs, int max_count, -+ struct commit_list **reversed) ++ struct commit_list **reversed) +{ + struct commit *c; + struct commit_list *into_queue = NULL; @@ revision.c: static struct commit *get_revision_internal(struct rev_info *revs) + } + } + -+ while (outo_count) { -+ c = pop_commit(&outo_queue); -+ outo_count--; ++ while ((c = pop_commit(&outo_queue))) + commit_list_insert(c, reversed); -+ } -+ -+ while (into_count) { -+ c = pop_commit(&into_queue); -+ into_count--; ++ while ((c = pop_commit(&into_queue))) + commit_list_insert(c, &outo_queue); -+ outo_count++; -+ } -+ -+ while (outo_count) { -+ c = pop_commit(&outo_queue); -+ outo_count--; ++ while ((c = pop_commit(&outo_queue))) + commit_list_insert(c, reversed); -+ } +} + struct commit *get_revision(struct rev_info *revs) -- 2.54.0