threads / discuss / 24668

git log --stat FILE

Subject: git log --stat FILE

## tl;dr

11 messages between Aug 8, 2010 and Aug 9, 2010.

replies: 10people: 6as markdown or json

Marcus Comstedt· Aug 8, 2010, 11:29 UTC · lore
Hi guys.

I'm probably just missing something here, but I've run across a rather annoying behavior of log.

When I do "git log --stat FILE", then only commits which touch FILE are displayed, as expected. However, contrary to expectation (well, my expectation at least), the stat shows that only one file (FILE) is modified by the commits, even if they actually modified multiple files. That's not what I wanted; I used FILE to select commits, not to control how they are presented. In fact, the information which is hidden is exactly that which I wanted to see; the whole reason for the --stat was that I wanted to know what _other_ files were modified together with FILE.

What's worse, I could not find how to circumvent this behavior, short of using

 git log --format=format:'%H' FILE | xargs git show --stat
which isn't especially convenient...
So, if this behavior is intentional, how can it be turned off?
  // Marcus
Jakub Narebski· Aug 8, 2010, 11:54 UTC · re: Marcus Comstedt · lore

Re: git log --stat FILE

Marcus Comstedt <marcus@mc.pp.se> writes:
Show 16 quoted lines
> Hi guys.
> 
> I'm probably just missing something here, but I've run across a rather
> annoying behavior of log.
> 
> When I do "git log --stat FILE", then only commits which touch FILE
> are displayed, as expected.  However, contrary to expectation (well,
> my expectation at least), the stat shows that only one file (FILE) is
> modified by the commits, even if they actually modified multiple files.
> That's not what I wanted; I used FILE to select commits, not to
> control how they are presented.  In fact, the information which is
> hidden is exactly that which I wanted to see; the whole reason for the
> --stat was that I wanted to know what _other_ files were modified
> together with FILE.
> 
> What's worse, I could not find how to circumvent this behavior, [...]
See --full-diff option to git-log.
-- 
Jakub Narebski
Poland
ShadeHawk on #git
Lars Hjemli· Aug 8, 2010, 11:54 UTC · re: Marcus Comstedt · lore

Re: git log --stat FILE

On Sun, Aug 8, 2010 at 13:29, Marcus Comstedt <marcus@mc.pp.se> wrote:
Show 5 quoted lines
> When I do "git log --stat FILE", then only commits which touch FILE
> are displayed, as expected.  However, contrary to expectation (well,
> my expectation at least), the stat shows that only one file (FILE) is
> modified by the commits, even if they actually modified multiple files.
> That's not what I wanted;
Try adding --full-diff to your `git log` incantation.

-- larsh

Marcus Comstedt· Aug 8, 2010, 12:04 UTC · re: Lars Hjemli · lore

Re: git log --stat FILE

Thanks guys.
I suspected there was some option I had missed.  :-)

Both the option name and the documentaion mention only diffs, not stats, which makes it a bit hard to find...

  // Marcus
Jakub Narebski· Aug 8, 2010, 12:26 UTC · re: Marcus Comstedt · lore

Re: git log --stat FILE

On Sun, 8 Aug 2010, Marcus Comstedt wrote:
Show 7 quoted lines
> 
> Thanks guys.
> 
> I suspected there was some option I had missed.  :-)
> 
> Both the option name and the documentaion mention only diffs, not
> stats, which makes it a bit hard to find...

Diffstat is just a diff format (a way of presenting diff); '--stat' is described in "Common _diff_ options" of git-log(1) manpage.

But whats obvoud to me might not be obvious to everyone.
-- 
Jakub Narebski
Poland
Marcus Comstedt· Aug 8, 2010, 12:35 UTC · re: Jakub Narebski · lore

Re: git log --stat FILE

Jakub Narebski <jnareb@gmail.com> writes:
> Diffstat is just a diff format (a way of presenting diff); '--stat'
> is described in "Common _diff_ options" of git-log(1) manpage.
>
> But whats obvoud to me might not be obvious to everyone.

To me (and probably many others), a "diff" is the output of the command "/usr/bin/diff". I notice that git seems to refer to this as a "patch" instead. Nevertheless, the documentation of --full-diff explicitly talks about "log -p", rather than "diffs" in general. So it's not clear from the documentation that it affects other types of diffs than those produced by -p ("patches").

  // Marcus
Jakub Narebski· Aug 8, 2010, 13:08 UTC · re: Marcus Comstedt · lore

Re: git log --stat FILE

Marcus Comstedt wrote:
Show 13 quoted lines
> Jakub Narebski <jnareb@gmail.com> writes:
> 
> > Diffstat is just a diff format (a way of presenting diff); '--stat'
> > is described in "Common _diff_ options" of git-log(1) manpage.
> >
> > But whats obvious to me might not be obvious to everyone.
> 
> To me (and probably many others), a "diff" is the output of the
> command "/usr/bin/diff".  I notice that git seems to refer to this as
> a "patch" instead.  Nevertheless, the documentation of --full-diff
> explicitly talks about "log -p", rather than "diffs" in general.  So
> it's not clear from the documentation that it affects other types of
> diffs than those produced by -p ("patches").

