From: Jeff King <peff@peff.net>
To: Junio C Hamano <gitster@pobox.com>
Cc: Matt McCutchen <matt@mattmccutchen.net>, git@vger.kernel.org
Subject: Re: "git diff --ignore-space-change --stat" lists files with only whitespace differences as "changed"
Date: Wed, 18 Jan 2017 16:08:21 -0500 [thread overview]
Message-ID: <20170118210821.xugr6jnvzgoxpynb@sigill.intra.peff.net> (raw)
In-Reply-To: <xmqqvatc3x3r.fsf@gitster.mtv.corp.google.com>
On Wed, Jan 18, 2017 at 12:57:12PM -0800, Junio C Hamano wrote:
> Jeff King <peff@peff.net> writes:
>
> > So I dunno. A sensible rule to me is "iff -p would show a diff header,
> > then --stat should mention it".
>
> True but tricky (you need a better definition of "a diff header").
>
> In addition to a new and deleted file, does a file whose executable
> bit was flipped need mention? If so, then "diff --git" is the diff
> header in the above. Otherwise "@@ ... @@", iow, "iff -p would show
> any hunk".
>
> I think the patch implements the latter, which I think is sensible.
I would think the former is more sensible (and is what my patch is
working towards). Doing:
>empty
git add empty
git diff --cached
shows a "diff --git" header, but no hunk. I think it should show a
diffstat (and does with my patch).
I was thinking the rule should be something like:
if (p->status == DIFF_STATUS_MODIFIED &&
!file->added && !file->deleted))
and otherwise include the entry, since it would be an add, delete,
rename, etc, which carries useful information.
Though a pure rename would not hit this code path at all, I would think
(it would not trigger "!same_contents"). And a rename where there was a
whitespace only change probably _should_ be omitted from "-b".
Ditto for a pure mode change, I think. We do not run the contents
through diff at all, so it does not hit this code path.
-Peff
next prev parent reply other threads:[~2017-01-18 21:08 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-01-18 2:01 "git diff --ignore-space-change --stat" lists files with only whitespace differences as "changed" Matt McCutchen
2017-01-18 11:17 ` Jeff King
2017-01-18 20:57 ` Junio C Hamano
2017-01-18 21:08 ` Jeff King [this message]
2017-01-18 22:15 ` Junio C Hamano
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=20170118210821.xugr6jnvzgoxpynb@sigill.intra.peff.net \
--to=peff@peff.net \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=matt@mattmccutchen.net \
/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).