Skip to content

line-log: integrate -L with the standard log output pipeline#2094

Open
mmontalbo wants to merge 2 commits intogitgitgadget:masterfrom
mmontalbo:mm/line-log-use-log-tree-diff-flush
Open

line-log: integrate -L with the standard log output pipeline#2094
mmontalbo wants to merge 2 commits intogitgitgadget:masterfrom
mmontalbo:mm/line-log-use-log-tree-diff-flush

Conversation

@mmontalbo
Copy link
Copy Markdown

Since its introduction in 12da1d1 (2013), git log -L has
short-circuited from log_tree_commit() into its own output function,
bypassing log_tree_diff() and log_tree_diff_flush(). This skips
no_free save/restore (noted in a NEEDSWORK added by f8781bf),
the always_show_header fallback, and diff_free() cleanup.

Because -L computes diffs during the history walk to propagate line
ranges, its filepairs are already resolved when it reaches the
output stage. The output function only needs to queue those pairs
and let the standard pipeline handle the rest.

This series builds on the "line-log: route -L output through the
standard diff pipeline" series, merged at 1678b7d.

Patch 1 replaces line_log_print() with line_log_queue_pairs(), which
just queues pre-computed filepairs, and routes -L through
log_tree_diff() -> log_tree_diff_flush(), the same path used by the
normal single-parent and merge diff codepaths. Deferring show_log()
until after diffcore_std() means pickaxe and --diff-filter now
properly suppress commits when all pairs are filtered out.

Patch 2 expands the output format allowlist to accept --raw,
--name-only, --name-status, --summary, and --check. Diff stat
formats remain blocked because they would show whole-file statistics
rather than range-scoped ones. Also rejects --full-diff, which is
meaningless with -L since filepairs are pre-computed during the
history walk. A test_expect_failure documents that --check does not
yet scope its output to the tracked range.

`git log -L` has bypassed log_tree_diff() and log_tree_diff_flush()
since the feature was introduced, short-circuiting from
log_tree_commit() directly into line_log_print().  This skips the
no_free save/restore (noted in a NEEDSWORK comment added by
f8781bf), the always_show_header fallback, show_diff_of_diff(),
and diff_free() cleanup.

Restructure so that -L flows through log_tree_diff() ->
log_tree_diff_flush(), the same path used by the normal
single-parent and merge diff codepaths:

 - Rename line_log_print() to line_log_queue_pairs() and strip it
   down to just queuing pre-computed filepairs.  The show_log(),
   separator, diffcore_std(), and diff_flush() calls are removed
   since log_tree_diff_flush() handles all of those.

 - In log_tree_diff(), call line_log_queue_pairs() then
   log_tree_diff_flush(), mirroring the diff_tree_oid() + flush
   pattern used by the single-parent and merge codepaths.

 - Remove the early return in log_tree_commit() that bypassed
   no_free save/restore, always_show_header, and diff_free().

 - Move the -L block in setup_revisions() above the output_format
   to revs->diff derivation so that the default DIFF_FORMAT_PATCH
   is visible to the existing check.

Because show_log() is now deferred until after diffcore_std() inside
log_tree_diff_flush(), pickaxe (-S, -G, --find-object) and
--diff-filter now properly suppress commits when all pairs are
filtered out.

The blank-line separator between commit header and diff changes
slightly: the old code printed one unconditionally, while
log_tree_diff_flush() only emits one for verbose headers.  This
matches the rest of log output.

Update tests accordingly.

Signed-off-by: Michael Montalbo <mmontalbo@gmail.com>
Now that -L flows through log_tree_diff_flush() and diff_flush(),
metadata-only diff formats work because they only read filepair
fields (status, mode, path, oid) already set on the pre-computed
pairs.

Expand the allowlist in setup_revisions() to also accept --raw,
--name-only, --name-status, --summary, and --check.  Diff stat
formats (--stat, --numstat, --shortstat, --dirstat) remain blocked
because they call compute_diffstat() on full blob content and would
show whole-file statistics rather than range-scoped ones.

Also reject --full-diff, which is meaningless with -L: the filepairs
are pre-computed during the history walk and scoped to tracked paths,
so there is no tree diff to widen.

Signed-off-by: Michael Montalbo <mmontalbo@gmail.com>
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