Re: Fix "git diff --stat" for interesting - but empty - file changes

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Linus Torvalds <torvalds@xxxxxxxxxxxxxxxxxxxx> 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@xxxxxxxxxxxxxxxxxxxx>
> ---
>
> 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"?

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]