Skip to content

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

Closed
mmontalbo wants to merge 3 commits into
gitgitgadget:masterfrom
mmontalbo:mm/line-log-use-log-tree-diff-flush
Closed

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

Conversation

@mmontalbo

@mmontalbo mmontalbo commented Apr 19, 2026

Copy link
Copy Markdown

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. Rejects --full-diff, which
is not yet supported 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.

Changes since v2:

  • Switch "! test_grep" to "test_grep !" in tests.

cc: "D. Ben Knoble" ben.knoble@gmail.com

@mmontalbo mmontalbo force-pushed the mm/line-log-use-log-tree-diff-flush branch from b1082fe to 151ccc5 Compare April 27, 2026 21:42
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>
@mmontalbo mmontalbo force-pushed the mm/line-log-use-log-tree-diff-flush branch 2 times, most recently from 1c88248 to 06c24b4 Compare April 27, 2026 22:44
@mmontalbo

Copy link
Copy Markdown
Author

/preview

@gitgitgadget

gitgitgadget Bot commented Apr 28, 2026

Copy link
Copy Markdown

Preview email sent as pull.2094.git.1777348749.gitgitgadget@gmail.com

@mmontalbo

Copy link
Copy Markdown
Author

/submit

@gitgitgadget

gitgitgadget Bot commented Apr 28, 2026

Copy link
Copy Markdown

Submitted as pull.2094.git.1777349126.gitgitgadget@gmail.com

To fetch this version into FETCH_HEAD:

git fetch https://github.com/gitgitgadget/git/ pr-2094/mmontalbo/mm/line-log-use-log-tree-diff-flush-v1

To fetch this version to local tag pr-2094/mmontalbo/mm/line-log-use-log-tree-diff-flush-v1:

git fetch --no-tags https://github.com/gitgitgadget/git/ tag pr-2094/mmontalbo/mm/line-log-use-log-tree-diff-flush-v1

@gitgitgadget

gitgitgadget Bot commented May 3, 2026

Copy link
Copy Markdown

This branch is now known as mm/line-log-cleanup.

@gitgitgadget

gitgitgadget Bot commented May 3, 2026

Copy link
Copy Markdown

This patch series was integrated into seen via git@7dd37ea.

@gitgitgadget gitgitgadget Bot added the seen label May 3, 2026
@gitgitgadget

gitgitgadget Bot commented May 3, 2026

Copy link
Copy Markdown

There was a status update in the "New Topics" section about the branch mm/line-log-cleanup on the Git mailing list:

Code clean-up.

Comments?
source: <pull.2094.git.1777349126.gitgitgadget@gmail.com>

@gitgitgadget

gitgitgadget Bot commented May 4, 2026

Copy link
Copy Markdown

This patch series was integrated into seen via git@46c1ebf.

@gitgitgadget

gitgitgadget Bot commented May 9, 2026

Copy link
Copy Markdown

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

@gitgitgadget

gitgitgadget Bot commented May 9, 2026

Copy link
Copy Markdown

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

@gitgitgadget

gitgitgadget Bot commented May 11, 2026

Copy link
Copy Markdown

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

@gitgitgadget

gitgitgadget Bot commented May 11, 2026

Copy link
Copy Markdown

There was a status update in the "Cooking" section about the branch mm/line-log-cleanup on the Git mailing list:

Code clean-up.

Comments?
source: <pull.2094.git.1777349126.gitgitgadget@gmail.com>

@gitgitgadget

gitgitgadget Bot commented May 11, 2026

Copy link
Copy Markdown

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

@gitgitgadget

gitgitgadget Bot commented May 11, 2026

Copy link
Copy Markdown

This patch series was integrated into seen via git@9781aa1.

@gitgitgadget

gitgitgadget Bot commented May 12, 2026

Copy link
Copy Markdown

Junio C Hamano wrote on the Git mailing list (how to reply to this email):

"Michael Montalbo via GitGitGadget" <gitgitgadget@gmail.com> writes:

> 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.

This unfortunately saw no reviews and

  https://lore.kernel.org/git/pull.2094.git.1777349126.gitgitgadget@gmail.com/

does not show the previous rouns so I am assuming nobody is
interested in the topic?  

Or are people more busily writing their own patches than reviewing
others' patches?  Unfortunately that is not sustainable.




> 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.
>
> Michael Montalbo (3):
>   revision: move -L setup before output_format-to-diff derivation
>   line-log: integrate -L output with the standard log-tree pipeline
>   line-log: allow non-patch diff formats with -L
>
>  Documentation/line-range-options.adoc         | 10 +-
>  line-log.c                                    | 30 ++----
>  line-log.h                                    |  2 +-
>  log-tree.c                                    |  9 +-
>  revision.c                                    | 25 +++--
>  t/t4211-line-log.sh                           | 99 ++++++++++++++++---
>  t/t4211/sha1/expect.parallel-change-f-to-main |  1 -
>  .../sha256/expect.parallel-change-f-to-main   |  1 -
>  8 files changed, 120 insertions(+), 57 deletions(-)
>
>
> base-commit: 9f223ef1c026d91c7ac68cc0211bde255dda6199
> Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-2094%2Fmmontalbo%2Fmm%2Fline-log-use-log-tree-diff-flush-v1
> Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-2094/mmontalbo/mm/line-log-use-log-tree-diff-flush-v1
> Pull-Request: https://github.com/gitgitgadget/git/pull/2094

@gitgitgadget

gitgitgadget Bot commented May 12, 2026

Copy link
Copy Markdown

This patch series was integrated into seen via git@67cdb16.

@gitgitgadget

gitgitgadget Bot commented May 12, 2026

Copy link
Copy Markdown

There was a status update in the "Cooking" section about the branch mm/line-log-cleanup on the Git mailing list:

Code clean-up.

Comments?
cf. <xmqqfr3xp98b.fsf@gitster.g>
source: <pull.2094.git.1777349126.gitgitgadget@gmail.com>

@gitgitgadget

gitgitgadget Bot commented May 13, 2026

Copy link
Copy Markdown

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

@gitgitgadget

gitgitgadget Bot commented May 14, 2026

Copy link
Copy Markdown

This patch series was integrated into seen via git@3cd0553.

@gitgitgadget

gitgitgadget Bot commented May 15, 2026

Copy link
Copy Markdown

This patch series was integrated into seen via git@15f8769.

@gitgitgadget

gitgitgadget Bot commented May 18, 2026

Copy link
Copy Markdown

This patch series was integrated into seen via git@36f0732.

@gitgitgadget

gitgitgadget Bot commented May 18, 2026

Copy link
Copy Markdown

There was a status update in the "Cooking" section about the branch mm/line-log-cleanup on the Git mailing list:

Code clean-up.

Comments?
cf. <xmqqfr3xp98b.fsf@gitster.g>
source: <pull.2094.git.1777349126.gitgitgadget@gmail.com>

@gitgitgadget

gitgitgadget Bot commented May 18, 2026

Copy link
Copy Markdown

This patch series was integrated into seen via git@5ac231a.

@gitgitgadget

gitgitgadget Bot commented May 19, 2026

Copy link
Copy Markdown

This patch series was integrated into seen via git@3c5be57.

@gitgitgadget

gitgitgadget Bot commented May 20, 2026

Copy link
Copy Markdown

This patch series was integrated into seen via git@0f29831.

@mmontalbo

Copy link
Copy Markdown
Author

/submit

@gitgitgadget

gitgitgadget Bot commented May 25, 2026

Copy link
Copy Markdown

Submitted as pull.2094.v2.git.1779738059.gitgitgadget@gmail.com

To fetch this version into FETCH_HEAD:

git fetch https://github.com/gitgitgadget/git/ pr-2094/mmontalbo/mm/line-log-use-log-tree-diff-flush-v2

To fetch this version to local tag pr-2094/mmontalbo/mm/line-log-use-log-tree-diff-flush-v2:

git fetch --no-tags https://github.com/gitgitgadget/git/ tag pr-2094/mmontalbo/mm/line-log-use-log-tree-diff-flush-v2

@gitgitgadget

gitgitgadget Bot commented May 26, 2026

Copy link
Copy Markdown

There was a status update in the "Cooking" section about the branch mm/line-log-cleanup on the Git mailing list:

The `git log -L` implementation has been refactored to use the
standard diff output pipeline, enabling pickaxe and diff-filter to
work as expected. Additionally, metadata-only diff formats like
--raw and --name-only are now supported with -L.

Will merge to 'next'?
source: <pull.2120.v2.git.1779733799.gitgitgadget@gmail.com>

@gitgitgadget

gitgitgadget Bot commented May 27, 2026

Copy link
Copy Markdown

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

@gitgitgadget

gitgitgadget Bot commented May 27, 2026

Copy link
Copy Markdown

There was a status update in the "Cooking" section about the branch mm/line-log-cleanup on the Git mailing list:

The `git log -L` implementation has been refactored to use the
standard diff output pipeline, enabling pickaxe and diff-filter to
work as expected. Additionally, metadata-only diff formats like
--raw and --name-only are now supported with -L.

Will merge to 'next'?
source: <pull.2120.v2.git.1779733799.gitgitgadget@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, 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>
@gitgitgadget

gitgitgadget Bot commented May 27, 2026

Copy link
Copy Markdown

"D. Ben Knoble" wrote on the Git mailing list (how to reply to this email):

On Mon, May 25, 2026 at 3:41 PM Michael Montalbo via GitGitGadget
<gitgitgadget@gmail.com> wrote:
>
> 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. Rejects --full-diff, which is not yet supported 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.
>
> Changes since v1:
>
>  * Patch 2: use !opt->loginfo return convention in log_tree_diff() to match
>    the existing single-parent and merge codepaths, instead of returning
>    log_tree_diff_flush() directly.
>  * Patch 2: reword the early-return removal to explicitly tie it to the
>    pipeline change.
>  * Patch 2: soften --full-diff rejection to "not yet supported".
>  * Patches 2-3: use test_grep consistently in new tests.
>  * Patch 2: replace sed | grep pipe with sed > file && test_grep for proper
>    exit status handling.
>
> Michael Montalbo (3):
>   revision: move -L setup before output_format-to-diff derivation
>   line-log: integrate -L output with the standard log-tree pipeline
>   line-log: allow non-patch diff formats with -L
>
>  Documentation/line-range-options.adoc         |  10 +-
>  line-log.c                                    |  30 ++----
>  line-log.h                                    |   2 +-
>  log-tree.c                                    |  10 +-
>  revision.c                                    |  24 +++--
>  t/t4211-line-log.sh                           | 100 +++++++++++++++---
>  t/t4211/sha1/expect.parallel-change-f-to-main |   1 -
>  .../sha256/expect.parallel-change-f-to-main   |   1 -
>  8 files changed, 121 insertions(+), 57 deletions(-)
>
>
> base-commit: 9f223ef1c026d91c7ac68cc0211bde255dda6199
> Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-2094%2Fmmontalbo%2Fmm%2Fline-log-use-log-tree-diff-flush-v2
> Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-2094/mmontalbo/mm/line-log-use-log-tree-diff-flush-v2
> Pull-Request: https://github.com/gitgitgadget/git/pull/2094
>
> Range-diff vs v1:

Looks good.

