]> git.ipfire.org Git - thirdparty/git.git/commit
line-log: integrate -L output with the standard log-tree pipeline
authorMichael Montalbo <mmontalbo@gmail.com>
Mon, 25 May 2026 19:40:57 +0000 (19:40 +0000)
committerJunio C Hamano <gitster@pobox.com>
Mon, 25 May 2026 22:57:50 +0000 (07:57 +0900)
commit2b240d4281b8d517c23b6f163103c91f32fa34ff
treecfd74c7d26466cdd504bc464c355d9150886d864
parenta6969f90a502a83d53af5a293e203ac5b41996d2
line-log: integrate -L output with the standard log-tree pipeline

`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
f8781bfda3), 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 is no longer
   needed now that -L output flows through log_tree_diff() and
   log_tree_diff_flush(); this restores no_free save/restore,
   always_show_header, and diff_free() cleanup.

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 not yet supported with -L: the
filepairs are pre-computed during the history walk and scoped to
tracked line ranges, so there is currently no full-tree diff to
fall back to for display.

Update tests accordingly.

Signed-off-by: Michael Montalbo <mmontalbo@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
line-log.c
line-log.h
log-tree.c
revision.c
t/t4211-line-log.sh
t/t4211/sha1/expect.parallel-change-f-to-main
t/t4211/sha256/expect.parallel-change-f-to-main