git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: "git diff --stat" doesn't show added empty file

From
Johannes Schindelin <johannes.schindelin@gmx.de>
Date
Jan 13, 2009, 11:27 UTC
Message-ID
<alpine.DEB.1.00.0901131223010.3586@pacific.mpi-cbg.de>
In-Reply-To
<496B64BA.7000408@drmicha.warpmail.net>
Hi,
On Mon, 12 Jan 2009, Michael J Gruber wrote:
Show 20 quoted lines
> Johannes Schindelin venit, vidit, dixit 01/12/09 13:19:
> 
> > On Mon, 12 Jan 2009, Ping Yin wrote:
> > 
> >> $ git --version
> >> git version 1.6.1.9.g97c34
> >> $ mkdir test && cd test && git init && git commit --allow-empty -m
> >> "Initial commit"
> >> $ touch .gitignore && git add .gitignore && git commit -m "Add empty .gitignore"
> >> $ git diff --stat HEAD^..
> >>  0 files changed, 0 insertions(+), 0 deletions(-)
> >>
> >> May be the following is better?
> >>
> >>  .gitignore |    0 +
> >>  1 files changed, 0 insertions(+), 0 deletions(-)
> > 
> > Have fun coding that.
> 
> Removing 5 lines from diff.c does the job,
I can only think that you mean these lines:
                else if (!data->files[i]->is_renamed &&
                         (added + deleted == 0)) {
                        total_files--;
                        continue;
                }
However, they are also present in the initial stat code in d75f7952:
                } else if (added + deleted == 0) {
                        total_files--;
                        continue;
                }

Now, the fun part is finding out why this code is there. Are there unintended side effects? If so, are they still there? Or was it introduced due to an explicit request back then? Was it just sloppy?

Removing the 5 lines is not all you have to do, by _far_.

Lots of fun, Dscho

Previous: Michael J GruberNext: Linus Torvalds
Message 4 of 6 in “"git diff --stat" doesn't show added empty file”
  1. Ping YinJan 12, 2009
  2. Johannes SchindelinJan 12, 2009
  3. Michael J GruberJan 12, 2009
  4. Johannes SchindelinJan 13, 2009
  5. Linus TorvaldsJan 12, 2009
  6. Ping YinJan 13, 2009

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.