threads / discuss / 30580

diffstat witdth with one changed file

Subject: diffstat witdth with one changed file

## tl;dr

6 messages between May 21, 2012 and May 22, 2012.

replies: 5people: 4as markdown or json

Nguyen Thai Ngoc Duy· May 21, 2012, 15:52 UTC · lore
Hi,

With recent git, "git log --stat 90e6ef5", the first commit's diffstat uses full terminal width while the next one uses less than 80 chars. Both changes one file. Is it intentional? I tend to think it's a bug because with one-file changes, diffstat width is not important as we have no other files to compare with.

-- 
Duy
Andreas Schwab· May 21, 2012, 17:33 UTC · re: Nguyen Thai Ngoc Duy · lore

Re: diffstat witdth with one changed file

Nguyen Thai Ngoc Duy <pclouds@gmail.com> writes:
> With recent git, "git log --stat 90e6ef5", the first commit's diffstat
> uses full terminal width while the next one uses less than 80 chars.
> Both changes one file. Is it intentional?

In commit 0e641b1 the file has only 41 lines of changes, so it looks intentional.

Andreas.
-- 
Andreas Schwab, schwab@linux-m68k.org
GPG Key fingerprint = 58CA 54C7 6D53 942B 1756  01D3 44D5 214B 8276 4ED5
"And now for something completely different."
Junio C Hamano· May 21, 2012, 22:20 UTC · re: Andreas Schwab · lore

Re: diffstat witdth with one changed file

Andreas Schwab <schwab@linux-m68k.org> writes:
Show 8 quoted lines
> Nguyen Thai Ngoc Duy <pclouds@gmail.com> writes:
>
>> With recent git, "git log --stat 90e6ef5", the first commit's diffstat
>> uses full terminal width while the next one uses less than 80 chars.
>> Both changes one file. Is it intentional?
>
> In commit 0e641b1 the file has only 41 lines of changes, so it looks
> intentional.

Correct. We do not try to make width of bars from two different commits comparable [*1*], but we do try to make them comparable within a single commit; for a commit that changes only a single path, you still have adds and removals to compare. The overall length is ideally one + or - per line if the graph fits the output width, but if that makes the graph too wide, we scale to fit in the output width. So a change with 41 lines gets only 41 +/- and does not consume full 80-column terminal.

[Footnote]

*1* This is very much on purpose; otherwise it will hurt the perceived latency of the command.

Zbigniew Jędrzejewski-Szmek· May 22, 2012, 05:59 UTC · re: Nguyen Thai Ngoc Duy · lore

Re: diffstat witdth with one changed file

On 05/21/2012 05:52 PM, Nguyen Thai Ngoc Duy wrote:
Show 7 quoted lines
> Hi,
> 
> With recent git, "git log --stat 90e6ef5", the first commit's diffstat
> uses full terminal width while the next one uses less than 80 chars.
> Both changes one file. Is it intentional? I tend to think it's a bug
> because with one-file changes, diffstat width is not important as we
> have no other files to compare with.

Hi, 90e6ef5 makes 502 additions/deletions, so it scales the +- part to the whole available terminal width. 90e6ef5^ does only 41 additions, so it can display the +- part unscaled without even filling the terminal width.

Since we don't coordinate the diffstat width between different commits in the same git-log invocation, there's no way to make the diffstats use the same scale. Anyway, diffstat is only supposed to give a rough overview, and it does that here.

What output would you expect?
Zbyszek
Nguyen Thai Ngoc Duy· May 22, 2012, 12:50 UTC · re: Zbigniew Jędrzejewski-Szmek · lore

Re: diffstat witdth with one changed file

On Tue, May 22, 2012 at 12:59 PM, Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> wrote:

Show 17 quoted lines
> On 05/21/2012 05:52 PM, Nguyen Thai Ngoc Duy wrote:
>> Hi,
>>
>> With recent git, "git log --stat 90e6ef5", the first commit's diffstat
>> uses full terminal width while the next one uses less than 80 chars.
>> Both changes one file. Is it intentional? I tend to think it's a bug
>> because with one-file changes, diffstat width is not important as we
>> have no other files to compare with.
> Hi,
> 90e6ef5 makes 502 additions/deletions, so it scales the +- part to the
> whole available terminal width. 90e6ef5^ does only 41 additions, so it
> can display the +- part unscaled without even filling the terminal width.
>
> Since we don't coordinate the diffstat width between different commits
> in the same git-log invocation, there's no way to make the diffstats use
> the same scale. Anyway, diffstat is only supposed to give a rough
> overview, and it does that here.
Yeah, others have explained it. And it makes sense.
> What output would you expect?

It just looks weird that while most of the commits fill half of my screen (200 char width), some diffstats strike a line through the right edge. And I did not see the reason for that in the beginning because I thought long lines only makes sense when compare to other lines.

-- 
Duy
Zbigniew Jędrzejewski-Szmek· May 22, 2012, 16:47 UTC · re: Nguyen Thai Ngoc Duy · lore

Re: diffstat witdth with one changed file

On 05/22/2012 02:50 PM, Nguyen Thai Ngoc Duy wrote:
Show 13 quoted lines
>> On 05/21/2012 05:52 PM, Nguyen Thai Ngoc Duy wrote:
>>> Hi,
>>>
>>> With recent git, "git log --stat 90e6ef5", the first commit's diffstat
>>> uses full terminal width while the next one uses less than 80 chars.
>>> Both changes one file. Is it intentional? I tend to think it's a bug
>>> because with one-file changes, diffstat width is not important as we
>>> have no other files to compare with.
> It just looks weird that while most of the commits fill half of my
> screen (200 char width), some diffstats strike a line through the
> right edge. And I did not see the reason for that in the beginning
> because I thought long lines only makes sense when compare to other
> lines.

A side note: 'git diff --stat-graph-width=N' or 'git config diff.statGraphWidth N' can be used to limit the width of the graph part. I don't use it myself, but it could be useful if you have a really wide terminal.

Zbyszek

← back to recent threads