* "git diff --stat" doesn't show added empty file
@ 2009-01-12 3:36 Ping Yin
2009-01-12 12:19 ` Johannes Schindelin
2009-01-12 16:13 ` Linus Torvalds
0 siblings, 2 replies; 6+ messages in thread
From: Ping Yin @ 2009-01-12 3:36 UTC (permalink / raw)
To: Git Mailing List
$ 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(-)
Ping Yin
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: "git diff --stat" doesn't show added empty file
2009-01-12 3:36 "git diff --stat" doesn't show added empty file Ping Yin
@ 2009-01-12 12:19 ` Johannes Schindelin
2009-01-12 15:41 ` Michael J Gruber
2009-01-12 16:13 ` Linus Torvalds
1 sibling, 1 reply; 6+ messages in thread
From: Johannes Schindelin @ 2009-01-12 12:19 UTC (permalink / raw)
To: Ping Yin; +Cc: Git Mailing List
Hi,
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.
Ciao,
Dscho
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: "git diff --stat" doesn't show added empty file
2009-01-12 12:19 ` Johannes Schindelin
@ 2009-01-12 15:41 ` Michael J Gruber
2009-01-13 11:27 ` Johannes Schindelin
0 siblings, 1 reply; 6+ messages in thread
From: Michael J Gruber @ 2009-01-12 15:41 UTC (permalink / raw)
To: Johannes Schindelin; +Cc: Ping Yin, Git Mailing List
Johannes Schindelin venit, vidit, dixit 01/12/09 13:19:
> Hi,
>
> 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, except for the " +" after 0,
but I don't know if that output is really better. Is the
addition/removal of an empty file a file change? It's certainly a change
of the containing dir, which git does not track. I don't see how to
distinguish addition from removal of an empty file at that point in the
code yet. This might be the "fun" part...
Michael
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: "git diff --stat" doesn't show added empty file
2009-01-12 3:36 "git diff --stat" doesn't show added empty file Ping Yin
2009-01-12 12:19 ` Johannes Schindelin
@ 2009-01-12 16:13 ` Linus Torvalds
2009-01-13 7:42 ` Ping Yin
1 sibling, 1 reply; 6+ messages in thread
From: Linus Torvalds @ 2009-01-12 16:13 UTC (permalink / raw)
To: Ping Yin; +Cc: Git Mailing List
On Mon, 12 Jan 2009, Ping Yin wrote:
> $ git diff --stat HEAD^..
> 0 files changed, 0 insertions(+), 0 deletions(-)
In the kernel, we use "git diff --stat --summary" for exactly this reason.
Well, not exactly.
The thing is, even if the file is _not_ empty, there's a huge difference
between "added 100 lines to an already-existing file" and "created a new
100-line file". Which is exactly what "--summary" adds.
And it sometimes even makes sense to show the summary without the
diffstat. If you're _only_ interested in create/delete/rename information,
you can do "git show --summary <cmit>". It won't give you line counts, but
it will give you information about any changes to filenames, eg in the
kernel archive, you could see an example of this with
git show -M --summary 95b482a8d31116f3f5c2a5089569393234d06385
where you have a combination of renames, creates and deletes.
So I think it's already better than what you ask for.
Linus
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: "git diff --stat" doesn't show added empty file
2009-01-12 16:13 ` Linus Torvalds
@ 2009-01-13 7:42 ` Ping Yin
0 siblings, 0 replies; 6+ messages in thread
From: Ping Yin @ 2009-01-13 7:42 UTC (permalink / raw)
To: Linus Torvalds; +Cc: Git Mailing List
On Tue, Jan 13, 2009 at 12:13 AM, Linus Torvalds
<torvalds@linux-foundation.org> wrote:
>
>
> On Mon, 12 Jan 2009, Ping Yin wrote:
>> $ git diff --stat HEAD^..
>> 0 files changed, 0 insertions(+), 0 deletions(-)
>
> In the kernel, we use "git diff --stat --summary" for exactly this reason.
>
> Well, not exactly.
>
> The thing is, even if the file is _not_ empty, there's a huge difference
> between "added 100 lines to an already-existing file" and "created a new
> 100-line file". Which is exactly what "--summary" adds.
>
> And it sometimes even makes sense to show the summary without the
> diffstat. If you're _only_ interested in create/delete/rename information,
> you can do "git show --summary <cmit>". It won't give you line counts, but
> it will give you information about any changes to filenames, eg in the
> kernel archive, you could see an example of this with
>
> git show -M --summary 95b482a8d31116f3f5c2a5089569393234d06385
>
> where you have a combination of renames, creates and deletes.
>
> So I think it's already better than what you ask for.
>
> Linus
>
Thanks. --summary works.
I just want to get all changed files. I think "git diff --name-status
A..B" should be better.
Ping Yin
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: "git diff --stat" doesn't show added empty file
2009-01-12 15:41 ` Michael J Gruber
@ 2009-01-13 11:27 ` Johannes Schindelin
0 siblings, 0 replies; 6+ messages in thread
From: Johannes Schindelin @ 2009-01-13 11:27 UTC (permalink / raw)
To: Michael J Gruber; +Cc: Ping Yin, Git Mailing List
Hi,
On Mon, 12 Jan 2009, Michael J Gruber wrote:
> 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
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2009-01-13 11:27 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-01-12 3:36 "git diff --stat" doesn't show added empty file Ping Yin
2009-01-12 12:19 ` Johannes Schindelin
2009-01-12 15:41 ` Michael J Gruber
2009-01-13 11:27 ` Johannes Schindelin
2009-01-12 16:13 ` Linus Torvalds
2009-01-13 7:42 ` Ping Yin
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).