To me (and probably many others), a "diff" is something that describe differences between two versions (compares two version). Note that 'GNU diff' (and other "/usr/bin/diff") supports three output formats: ed based, context and unified formats. git-diff supports patch format (unified, with some extensions), raw aka diff-tree format, and various versions of diffstat format.

The '--full-diff' is a git-log option, not diff option, as it affects how git-log uses path limiter. "git log -p <path>..." is an example of copmmand that shows diffs with commits, as "git log <path>..." alone doesn't show diffs (in any format). But perhaps the description of '--full-diff' option could be improved.

The '--stat' is git-diff option, as you can see by running e.g. "git diff --stat HEAD^!"

-- 
Jakub Narebski
Poland
Marcus Comstedt· Aug 8, 2010, 13:33 UTC · re: Jakub Narebski · lore

Re: git log --stat FILE

Jakub Narebski <jnareb@gmail.com> writes:
> To me (and probably many others), a "diff" is something that describe
> differences between two versions (compares two version).

Jakub, there is no need for you to explain or justify why this is obvious to you. I have no problem accepting that at face value. I'm simply trying to explain why this was not obvious to me, in the hope of aiding any effort in improving the documentation. After all, writing documentation for something you feel is obvious is very difficult. But if you feel that the documentation is fine as it is, that is also your privilege.

> Note that 'GNU diff' (and other "/usr/bin/diff") supports three
> output formats:  ed based, context and unified formats.

Indeed, and all those qualify as "diffs" in my mindset. I would however not consider the output of "diff -q" as a true "diff", and naturally not the output of "diff --version".

  // Marcus
Michael J Gruber· Aug 8, 2010, 15:31 UTC · re: Marcus Comstedt · lore

[PATCH] Documentation/git-log: Clarify --full-diff

The current description gives the impression that "--full-diff" affects "log -p" only.

Make it clearer that it affects all diff-based output types.
Signed-off-by: Michael J Gruber <git@drmicha.warpmail.net>
---
 Documentation/git-log.txt |    3 +++
 1 files changed, 3 insertions(+), 0 deletions(-)
diff --git a/Documentation/git-log.txt b/Documentation/git-log.txt
index e970664..c213bdb 100644
--- a/Documentation/git-log.txt
+++ b/Documentation/git-log.txt
@@ -55,6 +55,9 @@ OPTIONS
 	paths.  With this, the full diff is shown for commits that touch
 	the specified paths; this means that "<path>..." limits only
 	commits, and doesn't limit diff for those commits.
++
+Note that this affects all diff-based output types, e.g. those
+produced by --stat etc.
 
 --log-size::
 	Before the log message print out its size in bytes. Intended
-- 
1.7.2.1.52.g7f7860
Matthieu Moy· Aug 9, 2010, 07:45 UTC · re: Michael J Gruber · lore

Re: [PATCH] Documentation/git-log: Clarify --full-diff

Michael J Gruber <git@drmicha.warpmail.net> writes:
Show 9 quoted lines
> --- a/Documentation/git-log.txt
> +++ b/Documentation/git-log.txt
> @@ -55,6 +55,9 @@ OPTIONS
>  	paths.  With this, the full diff is shown for commits that touch
>  	the specified paths; this means that "<path>..." limits only
>  	commits, and doesn't limit diff for those commits.
> ++
> +Note that this affects all diff-based output types, e.g. those
> +produced by --stat etc.
+1.
This also help people grepping for "--stat" to find "--full-diff".
-- 
Matthieu Moy
http://www-verimag.imag.fr/~moy/
Junio C Hamano· Aug 9, 2010, 19:57 UTC · re: Matthieu Moy · lore

Re: [PATCH] Documentation/git-log: Clarify --full-diff

Matthieu Moy <Matthieu.Moy@grenoble-inp.fr> writes:
Show 15 quoted lines
> Michael J Gruber <git@drmicha.warpmail.net> writes:
>
>> --- a/Documentation/git-log.txt
>> +++ b/Documentation/git-log.txt
>> @@ -55,6 +55,9 @@ OPTIONS
>>  	paths.  With this, the full diff is shown for commits that touch
>>  	the specified paths; this means that "<path>..." limits only
>>  	commits, and doesn't limit diff for those commits.
>> ++
>> +Note that this affects all diff-based output types, e.g. those
>> +produced by --stat etc.
>
> +1.
>
> This also help people grepping for "--stat" to find "--full-diff".

Yeah, I think this is a good change especially to help new people that come to git community every day.

Thanks.

← back to recent threads