{"thread":{"id":"17108","subject":"\"git diff --stat\" doesn't show added empty file","startedAt":"2009-01-12T03:36:00Z","lastAt":"2009-01-13T11:27:22Z","messageCount":6,"participants":["Ping Yin","Johannes Schindelin","Michael J Gruber","Linus Torvalds"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"100064","messageId":"46dff0320901111936h6343e51fo94750d83e95743dc@mail.gmail.com","threadId":"17108","inReplyTo":null,"subject":"\"git diff --stat\" doesn't show added empty file","fromName":"Ping Yin","fromEmail":"pkufranky@gmail.com","sentAt":"2009-01-12T03:36:00Z","receivedAt":"2009-01-12T03:36:00Z","isPatch":false,"sender":{"key":"pkufranky@gmail.com","avatar":"https://avatars.githubusercontent.com/u/5346?v=4"},"body":"$ git --version\ngit version 1.6.1.9.g97c34\n$ mkdir test && cd test && git init && git commit --allow-empty -m\n\"Initial commit\"\n$ touch .gitignore && git add .gitignore && git commit -m \"Add empty .gitignore\"\n$ git diff --stat HEAD^..\n 0 files changed, 0 insertions(+), 0 deletions(-)\n\nMay be the following is better?\n\n .gitignore |    0 +\n 1 files changed, 0 insertions(+), 0 deletions(-)\n\nPing Yin\n"},{"id":"100112","messageId":"alpine.DEB.1.00.0901121319210.3586@pacific.mpi-cbg.de","threadId":"17108","inReplyTo":"46dff0320901111936h6343e51fo94750d83e95743dc@mail.gmail.com","subject":"Re: \"git diff --stat\" doesn't show added empty file","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2009-01-12T12:19:37Z","receivedAt":"2009-01-12T12:19:37Z","isPatch":false,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi,\n\nOn Mon, 12 Jan 2009, Ping Yin wrote:\n\n> $ git --version\n> git version 1.6.1.9.g97c34\n> $ mkdir test && cd test && git init && git commit --allow-empty -m\n> \"Initial commit\"\n> $ touch .gitignore && git add .gitignore && git commit -m \"Add empty .gitignore\"\n> $ git diff --stat HEAD^..\n>  0 files changed, 0 insertions(+), 0 deletions(-)\n> \n> May be the following is better?\n> \n>  .gitignore |    0 +\n>  1 files changed, 0 insertions(+), 0 deletions(-)\n\nHave fun coding that.\n\nCiao,\nDscho\n"},{"id":"100131","messageId":"496B64BA.7000408@drmicha.warpmail.net","threadId":"17108","inReplyTo":"alpine.DEB.1.00.0901121319210.3586@pacific.mpi-cbg.de","subject":"Re: \"git diff --stat\" doesn't show added empty file","fromName":"Michael J Gruber","fromEmail":"git@drmicha.warpmail.net","sentAt":"2009-01-12T15:41:46Z","receivedAt":"2009-01-12T15:41:46Z","isPatch":false,"sender":{"key":"git@grubix.eu","avatar":"https://avatars.githubusercontent.com/u/233215?v=4"},"body":"Johannes Schindelin venit, vidit, dixit 01/12/09 13:19:\n> Hi,\n> \n> On Mon, 12 Jan 2009, Ping Yin wrote:\n> \n>> $ git --version\n>> git version 1.6.1.9.g97c34\n>> $ mkdir test && cd test && git init && git commit --allow-empty -m\n>> \"Initial commit\"\n>> $ touch .gitignore && git add .gitignore && git commit -m \"Add empty .gitignore\"\n>> $ git diff --stat HEAD^..\n>>  0 files changed, 0 insertions(+), 0 deletions(-)\n>>\n>> May be the following is better?\n>>\n>>  .gitignore |    0 +\n>>  1 files changed, 0 insertions(+), 0 deletions(-)\n> \n> Have fun coding that.\n\nRemoving 5 lines from diff.c does the job, except for the \" +\" after 0,\nbut I don't know if that output is really better. Is the\naddition/removal of an empty file a file change? It's certainly a change\nof the containing dir, which git does not track. I don't see how to\ndistinguish addition from removal of an empty file at that point in the\ncode yet. This might be the \"fun\" part...\n\nMichael\n"},{"id":"100133","messageId":"alpine.LFD.2.00.0901120805310.6528@localhost.localdomain","threadId":"17108","inReplyTo":"46dff0320901111936h6343e51fo94750d83e95743dc@mail.gmail.com","subject":"Re: \"git diff --stat\" doesn't show added empty file","fromName":"Linus Torvalds","fromEmail":"torvalds@linux-foundation.org","sentAt":"2009-01-12T16:13:53Z","receivedAt":"2009-01-12T16:13:53Z","isPatch":false,"sender":{"key":"torvalds@linux-foundation.org","avatar":"https://avatars.githubusercontent.com/u/1024025?v=4"},"body":"\n\nOn Mon, 12 Jan 2009, Ping Yin wrote:\n> $ git diff --stat HEAD^..\n>  0 files changed, 0 insertions(+), 0 deletions(-)\n\nIn the kernel, we use \"git diff --stat --summary\" for exactly this reason.\n\nWell, not exactly. \n\nThe thing is, even if the file is _not_ empty, there's a huge difference \nbetween \"added 100 lines to an already-existing file\" and \"created a new \n100-line file\". Which is exactly what \"--summary\" adds. \n\nAnd it sometimes even makes sense to show the summary without the \ndiffstat. If you're _only_ interested in create/delete/rename information, \nyou can do \"git show --summary <cmit>\". It won't give you line counts, but \nit will give you information about any changes to filenames, eg in the \nkernel archive, you could see an example of this with\n\n\tgit show -M --summary 95b482a8d31116f3f5c2a5089569393234d06385\n\nwhere you have a combination of renames, creates and deletes.\n\nSo I think it's already better than what you ask for.\n\n\t\t\tLinus\n"},{"id":"100243","messageId":"46dff0320901122342q75e3e9e0gfe4e83bc7c60f193@mail.gmail.com","threadId":"17108","inReplyTo":"alpine.LFD.2.00.0901120805310.6528@localhost.localdomain","subject":"Re: \"git diff --stat\" doesn't show added empty file","fromName":"Ping Yin","fromEmail":"pkufranky@gmail.com","sentAt":"2009-01-13T07:42:22Z","receivedAt":"2009-01-13T07:42:22Z","isPatch":false,"sender":{"key":"pkufranky@gmail.com","avatar":"https://avatars.githubusercontent.com/u/5346?v=4"},"body":"On Tue, Jan 13, 2009 at 12:13 AM, Linus Torvalds\n<torvalds@linux-foundation.org> wrote:\n>\n>\n> On Mon, 12 Jan 2009, Ping Yin wrote:\n>> $ git diff --stat HEAD^..\n>>  0 files changed, 0 insertions(+), 0 deletions(-)\n>\n> In the kernel, we use \"git diff --stat --summary\" for exactly this reason.\n>\n> Well, not exactly.\n>\n> The thing is, even if the file is _not_ empty, there's a huge difference\n> between \"added 100 lines to an already-existing file\" and \"created a new\n> 100-line file\". Which is exactly what \"--summary\" adds.\n>\n> And it sometimes even makes sense to show the summary without the\n> diffstat. If you're _only_ interested in create/delete/rename information,\n> you can do \"git show --summary <cmit>\". It won't give you line counts, but\n> it will give you information about any changes to filenames, eg in the\n> kernel archive, you could see an example of this with\n>\n>        git show -M --summary 95b482a8d31116f3f5c2a5089569393234d06385\n>\n> where you have a combination of renames, creates and deletes.\n>\n> So I think it's already better than what you ask for.\n>\n>                        Linus\n>\n\nThanks. --summary works.\nI just want to get all changed files. I think \"git diff --name-status\nA..B\" should be better.\n\n\nPing Yin\n"},{"id":"100266","messageId":"alpine.DEB.1.00.0901131223010.3586@pacific.mpi-cbg.de","threadId":"17108","inReplyTo":"496B64BA.7000408@drmicha.warpmail.net","subject":"Re: \"git diff --stat\" doesn't show added empty file","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2009-01-13T11:27:22Z","receivedAt":"2009-01-13T11:27:22Z","isPatch":false,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi,\n\nOn Mon, 12 Jan 2009, Michael J Gruber wrote:\n\n> Johannes Schindelin venit, vidit, dixit 01/12/09 13:19:\n> \n> > On Mon, 12 Jan 2009, Ping Yin wrote:\n> > \n> >> $ git --version\n> >> git version 1.6.1.9.g97c34\n> >> $ mkdir test && cd test && git init && git commit --allow-empty -m\n> >> \"Initial commit\"\n> >> $ touch .gitignore && git add .gitignore && git commit -m \"Add empty .gitignore\"\n> >> $ git diff --stat HEAD^..\n> >>  0 files changed, 0 insertions(+), 0 deletions(-)\n> >>\n> >> May be the following is better?\n> >>\n> >>  .gitignore |    0 +\n> >>  1 files changed, 0 insertions(+), 0 deletions(-)\n> > \n> > Have fun coding that.\n> \n> Removing 5 lines from diff.c does the job,\n\nI can only think that you mean these lines:\n\n                else if (!data->files[i]->is_renamed &&\n                         (added + deleted == 0)) {\n                        total_files--;\n                        continue;\n                }\n\nHowever, they are also present in the initial stat code in d75f7952:\n\n                } else if (added + deleted == 0) {\n                        total_files--;\n                        continue;\n                }\n\nNow, the fun part is finding out why this code is there.  Are there \nunintended side effects?  If so, are they still there?  Or was it \nintroduced due to an explicit request back then?  Was it just sloppy?\n\nRemoving the 5 lines is not all you have to do, by _far_.\n\nLots of fun,\nDscho\n"}]}