git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Junio C Hamano <gitster@pobox.com>
To: Lidong Yan <yldhome2d2@gmail.com>
Cc: hi@arnes.space, git@vger.kernel.org, "Michał Kępień" <michal@isc.org>
Subject: Re: git-diff: --ignore-matching-lines has no effect on the output when --name-only is used
Date: Wed, 23 Jul 2025 10:09:38 -0700	[thread overview]
Message-ID: <xmqqqzy6omul.fsf@gitster.g> (raw)
In-Reply-To: <12095AC3-BC38-48DB-95B4-394F9F7DE054@gmail.com> (Lidong Yan's message of "Wed, 23 Jul 2025 16:00:43 +0800")

Lidong Yan <yldhome2d2@gmail.com> writes:

> The `—ignore-matching-lines` options is introduced in 296d4a94e72
> (Michał Kępień 2020-10-20 08:48:09 +0200 5803) Since the Git documentation

WTH is that reference format?

> doesn't specify how git diff --ignore-matching-lines=<regex>
> is supposed to behave when used with --name-only,

True.

Traditionally, these options that deliberately allowed loss of
information (e.g., --name-only that strips _how_ they are different,
--quiet that only talks about if there is anything different) are
meant primarily to be optimization---when it can compute its result
without looking into the blob contents, it is very much encouraged
to do so.  So originally the design principle was that options like
-w -b that needs to look into the blob contents are to be ignored
when computing --name-only and --quiet.

Things gradually have changed, and these days we generally consider
it a bug for the class of options that deliberately lose information
to disable the class of options that require to look into blob
contents to compute the outcome if the output were not losing
information.

"--ignore-matching-lines", together with any options that affect
XDF_IGNORE_WHITESPACE* (like -w, --ignore-space-at-eol) are special
cased to tell the machinery to look at the contents when deciding
what exit code to return:

	if ((options->xdl_opts & XDF_WHITESPACE_FLAGS) ||
	    options->ignore_regex_nr)
		options->flags.diff_from_contents = 1;
	else
		options->flags.diff_from_contents = 0;

so "git diff --ignore-matching-lines --quiet" would already be
operating correctly, I would think.

It is just --raw, --name-only, --name-status, and --checkdiff output
formats that deliberately ignore content based ignore mechanisms.

And I do not think it would be a good change to have them follow
"ignore" bits.  When asked "has this path been modified?"  "what are
the before and after blob object names?" etc., it does not make sense
for the answer to be different depending on the presense of -w or
--ignore-matching options.



  reply	other threads:[~2025-07-23 17:09 UTC|newest]

Thread overview: 35+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-07-23  5:47 git-diff: --ignore-matching-lines has no effect on the output when --name-only is used hi
2025-07-23  8:00 ` Lidong Yan
2025-07-23 17:09   ` Junio C Hamano [this message]
2025-07-24  1:56     ` Lidong Yan
2025-07-24  2:16       ` Eric Sunshine
2025-07-24  3:38         ` Lidong Yan
2025-07-25  6:00     ` hi
2025-07-25  6:06       ` hi
2025-07-25  6:46       ` Lidong Yan
2025-07-25  8:08         ` hi
2025-07-25 11:11           ` Jeff King
2025-07-25 15:20             ` Junio C Hamano
2025-07-29  8:18               ` [PATCH] diff: ensure consistent diff behavior with -I<regex> across output formats Lidong Yan
2025-07-30  0:28                 ` Junio C Hamano
2025-08-02 10:22                   ` Jeff King
2025-08-03  8:42                     ` Lidong Yan
2025-08-03 15:43                     ` Junio C Hamano
2025-08-04  4:39                     ` Junio C Hamano
2025-08-04 12:42                       ` Jeff King
2025-08-03 14:51                   ` [PATCH v2] " Lidong Yan
2025-08-04  0:39                     ` Junio C Hamano
2025-08-04  1:56                       ` Lidong Yan
2025-08-04  4:36                         ` Junio C Hamano
2025-08-05  9:23                           ` Lidong Yan
2025-08-05 16:11                             ` Junio C Hamano
2025-08-06 12:33                     ` [PATCH v3] diff: ensure consistent diff behavior with ignore options Lidong Yan
2025-08-06 17:35                       ` Junio C Hamano
2025-08-07  1:23                         ` Lidong Yan
2025-08-06 20:56                       ` Junio C Hamano
2025-08-07  1:39                         ` Lidong Yan
2025-08-07  2:06                       ` [PATCH v4] " Lidong Yan
2025-08-07 21:27                         ` Junio C Hamano
2025-08-08  1:46                           ` Lidong Yan
2025-08-08  3:30                             ` [PATCH v5] " Lidong Yan
2025-10-16 14:55                               ` Johannes Schindelin

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=xmqqqzy6omul.fsf@gitster.g \
    --to=gitster@pobox.com \
    --cc=git@vger.kernel.org \
    --cc=hi@arnes.space \
    --cc=michal@isc.org \
    --cc=yldhome2d2@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;
as well as URLs for NNTP newsgroup(s).