# diffstat witdth with one changed file

6 messages from 2012-05-21 to 2012-05-22. Participants: Nguyen Thai Ngoc Duy, Andreas Schwab, Junio C Hamano, Zbigniew Jędrzejewski-Szmek.
Thread: https://gitlist.dev/t/30580

## Nguyen Thai Ngoc Duy, 2012-05-21 15:52

Subject: diffstat witdth with one changed file
Message-ID: <CACsJy8BrqaLbtVp5uF3q2Jo63DPwtFACYw3_rPy8eyNK7VSWMw@mail.gmail.com>
URL: https://gitlist.dev/e/CACsJy8BrqaLbtVp5uF3q2Jo63DPwtFACYw3_rPy8eyNK7VSWMw%40mail.gmail.com

```
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, 2012-05-21 17:33

Subject: Re: diffstat witdth with one changed file
Message-ID: <m2obphcubh.fsf@igel.home>
URL: https://gitlist.dev/e/m2obphcubh.fsf%40igel.home
In-Reply-To: <CACsJy8BrqaLbtVp5uF3q2Jo63DPwtFACYw3_rPy8eyNK7VSWMw@mail.gmail.com>

```
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, 2012-05-21 22:20

Subject: Re: diffstat witdth with one changed file
Message-ID: <7vehqd6urj.fsf@alter.siamese.dyndns.org>
URL: https://gitlist.dev/e/7vehqd6urj.fsf%40alter.siamese.dyndns.org
In-Reply-To: <m2obphcubh.fsf@igel.home>

```
Andreas Schwab <schwab@linux-m68k.org> writes:

> 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, 2012-05-22 05:59

Subject: Re: diffstat witdth with one changed file
Message-ID: <4FBB2B4B.6030402@in.waw.pl>
URL: https://gitlist.dev/e/4FBB2B4B.6030402%40in.waw.pl
In-Reply-To: <CACsJy8BrqaLbtVp5uF3q2Jo63DPwtFACYw3_rPy8eyNK7VSWMw@mail.gmail.com>

```
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.

What output would you expect?

Zbyszek

```

## Nguyen Thai Ngoc Duy, 2012-05-22 12:50

Subject: Re: diffstat witdth with one changed file
Message-ID: <CACsJy8D1eMhyPm8b5D6vSuMDvebfX1hB2GUz82E8LeVhnWsqCQ@mail.gmail.com>
URL: https://gitlist.dev/e/CACsJy8D1eMhyPm8b5D6vSuMDvebfX1hB2GUz82E8LeVhnWsqCQ%40mail.gmail.com
In-Reply-To: <4FBB2B4B.6030402@in.waw.pl>

```
On Tue, May 22, 2012 at 12:59 PM, Zbigniew Jędrzejewski-Szmek
<zbyszek@in.waw.pl> wrote:
> 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, 2012-05-22 16:47

Subject: Re: diffstat witdth with one changed file
Message-ID: <4FBBC312.5000402@in.waw.pl>
URL: https://gitlist.dev/e/4FBBC312.5000402%40in.waw.pl
In-Reply-To: <CACsJy8D1eMhyPm8b5D6vSuMDvebfX1hB2GUz82E8LeVhnWsqCQ@mail.gmail.com>

```
On 05/22/2012 02:50 PM, Nguyen Thai Ngoc Duy wrote:
>> 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

```
