Thread (2 messages) 2 messages, 2 authors, 2025-08-04

Re: [PATCH] diff: ensure consistent diff behavior with -I<regex> across output formats

From: Jeff King <hidden>
Date: 2025-08-04 12:42:25

On Sun, Aug 03, 2025 at 09:39:21PM -0700, Junio C Hamano wrote:
Jeff King [off-list ref] writes:
quoted
.... It affects all of raw, name-only,
name-status, and checkdiff. I know Junio said that --raw should not be
affected, but I'm not sure I agree.
I no longer am sure if I agree.  I do not mind a raw entry that
would show different object name for preimage and postimage for a
path to be omitted when --ignore-whatever is passed and the blobs
compare "equal" under the specified "ignore" criteria.

The behaviour sounds somewhat incoherent, but that is what the user,
who passes both --raw and --ignore-whatever to the command at the
same time, wants.
Yeah, exactly. It definitely is weird, but it feels like the closest
thing to what the user asked for.

Just trying to play devil's advocate on this whole topic: is there
anybody who could complain about omitting these entries from raw or
name-only lists? IMHO it is weird and a bug that:

  git diff --name-only --raw -p -w <commit...>

might show an entry in the name-only and raw lists that doesn't also end
up in the actual patch. For just:

  git diff --name-only --raw -w

it is easy to say "well, why did you pass -w if you did not want
content-level inspection?". But when they are combined, could the
current behavior ever be preferred?

The two counterpoints I can think of are:

  1. Maybe that is an interesting signal to somebody that the diff _did_
     touch that path, but it just had no content-level change. I am
     having trouble imagining why that is useful, but it's not outside
     the realm of possibility. And certainly you could get that
     information separately by running a tree-level raw diff (without
     "-w") followed by a "-p -w" diff (and if you use diff-pairs, that
     second diff can even skip doing the tree-diff again).

  2. 99% of the time, "-w" (or -I, or whatever) will not remove the
     entirety of the change from those files. So we will do a whole
     content-level diff just to say "yep, we still should mention this
     in --raw"). Is the extra computation worth it?

-Peff
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help