line-log: integrate -L with the standard log output pipeline#2094
Open
mmontalbo wants to merge 2 commits intogitgitgadget:masterfrom
Open
line-log: integrate -L with the standard log output pipeline#2094mmontalbo wants to merge 2 commits intogitgitgadget:masterfrom
mmontalbo wants to merge 2 commits intogitgitgadget:masterfrom
Conversation
`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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.