git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Junio C Hamano <gitster@pobox.com>
To: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Git Mailing List <git@vger.kernel.org>
Subject: Re: Fix "git diff --stat" for interesting - but empty - file changes
Date: Wed, 17 Oct 2012 11:28:02 -0700	[thread overview]
Message-ID: <7v4nltoswd.fsf@alter.siamese.dyndns.org> (raw)
In-Reply-To: <CA+55aFz88GPJcfMSqiyY+u0Cdm48bEyrsTGxHVJbGsYsDg=Q5w@mail.gmail.com> (Linus Torvalds's message of "Wed, 17 Oct 2012 10:00:37 -0700")

Linus Torvalds <torvalds@linux-foundation.org> writes:

> So if you did
>
>    chmod +x Makefile
>    git diff --stat
>
> before, it would show empty (" 0 files changed"), with this it shows
>
>  Makefile | 0
>  1 file changed, 0 insertions(+), 0 deletions(-)
>
> which I think is a more correct diffstat (and then with "--summary" it
> shows *what* the metadata change to Makefile was - this is completely
> consistent with our handling of renamed files).
>
> Side note: the old behavior was *really* odd. With no changes at all,
> "git diff --stat" output was empty. With just a chmod, it said "0
> files changed". No way is our legacy behavior sane.
>
> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
> ---
>
> This was triggered by kernel developers not noticing that they had
> added zero-sized files, because those additions never showed up in the
> diffstat.
> ...
> Comments?

I think listing a file whose content remain unchanged with 0 as the
number of lines affected makes sense, and it will mesh well with
Duy's

  http://thread.gmane.org/gmane.comp.version-control.git/207749

I first wondered if we would get a division-by-zero while scaling
the graph, but we do not scale smaller numbers up to fill the
columns, so we should be safe.

These days, we omit 0 insertions and 0 deletions, so I am not sure
what you should get for this case, though:

>  Makefile | 0
>  1 file changed, 0 insertions(+), 0 deletions(-)

Should we just say "1 file changed"?

  reply	other threads:[~2012-10-17 18:28 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-10-17 17:00 Fix "git diff --stat" for interesting - but empty - file changes Linus Torvalds
2012-10-17 18:28 ` Junio C Hamano [this message]
2012-10-17 19:35   ` Linus Torvalds

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

  List information: http://vger.kernel.org/majordomo-info.html

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

  git send-email \
    --in-reply-to=7v4nltoswd.fsf@alter.siamese.dyndns.org \
    --to=gitster@pobox.com \
    --cc=git@vger.kernel.org \
    --cc=torvalds@linux-foundation.org \
    /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.
Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

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 read-only IMAP folder(s) and NNTP newsgroup(s).