line-log: integrate -L with the standard log output pipeline#2094
Open
mmontalbo wants to merge 3 commits intogitgitgadget:masterfrom
Open
line-log: integrate -L with the standard log output pipeline#2094mmontalbo wants to merge 3 commits intogitgitgadget:masterfrom
mmontalbo wants to merge 3 commits intogitgitgadget:masterfrom
Conversation
b1082fe to
151ccc5
Compare
The line_level_traverse block sets a default DIFF_FORMAT_PATCH when no output format has been explicitly requested. This default must be visible to the "Did the user ask for any diff output?" check that derives revs->diff from revs->diffopt.output_format. Currently the -L block runs after that derivation, so revs->diff stays 0 when no explicit format is given. This does not matter yet because log_tree_commit() short-circuits into line_log_print() before consulting revs->diff, but the next commit will route -L through the normal log_tree_diff() path, which checks revs->diff. Move the block above the derivation so the default DIFF_FORMAT_PATCH is in place when revs->diff is computed. No behavior change on its own. Signed-off-by: Michael Montalbo <mmontalbo@gmail.com>
`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(). 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. 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. Update tests accordingly. Signed-off-by: Michael Montalbo <mmontalbo@gmail.com>
151ccc5 to
1c88248
Compare
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, and --summary. 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. Signed-off-by: Michael Montalbo <mmontalbo@gmail.com>
1c88248 to
06c24b4
Compare
Author
|
/preview |
|
Preview email sent as pull.2094.git.1777348749.gitgitgadget@gmail.com |
Author
|
/submit |
|
Submitted as pull.2094.git.1777349126.gitgitgadget@gmail.com To fetch this version into To fetch this version to local tag |
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, 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, always_show_header, diff_free() cleanup, and
means that pickaxe (-S, -G, --find-object) and --diff-filter
cannot suppress commits whose pairs are all filtered out, because
show_log() runs before diffcore_std().
This series restructures the flow so that -L goes through the
same log_tree_diff() -> log_tree_diff_flush() path as normal
single-parent and merge diffs, then uses that to enable several
non-patch diff formats.
Patch 1: revision: move -L setup before output_format-to-diff derivation
Preparatory reorder in setup_revisions(). The -L block sets a
default DIFF_FORMAT_PATCH when no format is requested; move it
before the derivation of revs->diff from output_format so the
default is visible to that check. No behavior change on its own.
Patch 2: line-log: integrate -L output with the standard log-tree pipeline
Rename line_log_print() to line_log_queue_pairs(), stripping it
down to only queue pre-computed filepairs. log_tree_diff_flush()
handles show_log(), diffcore_std(), and diff_flush(). This
fixes pickaxe and --diff-filter suppression, and aligns the
commit/diff separator with the rest of log output. Also rejects
--full-diff, which is meaningless when filepairs are pre-computed.
Patch 3: line-log: allow non-patch diff formats with -L
Expand the allowlist to accept --raw, --name-only,
--name-status, and --summary. These only read filepair metadata
already set by the line-log machinery. 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.