>
>  1:  9633eb62c6 = 1:  9633eb62c6 revision: move -L setup before output_format-to-diff derivation
>  2:  2d9e0ca015 ! 2:  7acfc5376e line-log: integrate -L output with the standard log-tree pipeline
>      @@ Commit message
>              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().
>      +     - 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
>      @@ Commit message
>           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.
>      +    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.
>
>      @@ log-tree.c: static int log_tree_diff(struct rev_info *opt, struct commit *commit
>
>       + if (opt->line_level_traverse) {
>       +         line_log_queue_pairs(opt, commit);
>      -+         return log_tree_diff_flush(opt);
>      ++         log_tree_diff_flush(opt);
>      ++         return !opt->loginfo;
>       + }
>       +
>         parse_commit_or_die(commit);
>      @@ log-tree.c: int log_tree_commit(struct rev_info *opt, struct commit *commit)
>
>        ## revision.c ##
>       @@ revision.c: int setup_revisions(int argc, const char **argv, struct rev_info *revs, struct s
>      +          die(_("the option '%s' requires '%s'"), "--grep-reflog", "--walk-reflogs");
>      +
>         if (revs->line_level_traverse &&
>      -      (revs->diffopt.output_format & ~(DIFF_FORMAT_PATCH | DIFF_FORMAT_NO_OUTPUT)))
>      -          die(_("-L does not yet support diff formats besides -p and -s"));
>      -+ if (revs->line_level_traverse && revs->full_diff)
>      -+         die(_("-L is not compatible with --full-diff"));
>      +-     (revs->diffopt.output_format & ~(DIFF_FORMAT_PATCH | DIFF_FORMAT_NO_OUTPUT)))
>      +-         die(_("-L does not yet support diff formats besides -p and -s"));
>      ++     (revs->full_diff ||
>      ++      (revs->diffopt.output_format &
>      ++       ~(DIFF_FORMAT_PATCH | DIFF_FORMAT_NO_OUTPUT))))
>      ++         die(_("-L does not yet support the requested diff format"));
>
>         if (revs->expand_tabs_in_log < 0)
>                 revs->expand_tabs_in_log = revs->expand_tabs_in_log_default;
>      @@ t/t4211-line-log.sh: test_expect_success '-L with -G filters to diff-text matche
>       + test_cmp expect actual
>       +'
>       +
>      -+test_expect_success '--full-diff is not supported with -L' '
>      ++test_expect_success '--full-diff is not yet supported with -L' '
>       + test_must_fail git log -L1,24:b.c --full-diff 2>err &&
>      -+ test_grep "not compatible with --full-diff" err
>      ++ test_grep "does not yet support" err
>       +'
>       +
>       +test_expect_success '-L --oneline has no extra blank line before diff' '
>       + git checkout parent-oids &&
>       + git log --oneline -L:func2:file.c -1 >actual &&
>       + # Oneline header on line 1, diff starts immediately on line 2
>      -+ sed -n 2p actual | grep "^diff --git"
>      ++ sed -n 2p actual >line2 &&
>      ++ test_grep "^diff --git" line2
>       +'
>       +
>        test_done
>  3:  06c24b416f ! 3:  10a3d8dde2 line-log: allow non-patch diff formats with -L
>      @@ Documentation/line-range-options.adoc
>
>        ## revision.c ##
>       @@ revision.c: int setup_revisions(int argc, const char **argv, struct rev_info *revs, struct s
>      -          die(_("the option '%s' requires '%s'"), "--grep-reflog", "--walk-reflogs");
>      -
>         if (revs->line_level_traverse &&
>      --     (revs->diffopt.output_format & ~(DIFF_FORMAT_PATCH | DIFF_FORMAT_NO_OUTPUT)))
>      --         die(_("-L does not yet support diff formats besides -p and -s"));
>      -+     (revs->diffopt.output_format &
>      -+      ~(DIFF_FORMAT_PATCH | DIFF_FORMAT_NO_OUTPUT |
>      -+        DIFF_FORMAT_RAW | DIFF_FORMAT_NAME |
>      -+        DIFF_FORMAT_NAME_STATUS | DIFF_FORMAT_SUMMARY)))
>      -+         die(_("-L does not yet support the requested diff format"));
>      -  if (revs->line_level_traverse && revs->full_diff)
>      -          die(_("-L is not compatible with --full-diff"));
>      +      (revs->full_diff ||
>      +       (revs->diffopt.output_format &
>      +-       ~(DIFF_FORMAT_PATCH | DIFF_FORMAT_NO_OUTPUT))))
>      ++       ~(DIFF_FORMAT_PATCH | DIFF_FORMAT_NO_OUTPUT |
>      ++         DIFF_FORMAT_RAW | DIFF_FORMAT_NAME |
>      ++         DIFF_FORMAT_NAME_STATUS | DIFF_FORMAT_SUMMARY))))
>      +          die(_("-L does not yet support the requested diff format"));
>
>      +  if (revs->expand_tabs_in_log < 0)
>
>        ## t/t4211-line-log.sh ##
>       @@ t/t4211-line-log.sh: test_expect_success '-p shows the default patch output' '
>      @@ t/t4211-line-log.sh: test_expect_success '-p shows the default patch output' '
>       - test_must_fail git log -L1,24:b.c --raw
>       +test_expect_success '--raw shows mode, oid, status and path' '
>       + git log -L1,24:b.c --raw --format= >actual &&
>      -+ grep "^:100644 100644 [0-9a-f]\{7\} [0-9a-f]\{7\} M     b.c$" actual &&
>      -+ ! grep "^diff --git" actual &&
>      -+ ! grep "^@@" actual
>      ++ test_grep "^:100644 100644 [0-9a-f]\{7\} [0-9a-f]\{7\} M        b.c$" actual &&
>      ++ ! test_grep "^diff --git" actual &&
>      ++ ! test_grep "^@@" actual

I wish we had docs for all the little test helpers… in particular, I
think this is supposed to be "test_grep !" ?

>       +'
>       +
>       +test_expect_success '--name-only shows path' '
>       + git log -L1,24:b.c --name-only --format= >actual &&
>      -+ grep "^b.c$" actual &&
>      -+ ! grep "^diff --git" actual &&
>      -+ ! grep "^@@" actual
>      ++ test_grep "^b.c$" actual &&
>      ++ ! test_grep "^diff --git" actual &&
>      ++ ! test_grep "^@@" actual
>       +'
>       +
>       +test_expect_success '--name-status shows status and path' '
>       + git log -L1,24:b.c --name-status --format= >actual &&
>      -+ grep "^M        b.c$" actual &&
>      -+ ! grep "^diff --git" actual &&
>      -+ ! grep "^@@" actual
>      ++ test_grep "^M   b.c$" actual &&
>      ++ ! test_grep "^diff --git" actual &&
>      ++ ! test_grep "^@@" actual
>       +'
>       +
>       +test_expect_success '--stat is not yet supported with -L' '
>      @@ t/t4211-line-log.sh: test_expect_success '-p shows the default patch output' '
>
>        test_expect_success 'setup for checking fancy rename following' '
>       @@ t/t4211-line-log.sh: test_expect_success '-L --oneline has no extra blank line before diff' '
>      -  sed -n 2p actual | grep "^diff --git"
>      +  test_grep "^diff --git" line2
>        '
>
>       +test_expect_success '--summary shows new file on root commit' '
>       + git checkout parent-oids &&
>       + git log -L:func2:file.c --summary --format= >actual &&
>      -+ grep "create mode 100644 file.c" actual
>      ++ test_grep "create mode 100644 file.c" actual
>       +'
>       +
>        test_done
>
> --
> gitgitgadget

Thanks

-- 
D. Ben Knoble

@mmontalbo mmontalbo force-pushed the mm/line-log-use-log-tree-diff-flush branch from 10a3d8d to ae0b7f3 Compare May 28, 2026 19:39
@gitgitgadget

gitgitgadget Bot commented May 28, 2026

Copy link
Copy Markdown

Junio C Hamano wrote on the Git mailing list (how to reply to this email):

"D. Ben Knoble" <ben.knoble@gmail.com> writes:

>>      ++ ! test_grep "^diff --git" actual &&
>>      ++ ! test_grep "^@@" actual
>
> I wish we had docs for all the little test helpers… in particular, I
> think this is supposed to be "test_grep !" ?

Good eyes.  I wonder if we teach test-lint to catch these.

@gitgitgadget

gitgitgadget Bot commented May 28, 2026

Copy link
Copy Markdown

Michael Montalbo wrote on the Git mailing list (how to reply to this email):

On Thu, May 28, 2026 at 11:55 AM Junio C Hamano <gitster@pobox.com> wrote:
>
> "D. Ben Knoble" <ben.knoble@gmail.com> writes:
>
> >>      ++ ! test_grep "^diff --git" actual &&
> >>      ++ ! test_grep "^@@" actual
> >
> > I wish we had docs for all the little test helpers… in particular, I
> > think this is supposed to be "test_grep !" ?

Good catch, thank you! Will submit a fix and try to address the lack
of docs in a follow-up.

>
> Good eyes.  I wonder if we teach test-lint to catch these.

I had the same thought, and started working on a series that does this
and migrates
existing offenders. I should be able to submit it soon.

@mmontalbo

Copy link
Copy Markdown
Author

/submit

@gitgitgadget

gitgitgadget Bot commented May 28, 2026

Copy link
Copy Markdown

Submitted as pull.2094.v3.git.1780001267.gitgitgadget@gmail.com

To fetch this version into FETCH_HEAD:

git fetch https://github.com/gitgitgadget/git/ pr-2094/mmontalbo/mm/line-log-use-log-tree-diff-flush-v3

To fetch this version to local tag pr-2094/mmontalbo/mm/line-log-use-log-tree-diff-flush-v3:

git fetch --no-tags https://github.com/gitgitgadget/git/ tag pr-2094/mmontalbo/mm/line-log-use-log-tree-diff-flush-v3

@gitgitgadget

gitgitgadget Bot commented May 29, 2026

Copy link
Copy Markdown

This patch series was integrated into seen via git@09f9932.

@gitgitgadget

gitgitgadget Bot commented May 29, 2026

Copy link
Copy Markdown

Ben Knoble wrote on the Git mailing list (how to reply to this email):

> Le 28 mai 2026 à 16:47, Michael Montalbo via GitGitGadget <gitgitgadget@gmail.com> a écrit :
> 
> 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. Rejects --full-diff, which is not yet supported 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.
> 
> Changes since v2:
> 
> * Switch "! test_grep" to "test_grep !" in tests.

Thanks ! I did not read the tests carefully for semantic value, but the rationale and overall code looks good to me as discussed previously.

The range-diff here looks good, too. 


> Michael Montalbo (3):
>  revision: move -L setup before output_format-to-diff derivation
>  line-log: integrate -L output with the standard log-tree pipeline
>  line-log: allow non-patch diff formats with -L
> 
> Documentation/line-range-options.adoc         |  10 +-
> line-log.c                                    |  30 ++----
> line-log.h                                    |   2 +-
> log-tree.c                                    |  10 +-
> revision.c                                    |  24 +++--
> t/t4211-line-log.sh                           | 100 +++++++++++++++---
> t/t4211/sha1/expect.parallel-change-f-to-main |   1 -
> .../sha256/expect.parallel-change-f-to-main   |   1 -
> 8 files changed, 121 insertions(+), 57 deletions(-)
> 
> 
> base-commit: 9f223ef1c026d91c7ac68cc0211bde255dda6199
> Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-2094%2Fmmontalbo%2Fmm%2Fline-log-use-log-tree-diff-flush-v3
> Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-2094/mmontalbo/mm/line-log-use-log-tree-diff-flush-v3
> Pull-Request: https://github.com/gitgitgadget/git/pull/2094
> 
> Range-diff vs v2:
> 
> 1:  9633eb62c6 = 1:  9633eb62c6 revision: move -L setup before output_format-to-diff derivation
> 2:  7acfc5376e = 2:  7acfc5376e line-log: integrate -L output with the standard log-tree pipeline
> 3:  10a3d8dde2 ! 3:  ae0b7f3ca8 line-log: allow non-patch diff formats with -L
>     @@ t/t4211-line-log.sh: test_expect_success '-p shows the default patch output' '
>      +test_expect_success '--raw shows mode, oid, status and path' '
>      +    git log -L1,24:b.c --raw --format= >actual &&
>      +    test_grep "^:100644 100644 [0-9a-f]\{7\} [0-9a-f]\{7\} M    b.c$" actual &&
>     -+    ! test_grep "^diff --git" actual &&
>     -+    ! test_grep "^@@" actual
>     ++    test_grep ! "^diff --git" actual &&
>     ++    test_grep ! "^@@" actual
>      +'
>      +
>      +test_expect_success '--name-only shows path' '
>      +    git log -L1,24:b.c --name-only --format= >actual &&
>      +    test_grep "^b.c$" actual &&
>     -+    ! test_grep "^diff --git" actual &&
>     -+    ! test_grep "^@@" actual
>     ++    test_grep ! "^diff --git" actual &&
>     ++    test_grep ! "^@@" actual
>      +'
>      +
>      +test_expect_success '--name-status shows status and path' '
>      +    git log -L1,24:b.c --name-status --format= >actual &&
>      +    test_grep "^M    b.c$" actual &&
>     -+    ! test_grep "^diff --git" actual &&
>     -+    ! test_grep "^@@" actual
>     ++    test_grep ! "^diff --git" actual &&
>     ++    test_grep ! "^@@" actual
>      +'
>      +
>      +test_expect_success '--stat is not yet supported with -L' '
> 
> --
> gitgitgadget

@gitgitgadget

gitgitgadget Bot commented May 31, 2026

Copy link
Copy Markdown

This patch series was integrated into seen via git@84d54c5.

@gitgitgadget

gitgitgadget Bot commented Jun 1, 2026

Copy link
Copy Markdown

Junio C Hamano wrote on the Git mailing list (how to reply to this email):

Ben Knoble <ben.knoble@gmail.com> writes:

>> Changes since v2:
>> 
>> * Switch "! test_grep" to "test_grep !" in tests.
>
> Thanks ! I did not read the tests carefully for semantic value,
> but the rationale and overall code looks good to me as discussed
> previously.
>
> The range-diff here looks good, too. 

Thanks, both.  Let's mark it for 'next' then.

@gitgitgadget

gitgitgadget Bot commented Jun 2, 2026

Copy link
Copy Markdown

This patch series was integrated into seen via git@76ed715.

@gitgitgadget

gitgitgadget Bot commented Jun 2, 2026

Copy link
Copy Markdown

This patch series was integrated into seen via git@93fc0d1.

@gitgitgadget

gitgitgadget Bot commented Jun 2, 2026

Copy link
Copy Markdown

There was a status update in the "Cooking" section about the branch mm/line-log-cleanup on the Git mailing list:

The `git log -L` implementation has been refactored to use the
standard diff output pipeline, enabling pickaxe and diff-filter to
work as expected. Additionally, metadata-only diff formats like
--raw and --name-only are now supported with -L.

Will merge to 'next'.
cf. <B59BA5B1-184D-48A8-8BAD-11EB6F8EB50C@gmail.com>
source: <pull.2094.v3.git.1780001267.gitgitgadget@gmail.com>

@gitgitgadget

gitgitgadget Bot commented Jun 3, 2026

Copy link
Copy Markdown

This patch series was integrated into seen via git@2330bb0.

@gitgitgadget

gitgitgadget Bot commented Jun 4, 2026

Copy link
Copy Markdown

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

@gitgitgadget

gitgitgadget Bot commented Jun 4, 2026

Copy link
Copy Markdown

This patch series was integrated into next via git@02f8bea.

@gitgitgadget gitgitgadget Bot added the next label Jun 4, 2026
@gitgitgadget

gitgitgadget Bot commented Jun 4, 2026

Copy link
Copy Markdown

There was a status update in the "Cooking" section about the branch mm/line-log-cleanup on the Git mailing list:

The `git log -L` implementation has been refactored to use the
standard diff output pipeline, enabling pickaxe and diff-filter to
work as expected. Additionally, metadata-only diff formats like
--raw and --name-only are now supported with -L.

Will merge to 'master'.
cf. <B59BA5B1-184D-48A8-8BAD-11EB6F8EB50C@gmail.com>
source: <pull.2094.v3.git.1780001267.gitgitgadget@gmail.com>

@gitgitgadget

gitgitgadget Bot commented Jun 9, 2026

Copy link
Copy Markdown

There was a status update in the "Cooking" section about the branch mm/line-log-cleanup on the Git mailing list:

The `git log -L` implementation has been refactored to use the
standard diff output pipeline, enabling pickaxe and diff-filter to
work as expected. Additionally, metadata-only diff formats like
--raw and --name-only are now supported with -L.

Will merge to 'master'.
cf. <B59BA5B1-184D-48A8-8BAD-11EB6F8EB50C@gmail.com>
source: <pull.2094.v3.git.1780001267.gitgitgadget@gmail.com>

@gitgitgadget

gitgitgadget Bot commented Jun 11, 2026

Copy link
Copy Markdown

There was a status update in the "Graduated to 'master'" section about the branch mm/line-log-cleanup on the Git mailing list:

The `git log -L` implementation has been refactored to use the
standard diff output pipeline, enabling pickaxe and diff-filter to
work as expected. Additionally, metadata-only diff formats like
--raw and --name-only are now supported with -L.
cf. <B59BA5B1-184D-48A8-8BAD-11EB6F8EB50C@gmail.com>
source: <pull.2094.v3.git.1780001267.gitgitgadget@gmail.com>

@gitgitgadget

gitgitgadget Bot commented Jun 11, 2026

Copy link
Copy Markdown

This patch series was integrated into master via git@53ff393.

@gitgitgadget gitgitgadget Bot added the master label Jun 11, 2026
@gitgitgadget gitgitgadget Bot closed this Jun 11, 2026
@gitgitgadget

gitgitgadget Bot commented Jun 11, 2026

Copy link
Copy Markdown

Congratulations! 🎉 Your patch series was merged into upstream via 53ff393.

Note: this pull request will show as "Closed" rather than "Merged" because the merge happened in the upstream repository, not on GitHub. This is expected — your contribution has been accepted!

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant