Skip to contentSkip to conversation

git log --stat FILE

PATCH In review Marcus Comstedt 6 participants 11 messages Jun 15, 2016 Documentation

lore
Share & tools
lore
#0 lore raw

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

#1 lore raw
Quoted 5 lines · Marcus Comstedt

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

#2 lore raw

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

#3 lore raw
Quoted 7 lines · Marcus Comstedt

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.

Signature · 2 lines
Jakub Narebski
Poland
#4 lore raw
Quoted 4 lines · Jakub Narebski

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

#5 lore raw
Quoted 5 lines · Marcus Comstedt
Quoted 3 lines · Jakub Narebski

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

Quoted 8 lines
Quoted 1 line

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^!"

Signature · 2 lines
Jakub Narebski
Poland
#6 lore raw
Quoted 2 lines · Jakub Narebski

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.

Quoted 2 lines

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

#7 lore raw

PATCH 1/1 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.

---
 Documentation/git-log.txt |    3 +++
 1 files changed, 3 insertions(+), 0 deletions(-)
Documentation/git-log.txt +3 -0
index e970664..c213bdb 100644
@@ -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
Signature · 1 line
1.7.2.1.52.g7f7860
#8 lore raw

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

Documentation/git-log.txt OPTIONS · line 60

Quoted 9 lines · Michael J Gruber
Documentation/git-log.txt +3 -0
@@ -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".

Signature · 2 lines
Matthieu Moy
http://www-verimag.imag.fr/~moy/
#9 lore raw

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

Quoted 14 lines · Matthieu Moy

Documentation/git-log.txt OPTIONS · line 60

Quoted 9 lines · Michael J Gruber
Documentation/git-log.txt +3 -0
@@ -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.

Quoted 1 line

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.

#10 lore raw
In reply to Marcus Comstedt
Quoted 15 lines · Marcus Comstedt

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.

Quoted 1 line

What's worse, I could not find how to circumvent this behavior, [...]

See --full-diff option to git-log.

Signature · 3 lines
Jakub Narebski
Poland
ShadeHawk on #git