Skip to content

revision: make get_commit_action() a pure predicate#2169

Open
mmontalbo wants to merge 1 commit into
gitgitgadget:masterfrom
mmontalbo:mm/line-log-tidy-proto
Open

revision: make get_commit_action() a pure predicate#2169
mmontalbo wants to merge 1 commit into
gitgitgadget:masterfrom
mmontalbo:mm/line-log-tidy-proto

Conversation

@mmontalbo

@mmontalbo mmontalbo commented Jul 5, 2026

Copy link
Copy Markdown

Cc: SZEDER Gábor szeder.dev@gmail.com

@mmontalbo mmontalbo changed the title line-log: extract the range-set module and tidy the -L machinery line-log: untangle the -L machinery and make get_commit_action() pure Jul 5, 2026
@mmontalbo mmontalbo force-pushed the mm/line-log-tidy-proto branch 4 times, most recently from 3ee39a8 to 80bb64c Compare July 11, 2026 00:08
@mmontalbo mmontalbo force-pushed the mm/line-log-tidy-proto branch from 80bb64c to 5a6705c Compare July 15, 2026 03:59
@mmontalbo mmontalbo changed the title line-log: untangle the -L machinery and make get_commit_action() pure revision: make get_commit_action() a pure predicate Jul 15, 2026
get_commit_action() reads as a predicate that decides whether a commit
is shown or ignored, but for a line-level log without parent rewriting
it also called line_log_process_ranges_arbitrary_commit(), which
mutates the tracked line ranges.  That hidden side effect makes it unsafe
to evaluate ahead of the walk, the way a lookahead would.

get_commit_action() was split out of simplify_commit() in beb5af4
(graph API: fix bug in graph_is_interesting(), 2009-08-18) as the
show/ignore decision minus the parent rewriting, so the graph renderer
could reuse it; line-level log later routed its filtering through it as
well, in 3cb9d2b (line-log: more responsive, incremental 'git log -L',
2020-05-11).  Besides simplify_commit(), the walk driver,
graph_is_interesting() is its only other caller, and it runs only under
--graph, which sets rewrite_parents and therefore want_ancestry(); the
"-L without ancestry" branch that holds the side effect never fires
there, so it is dormant today.

The line-level processing folds a commit's tracked ranges onto its
parents, which must happen even for a commit that get_commit_action()
filters from the output, or the ranges never reach the parents.  Move it
to simplify_commit() and run it before get_commit_action(), gated by
get_commit_action()'s leading checks (already shown, uninteresting, and
the like) so a commit ignored by those is not folded, as before; factor
those checks out as commit_early_ignore().  get_commit_action() is then
side-effect free.

commit_early_ignore() runs twice on the -L path, once for that gate and
once inside get_commit_action(), but it reads only object flags and pack
membership, disjoint from the TREESAME flag the fold sets, so the repeat
is harmless.

Add a "line-log-peek" subcommand to the revision-walking test helper
that evaluates get_commit_action() on a commit the walk has not reached
yet, plus a t4211 check that the commit's TREESAME flag is untouched.
The flag is watched rather than the commit list because add_line_range()
merges ranges by union, which is idempotent, so the side effect never
changed which commits a linear -L history shows.

Suggested-by: Junio C Hamano <gitster@pobox.com>
Signed-off-by: Michael Montalbo <mmontalbo@gmail.com>
@mmontalbo mmontalbo force-pushed the mm/line-log-tidy-proto branch from 5a6705c to 6a4fdee Compare July 15, 2026 04:21
@mmontalbo mmontalbo marked this pull request as ready for review July 15, 2026 04:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant