Git development
 help / color / mirror / Atom feed
From: Junio C Hamano <gitster@pobox.com>
To: "Michael Montalbo via GitGitGadget" <gitgitgadget@gmail.com>
Cc: git@vger.kernel.org,  "D. Ben Knoble" <ben.knoble@gmail.com>,
	 Michael Montalbo <mmontalbo@gmail.com>
Subject: Re: [PATCH 5/7] line-log: support diff stat formats with -L
Date: Thu, 18 Jun 2026 15:00:12 -0700	[thread overview]
Message-ID: <xmqq8q8bpl03.fsf@gitster.g> (raw)
In-Reply-To: <a70d861d27a13459bab34f6681b3ccfe2f20d0d8.1781806593.git.gitgitgadget@gmail.com> (Michael Montalbo via GitGitGadget's message of "Thu, 18 Jun 2026 18:16:30 +0000")

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

> diff --git a/Documentation/line-range-options.adoc b/Documentation/line-range-options.adoc
> index 72f639b5e7..1a25f55bb1 100644
> --- a/Documentation/line-range-options.adoc
> +++ b/Documentation/line-range-options.adoc
> @@ -9,10 +9,14 @@
>  	_<start>_ and _<end>_ (or _<funcname>_) must exist in the starting revision.
>  	You can specify this option more than once. Implies `--patch`.
>  	Patch output can be suppressed using `--no-patch`.
> -	Non-patch diff formats `--raw`, `--name-only`, `--name-status`,
> -	and `--summary` are supported.  Diff stat formats
> -	(`--stat`, `--numstat`, `--shortstat`, `--dirstat`) are not
> -	currently implemented.
> +	The following non-patch diff formats are supported: `--raw`,
> +	`--name-only`, `--name-status`, `--summary`,
> +	`--stat`, `--numstat`, and `--shortstat`.
> +	The stat formats show range-scoped counts: only lines within
> +	the tracked range are counted.  `--dirstat` is not supported

If "range-scoped" is a widely known term (as opposed to a new word
invented only during the introduction of this topic), the above
reads well with a nice rhythm, but otherwise it may be easier to
read, i.e., something like

	The stat formats counts only lines within the tracked range.

without having readers learn yet another new term that is only used
here.

> diff --git a/diff.c b/diff.c
> index 6233a96bf0..026fafeb90 100644
> --- a/diff.c
> +++ b/diff.c
> @@ -4289,7 +4289,18 @@ static void builtin_diffstat(const char *name_a, const char *name_b,
>  		xecfg.ctxlen = o->context;
>  		xecfg.interhunkctxlen = o->interhunkcontext;
>  		xecfg.flags = XDL_EMIT_NO_HUNK_HDR;
> -		if (xdi_diff_outf(&mf1, &mf2, NULL,
> +
> +		if (p->line_ranges) {
> +			struct line_range_filter lr_filter;
> +
> +			line_range_filter_init(&lr_filter, p->line_ranges,
> +					       diffstat_consume, diffstat);
> +
> +			if (line_range_filter_diff(&lr_filter, &mf1, &mf2,
> +						   &xpp, &xecfg))
> +				die("unable to generate diffstat for %s",
> +				    one->path);
> +		} else if (xdi_diff_outf(&mf1, &mf2, NULL,
>  				  diffstat_consume, diffstat, &xpp, &xecfg))
>  			die("unable to generate diffstat for %s", one->path);

It is pleasing to see that this can be done with such a surprisingly
small change.


  reply	other threads:[~2026-06-18 22:00 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-06-18 18:16 [PATCH 0/7] line-log: range-scope stat, check, and -G under -L Michael Montalbo via GitGitGadget
2026-06-18 18:16 ` [PATCH 1/7] diff: rename and group the line-range filter for clarity Michael Montalbo via GitGitGadget
2026-06-18 18:16 ` [PATCH 2/7] diff: simplify the line-range filter by classifying removals immediately Michael Montalbo via GitGitGadget
2026-06-18 18:16 ` [PATCH 3/7] diff: emit -L hunk headers via xdiff's formatter Michael Montalbo via GitGitGadget
2026-06-18 18:16 ` [PATCH 4/7] diff: extract a line-range diff helper for reuse Michael Montalbo via GitGitGadget
2026-06-18 18:16 ` [PATCH 5/7] line-log: support diff stat formats with -L Michael Montalbo via GitGitGadget
2026-06-18 22:00   ` Junio C Hamano [this message]
2026-06-18 18:16 ` [PATCH 6/7] diff: support --check with -L line ranges Michael Montalbo via GitGitGadget
2026-06-18 18:16 ` [PATCH 7/7] diffcore-pickaxe: scope -G to the -L tracked range Michael Montalbo via GitGitGadget

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=xmqq8q8bpl03.fsf@gitster.g \
    --to=gitster@pobox.com \
    --cc=ben.knoble@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=gitgitgadget@gmail.com \
    --cc=mmontalbo@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox