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
@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
@mmontalbo
mmontalbo force-pushed the mm/line-log-tidy-proto branch from 6a4fdee to 5e27e0b Compare July 15, 2026 17:58
@mmontalbo

Copy link
Copy Markdown
Author

/preview

@gitgitgadget

gitgitgadget Bot commented Jul 15, 2026

Copy link
Copy Markdown

Preview email sent as pull.2169.git.1784138532955.gitgitgadget@gmail.com

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 calls 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 call leaves the commit's flags
unchanged.  The flags are compared 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 5e27e0b to 7dd9136 Compare July 15, 2026 18:04
@mmontalbo

Copy link
Copy Markdown
Author

/submit

@gitgitgadget

gitgitgadget Bot commented Jul 15, 2026

Copy link
Copy Markdown

Submitted as pull.2169.git.1784143793613.gitgitgadget@gmail.com

To fetch this version into FETCH_HEAD:

git fetch https://github.com/gitgitgadget/git/ pr-2169/mmontalbo/mm/line-log-tidy-proto-v1

To fetch this version to local tag pr-2169/mmontalbo/mm/line-log-tidy-proto-v1:

git fetch --no-tags https://github.com/gitgitgadget/git/ tag pr-2169/mmontalbo/mm/line-log-tidy-proto-v1

@gitgitgadget

gitgitgadget Bot commented Jul 16, 2026

Copy link
Copy Markdown

This branch is now known as mm/revision-pure-get-commit-action.

@gitgitgadget

gitgitgadget Bot commented Jul 16, 2026

Copy link
Copy Markdown

This patch series was integrated into seen via git@ee63858.

@gitgitgadget gitgitgadget Bot added the seen label Jul 16, 2026
@gitgitgadget

gitgitgadget Bot commented Jul 17, 2026

Copy link
Copy Markdown

There was a status update in the "New Topics" section about the branch mm/revision-pure-get-commit-action on the Git mailing list:

The 'get_commit_action()' function has been refactored to be a pure
predicate by moving the side-effecting line-level log range folding to
'simplify_commit()'.  This ensures that evaluating a commit's action
before the walk reaches it does not prematurely mutate its tracked
line ranges, making it safer for potential lookahead evaluations.

Needs review.
source: <pull.2169.git.1784143793613.gitgitgadget@gmail.com>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant