All of lore.kernel.org
 help / color / mirror / Atom feed
* Incremental updates to What's cooking
@ 2012-02-28  6:53 Junio C Hamano
  2012-02-29  7:37 ` Zbigniew Jędrzejewski-Szmek
  0 siblings, 1 reply; 24+ messages in thread
From: Junio C Hamano @ 2012-02-28  6:53 UTC (permalink / raw)
  To: git
  Cc: Zbigniew Jędrzejewski-Szmek,
	Nguyễn Thái Ngọc Duy, René Scharfe,
	Jeff King, Clemens Buchacher, Jakub Narebski

It is a bit too much to keep sending the full report every night, so I'll
send out some highlights since issue #09 of this month for tonight.

Short term plans
----------------

Will merge to "master".
 + jb/required-filter                     02-17/02-26    #1
 + ph/cherry-pick-advice-refinement       02-22/02-26    #1
 + pj/completion-remote-set-url-branches  02-22/02-26    #2

Will merge to "next"
 - cn/maint-branch-with-bad               02-27          #1
 - jk/symbolic-ref-short                  02-27          #1

Will merge to "next", perhaps?
 - jn/gitweb-hilite-regions               02-26          #4
 - th/git-diffall                         02-27          #1


Notable topics that may need more discussion
--------------------------------------------

I will not list the stalled topics here and harrass owners of them here.

* zj/diff-stat-dyncol (2012-02-27) 11 commits
 - diff --stat: add config option to limit graph width
 - diff --stat: enable limiting of the graph part
 - diff --stat: add a test for output with COLUMNS=40
 - diff --stat: use a maximum of 5/8 for the filename part
 - merge --stat: use the full terminal width
 - log --stat: use the full terminal width
 - show --stat: use the full terminal width
 - diff --stat: use the full terminal width
 - diff --stat: tests for long filenames and big change counts
 - t4014: addtional format-patch test vectors
 - Merge branches zj/decimal-width, zj/term-columns and jc/diff-stat-scaler

I resurrected the additional tests for format-patch from an earlier round,
as it illustrates the behaviour change brought by "5/8 split" very well.

* nd/columns (2012-02-26) 11 commits
 - tag: add --column
 - column: support piping stdout to external git-column process
 - status: add --column
 - branch: add --column
 - help: reuse print_columns() for help -a
 - column: add column.ui for default column output settings
 - column: support columns with different widths
 - column: add columnar layout
 - Stop starting pager recursively
 - Add git-column and column mode parsing
 - column: add API to print items in columns

Comments by Ramsay on the parsing code seemed reasonable.

* cb/fsck-squelch-dangling (2012-02-26) 1 commit
 - fsck: do not print dangling objects by default

Introduces "fsck --dangling" and removes the output for dangling objects
from the default output.

The first patch to advance this topic should add --[no-]dangling option
and update the documentation to illustrate its use.  On top of that, if we
were to change the default not to show the dangling objects, deprecation
patches that span longer timeperiod need to be built, but the follow-on
patches and the default change may not be necessary, given that the
command is "fsck".

* rs/no-no-no-parseopt (2012-02-26) 3 commits
 - parse-options: remove PARSE_OPT_NEGHELP
 - parse-options: allow positivation of options starting, with no-
 - test-parse-options: convert to OPT_BOOL()

Options that use PARSE_OPT_NEGHELP needed to word their help text in
a strange way, and this gets rid of the uses of them.

I tend to agree with Peff that REVERSE_BOOL or NEGBIT based solution may
be more readable in the longer term. As the options that used the funny
NEGHELP are limited, the difference between two approaches may not matter
too much, but then that argues against fixing the funny help messages,
so...

^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: Incremental updates to What's cooking
  2012-02-28  6:53 Incremental updates to What's cooking Junio C Hamano
@ 2012-02-29  7:37 ` Zbigniew Jędrzejewski-Szmek
  2012-02-29  8:39   ` Junio C Hamano
  0 siblings, 1 reply; 24+ messages in thread
From: Zbigniew Jędrzejewski-Szmek @ 2012-02-29  7:37 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: git, Nguyễn Thái Ngọc Duy

On 02/28/2012 07:53 AM, Junio C Hamano wrote:

> * zj/diff-stat-dyncol (2012-02-27) 11 commits
>   - diff --stat: add config option to limit graph width
>   - diff --stat: enable limiting of the graph part
>   - diff --stat: add a test for output with COLUMNS=40
>   - diff --stat: use a maximum of 5/8 for the filename part
>   - merge --stat: use the full terminal width
>   - log --stat: use the full terminal width
>   - show --stat: use the full terminal width
>   - diff --stat: use the full terminal width
>   - diff --stat: tests for long filenames and big change counts
>   - t4014: addtional format-patch test vectors
>   - Merge branches zj/decimal-width, zj/term-columns and jc/diff-stat-scaler
>
> I resurrected the additional tests for format-patch from an earlier round,
> as it illustrates the behaviour change brought by "5/8 split" very well.
Hi,
the resurrected tests are partly duplicated in 4052-stat-output.sh:

t4014:
ok 75 - small change with long name gives more space to the name
ok 76 - a long name is given more room when the bar is short
ok 77 - format patch --stat-width=width works with long name        *
ok 78 - format patch --stat=...,name-width with long name           *
ok 79 - format patch --stat-name-width with long name               *
ok 81 - format patch graph part width                               *
ok 82 - format patch ignores COLUMNS                                *
ok 83 - format patch --stat=width with big change                   *
ok 84 - format patch --stat-width=width with big change             *
ok 85 - partition between long name and big change is more balanced

t4052:
ok 3 - format-patch graph width defaults to 80 columns
ok 4 - format-patch --stat=width with long name
ok 5 - format-patch --stat-width=width with long name
ok 6 - format-patch --stat=...,name-width with long name
ok 7 - format-patch --stat-name-width with long name
ok 24 - format-patch ignores too many COLUMNS (big change)
ok 28 - format-patch ignores not enough COLUMNS (big change)
ok 29 - format-patch ignores statGraphWidth config
ok 36 - format-patch --stat=width with big change
ok 37 - format-patch --stat-width=width with big change
ok 38 - format-patch --stat-graph--width with big change
ok 49 - format-patch --stat=width with big change and long name
ok 53 - format-patch ignores COLUMNS (long filename)

The ones with * are duplicated exactly. They tests run very fast, but 
maybe the duplicated ones should be culled.

Zbyszek

^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: Incremental updates to What's cooking
  2012-02-29  7:37 ` Zbigniew Jędrzejewski-Szmek
@ 2012-02-29  8:39   ` Junio C Hamano
  2012-02-29 13:50     ` Zbigniew Jędrzejewski-Szmek
  0 siblings, 1 reply; 24+ messages in thread
From: Junio C Hamano @ 2012-02-29  8:39 UTC (permalink / raw)
  To: Zbigniew Jędrzejewski-Szmek
  Cc: git, Nguyễn Thái Ngọc Duy

Zbigniew Jędrzejewski-Szmek  <zbyszek@in.waw.pl> writes:

> On 02/28/2012 07:53 AM, Junio C Hamano wrote:
>
>> * zj/diff-stat-dyncol (2012-02-27) 11 commits
>>   - diff --stat: add config option to limit graph width
>>   - diff --stat: enable limiting of the graph part
>>   - diff --stat: add a test for output with COLUMNS=40
>>   - diff --stat: use a maximum of 5/8 for the filename part
>>   - merge --stat: use the full terminal width
>>   - log --stat: use the full terminal width
>>   - show --stat: use the full terminal width
>>   - diff --stat: use the full terminal width
>>   - diff --stat: tests for long filenames and big change counts
>>   - t4014: addtional format-patch test vectors
>>   - Merge branches zj/decimal-width, zj/term-columns and jc/diff-stat-scaler
>>
>> I resurrected the additional tests for format-patch from an earlier round,
>> as it illustrates the behaviour change brought by "5/8 split" very well.
> Hi,
> the resurrected tests are partly duplicated in 4052-stat-output.sh:
>
> t4014:
> ok 75 - small change with long name gives more space to the name
> ok 76 - a long name is given more room when the bar is short
> ok 77 - format patch --stat-width=width works with long name        *
> ok 78 - format patch --stat=...,name-width with long name           *
> ok 79 - format patch --stat-name-width with long name               *
> ok 81 - format patch graph part width                               *
> ok 82 - format patch ignores COLUMNS                                *
> ok 83 - format patch --stat=width with big change                   *
> ok 84 - format patch --stat-width=width with big change             *
> ok 85 - partition between long name and big change is more balanced
>
> t4052:
> ok 3 - format-patch graph width defaults to 80 columns
> ok 4 - format-patch --stat=width with long name
> ok 5 - format-patch --stat-width=width with long name
> ok 6 - format-patch --stat=...,name-width with long name
> ok 7 - format-patch --stat-name-width with long name
> ok 24 - format-patch ignores too many COLUMNS (big change)
> ok 28 - format-patch ignores not enough COLUMNS (big change)
> ok 29 - format-patch ignores statGraphWidth config
> ok 36 - format-patch --stat=width with big change
> ok 37 - format-patch --stat-width=width with big change
> ok 38 - format-patch --stat-graph--width with big change
> ok 49 - format-patch --stat=width with big change and long name
> ok 53 - format-patch ignores COLUMNS (long filename)
>
> The ones with * are duplicated exactly. They tests run very fast, but
> maybe the duplicated ones should be culled.

Yeah, probably we should de-dup them.

Compare the behaviour change shown for t4052 and for t4014 by 119c07bf.
Which one more obviously show the effect of the code change to allow the
reader judge if the behaviour change is going in a good direction?

The style used in t4052 only changes expect_failure to expect_success, and
the reader has to accept the judgement of the person who wrote the test
vector and declared "this is the _right_ output!".  The way t4014, taken
from your earlier round, shows the behaviour change shows how the
expectation changes from the old behaviour to the new one, and the reader
can see and decide which one is giving a better output.

Actually, the whole reason I didn't notice duplicates in 4052 was because
of the above X-<.

If we remove duplicates, will 4052 become empty?  It would be really nice
if we do not have to add a new test script for this series, and instead
add necessary new tests to existing scripts.

^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: Incremental updates to What's cooking
  2012-02-29  8:39   ` Junio C Hamano
@ 2012-02-29 13:50     ` Zbigniew Jędrzejewski-Szmek
  2012-02-29 19:28       ` Junio C Hamano
  0 siblings, 1 reply; 24+ messages in thread
From: Zbigniew Jędrzejewski-Szmek @ 2012-02-29 13:50 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: git, Nguyễn Thái Ngọc Duy

On 02/29/2012 09:39 AM, Junio C Hamano wrote:
> Zbigniew Jędrzejewski-Szmek<zbyszek@in.waw.pl>  writes:
>
>> On 02/28/2012 07:53 AM, Junio C Hamano wrote:
>>
>>> * zj/diff-stat-dyncol (2012-02-27) 11 commits
>>>    - diff --stat: add config option to limit graph width
>>>    - diff --stat: enable limiting of the graph part
>>>    - diff --stat: add a test for output with COLUMNS=40
>>>    - diff --stat: use a maximum of 5/8 for the filename part
>>>    - merge --stat: use the full terminal width
>>>    - log --stat: use the full terminal width
>>>    - show --stat: use the full terminal width
>>>    - diff --stat: use the full terminal width
>>>    - diff --stat: tests for long filenames and big change counts
>>>    - t4014: addtional format-patch test vectors
>>>    - Merge branches zj/decimal-width, zj/term-columns and jc/diff-stat-scaler
>>>
>>> I resurrected the additional tests for format-patch from an earlier round,
>>> as it illustrates the behaviour change brought by "5/8 split" very well.
>> Hi,
>> the resurrected tests are partly duplicated in 4052-stat-output.sh:
>>
>> t4014:
>> ok 75 - small change with long name gives more space to the name
>> ok 76 - a long name is given more room when the bar is short
>> ok 77 - format patch --stat-width=width works with long name        *
>> ok 78 - format patch --stat=...,name-width with long name           *
>> ok 79 - format patch --stat-name-width with long name               *
>> ok 81 - format patch graph part width                               *
>> ok 82 - format patch ignores COLUMNS                                *
>> ok 83 - format patch --stat=width with big change                   *
>> ok 84 - format patch --stat-width=width with big change             *
>> ok 85 - partition between long name and big change is more balanced
>>
>> t4052:
>> ok 3 - format-patch graph width defaults to 80 columns
>> ok 4 - format-patch --stat=width with long name
>> ok 5 - format-patch --stat-width=width with long name
>> ok 6 - format-patch --stat=...,name-width with long name
>> ok 7 - format-patch --stat-name-width with long name
>> ok 24 - format-patch ignores too many COLUMNS (big change)
>> ok 28 - format-patch ignores not enough COLUMNS (big change)
>> ok 29 - format-patch ignores statGraphWidth config
>> ok 36 - format-patch --stat=width with big change
>> ok 37 - format-patch --stat-width=width with big change
>> ok 38 - format-patch --stat-graph--width with big change
>> ok 49 - format-patch --stat=width with big change and long name
>> ok 53 - format-patch ignores COLUMNS (long filename)
>>
>> The ones with * are duplicated exactly. They tests run very fast, but
>> maybe the duplicated ones should be culled.
>
> Yeah, probably we should de-dup them.
>
> Compare the behaviour change shown for t4052 and for t4014 by 119c07bf.
> Which one more obviously show the effect of the code change to allow the
> reader judge if the behaviour change is going in a good direction?
t4014 it seems, but mostly because of more descriptive test names.
But this is only true for the ones without *, I think. So the ones with 
* can be deleted without losing this advantage.

The ones with * are very similar in t4014 and t4052.

> The style used in t4052 only changes expect_failure to expect_success, and
> the reader has to accept the judgement of the person who wrote the test
> vector and declared "this is the _right_ output!".  The way t4014, taken
> from your earlier round, shows the behaviour change shows how the
> expectation changes from the old behaviour to the new one, and the reader
> can see and decide which one is giving a better output.
>
> Actually, the whole reason I didn't notice duplicates in 4052 was because
> of the above X-<.
>
> If we remove duplicates, will 4052 become empty?  It would be really nice
> if we do not have to add a new test script for this series, and instead
> add necessary new tests to existing scripts.
t4052 tests show, log, merge, diff and format-patch with basically the 
same commands. Separating the tests into different files would require 
duplicating a lot of setup code. OTOH, t4014 is only about format-patch, 
so the other ones don't fit. I thought it would be better to create a 
new file.

-
Zbyszek

^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: Incremental updates to What's cooking
  2012-02-29 13:50     ` Zbigniew Jędrzejewski-Szmek
@ 2012-02-29 19:28       ` Junio C Hamano
  2012-02-29 20:19         ` Zbigniew Jędrzejewski-Szmek
  0 siblings, 1 reply; 24+ messages in thread
From: Junio C Hamano @ 2012-02-29 19:28 UTC (permalink / raw)
  To: Zbigniew Jędrzejewski-Szmek
  Cc: git, Nguyễn Thái Ngọc Duy

Zbigniew Jędrzejewski-Szmek  <zbyszek@in.waw.pl> writes:

> t4052 tests show, log, merge, diff and format-patch with basically the
> same commands. Separating the tests into different files would require
> duplicating a lot of setup code. OTOH, t4014 is only about
> format-patch, so the other ones don't fit. I thought it would be
> better to create a new file.

OK, then perhaps we want to move the versions of duplicated one them from
4014 to 4052?

Thanks.

^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: Incremental updates to What's cooking
  2012-02-29 19:28       ` Junio C Hamano
@ 2012-02-29 20:19         ` Zbigniew Jędrzejewski-Szmek
  2012-02-29 20:48           ` Junio C Hamano
  0 siblings, 1 reply; 24+ messages in thread
From: Zbigniew Jędrzejewski-Szmek @ 2012-02-29 20:19 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: git, Nguyễn Thái Ngọc Duy

On 02/29/2012 08:28 PM, Junio C Hamano wrote:
> Zbigniew Jędrzejewski-Szmek<zbyszek@in.waw.pl>  writes:
>
>> t4052 tests show, log, merge, diff and format-patch with basically the
>> same commands. Separating the tests into different files would require
>> duplicating a lot of setup code. OTOH, t4014 is only about
>> format-patch, so the other ones don't fit. I thought it would be
>> better to create a new file.
>
> OK, then perhaps we want to move the versions of duplicated one them from
> 4014 to 4052?
Do you mean move a version of non-duplicated ones from t4014 to t4052 
and remove the duplicated ones?

Zbyszek

^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: Incremental updates to What's cooking
  2012-02-29 20:19         ` Zbigniew Jędrzejewski-Szmek
@ 2012-02-29 20:48           ` Junio C Hamano
  2012-03-01 12:26             ` [PATCH v7a 1/9] diff --stat: tests for long filenames and big change counts Zbigniew Jędrzejewski-Szmek
  0 siblings, 1 reply; 24+ messages in thread
From: Junio C Hamano @ 2012-02-29 20:48 UTC (permalink / raw)
  To: Zbigniew Jędrzejewski-Szmek
  Cc: git, Nguyễn Thái Ngọc Duy

Zbigniew Jędrzejewski-Szmek  <zbyszek@in.waw.pl> writes:

> Do you mean move a version of non-duplicated ones from t4014 to t4052
> and remove the duplicated ones?

Err, non-duplicated ones do not have anything to do with your series, no?
They are good copies you inherited from people who touched the file before
you, and we can leave the file in the state before this series.

Among the ones added to t4014, there are ones that have moral equivalent
in t4052.  These in t4052 are however less nice.  So I was suggesting to
replace these less nice ones in t4052 with their equivalents in t4014.
With such an update to t4052, the ones in t4014 that are duplicates in the
today's code can be removed, as we would have identical copies of them in
t4052.

^ permalink raw reply	[flat|nested] 24+ messages in thread

* [PATCH v7a 1/9] diff --stat: tests for long filenames and big change counts
  2012-02-29 20:48           ` Junio C Hamano
@ 2012-03-01 12:26             ` Zbigniew Jędrzejewski-Szmek
  2012-03-01 12:26               ` [PATCH v7a 2/9] diff --stat: use the full terminal width Zbigniew Jędrzejewski-Szmek
                                 ` (7 more replies)
  0 siblings, 8 replies; 24+ messages in thread
From: Zbigniew Jędrzejewski-Szmek @ 2012-03-01 12:26 UTC (permalink / raw)
  To: git, gitster; +Cc: pclouds, j.sixt, Zbigniew Jędrzejewski-Szmek

From: Junio C Hamano <gitster@pobox.com>

In preparation for updates to the "diff --stat" that updates the logic
to split the allotted columns into the name part and the graph part to
make the output more readable, add a handful of tests to document the
corner case behaviour in which long filenames and big changes are shown.

When a pathname is so long that it cannot fit on the column, the current
code truncates it to make sure that the graph part has enough room to show
a meaningful graph.  If the actual change is small (e.g. only one line
changed), this results in the final output that is shorter than the width
we aim for.

Signed-off-by: Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
---
v7a:

De-decuplicate new tests added in t4014 and t4052. Test descriptions
are taken from t4014, but the tests are all added in t4052.

This patch is a merge of 't4014: addtional format-patch test vectors'
from Junio C Hamano and v7 of my 'diff --stat: tests for long filenames
and big change counts'.

The rest of the series is only updated to apply cleanly after the changes
to tests.

[This patch series does not include the additional patches to minimize
the number of columns used for the change count number.]

 t/t4052-stat-output.sh |  182 ++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 182 insertions(+)
 create mode 100755 t/t4052-stat-output.sh

diff --git a/t/t4052-stat-output.sh b/t/t4052-stat-output.sh
new file mode 100755
index 0000000..f766c47
--- /dev/null
+++ b/t/t4052-stat-output.sh
@@ -0,0 +1,182 @@
+#!/bin/sh
+#
+# Copyright (c) 2012 Zbigniew Jędrzejewski-Szmek
+#
+
+test_description='test --stat output of various commands'
+
+. ./test-lib.sh
+. "$TEST_DIRECTORY"/lib-terminal.sh
+
+# 120 character name
+name=aaaaaaaaaa
+name=$name$name$name$name$name$name$name$name$name$name$name$name
+test_expect_success 'preparation' '
+	>"$name" &&
+	git add "$name" &&
+	git commit -m message &&
+	echo a >"$name" &&
+	git commit -m message "$name"
+'
+
+while read cmd args
+do
+	cat >expect <<-'EOF'
+	 ...aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa |    1 +
+	EOF
+	test_expect_success "$cmd: a short graph bar does not extend to the full width" '
+		git $cmd $args >output &&
+		grep " | " output >actual &&
+		test_cmp expect actual
+	'
+
+	cat >expect <<-'EOF'
+	 ...aaaaaaaaaaaaaaaaaaaaaa |    1 +
+	EOF
+	test_expect_success "$cmd --stat=width: name is chopped to leave room to the right of a short bar" '
+		git $cmd $args --stat=40 >output &&
+		grep " | " output >actual &&
+		test_cmp expect actual
+	'
+
+	test_expect_success "$cmd --stat-width=width with long name" '
+		git $cmd $args --stat-width=40 >output &&
+		grep " | " output >actual &&
+		test_cmp expect actual
+	'
+
+	cat >expect <<-'EOF'
+	 ...aaaaaaaaaaaaaaaaaaaaaaaaaaa |    1 +
+	EOF
+	test_expect_success "$cmd --stat=...,name-width with long name" '
+		git $cmd $args --stat=60,30 >output &&
+		grep " | " output >actual &&
+		test_cmp expect actual
+	'
+
+	test_expect_success "$cmd --stat-name-width with long name" '
+		git $cmd $args --stat-name-width=30 >output &&
+		grep " | " output >actual &&
+		test_cmp expect actual
+	'
+done <<\EOF
+format-patch -1 --stdout
+diff HEAD^ HEAD --stat
+show --stat
+log -1 --stat
+EOF
+
+
+test_expect_success 'preparation for big change tests' '
+	>abcd &&
+	git add abcd &&
+	git commit -m message &&
+	i=0 &&
+	while test $i -lt 1000
+	do
+		echo $i && i=$(($i + 1))
+	done >abcd &&
+	git commit -m message abcd
+'
+
+cat >expect80 <<'EOF'
+ abcd | 1000 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+EOF
+
+while read verb expect cmd args
+do
+	test_expect_success "$cmd $verb COLUMNS (big change)" '
+		COLUMNS=200 git $cmd $args >output
+		grep " | " output >actual &&
+		test_cmp "$expect" actual
+	'
+done <<\EOF
+ignores expect80 format-patch -1 --stdout
+ignores expect80 diff HEAD^ HEAD --stat
+ignores expect80 show --stat
+ignores expect80 log -1 --stat
+EOF
+
+cat >expect <<'EOF'
+ abcd | 1000 ++++++++++++++++++++++++++
+EOF
+while read cmd args
+do
+	test_expect_success "$cmd --stat=width with big change" '
+		git $cmd $args --stat=40 >output
+		grep " | " output >actual &&
+		test_cmp expect actual
+	'
+
+	test_expect_success "$cmd --stat-width=width with big change" '
+		git $cmd $args --stat-width=40 >output
+		grep " | " output >actual &&
+		test_cmp expect actual
+	'
+done <<\EOF
+format-patch -1 --stdout
+diff HEAD^ HEAD --stat
+show --stat
+log -1 --stat
+EOF
+
+test_expect_success 'preparation for long filename tests' '
+	cp abcd aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa &&
+	git add aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa &&
+	git commit -m message
+'
+
+cat >expect <<'EOF'
+ ...aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa | 1000 +++++
+EOF
+while read cmd args
+do
+	test_expect_success "$cmd --stat=width with big change and long name favors name part" '
+		git $cmd $args --stat-width=60 >output &&
+		grep " | " output >actual &&
+		test_cmp expect actual
+	'
+done <<\EOF
+format-patch -1 --stdout
+diff HEAD^ HEAD --stat
+show --stat
+log -1 --stat
+EOF
+
+cat >expect80 <<'EOF'
+ ...aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa | 1000 ++++++++++++++++++++
+EOF
+while read verb expect cmd args
+do
+	test_expect_success "$cmd $verb COLUMNS (long filename)" '
+		COLUMNS=200 git $cmd $args >output
+		grep " | " output >actual &&
+		test_cmp "$expect" actual
+	'
+done <<\EOF
+ignores expect80 format-patch -1 --stdout
+ignores expect80 diff HEAD^ HEAD --stat
+ignores expect80 show --stat
+ignores expect80 log -1 --stat
+EOF
+
+cat >expect <<'EOF'
+ abcd | 1000 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+EOF
+test_expect_success 'merge --stat ignores COLUMNS (big change)' '
+	git checkout -b branch HEAD^^ &&
+	COLUMNS=100 git merge --stat --no-ff master^ >output &&
+	grep " | " output >actual
+	test_cmp expect actual
+'
+
+cat >expect <<'EOF'
+ ...aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa | 1000 ++++++++++++++++++++
+EOF
+test_expect_success 'merge --stat ignores COLUMNS (long filename)' '
+	COLUMNS=100 git merge --stat --no-ff master >output &&
+	grep " | " output >actual
+	test_cmp expect actual
+'
+
+test_done
-- 
1.7.9.2.399.gdf4d.dirty

^ permalink raw reply related	[flat|nested] 24+ messages in thread

* [PATCH v7a 2/9] diff --stat: use the full terminal width
  2012-03-01 12:26             ` [PATCH v7a 1/9] diff --stat: tests for long filenames and big change counts Zbigniew Jędrzejewski-Szmek
@ 2012-03-01 12:26               ` Zbigniew Jędrzejewski-Szmek
  2012-03-01 12:26               ` [PATCH v7a 3/9] show " Zbigniew Jędrzejewski-Szmek
                                 ` (6 subsequent siblings)
  7 siblings, 0 replies; 24+ messages in thread
From: Zbigniew Jędrzejewski-Szmek @ 2012-03-01 12:26 UTC (permalink / raw)
  To: git, gitster; +Cc: pclouds, j.sixt, Zbigniew Jędrzejewski-Szmek

Default to the real terminal width for diff --stat output, instead
of the hard-coded 80 columns.

Some projects (especially in Java), have long filename paths, with
nested directories or long individual filenames. When files are
renamed, the filename part in stat output can be almost useless. If
the middle part between { and } is long (because the file was moved to
a completely different directory), then most of the path would be
truncated.

It makes sense to detect and use the full terminal width and display
full filenames if possible.

The are commands like diff, show, and log, which can adapt the output
to the terminal width. There are also commands like format-patch,
whose output should be independent of the terminal width. Since it is
safer to use the 80-column default, the real terminal width is only
used if requested by the calling code by setting diffopts.stat_width=-1.
Normally this value is 0, and can be set by the user only to a
non-negative value, so -1 is safe to use internally.

This patch only changes the diff builtin to use the full terminal width.

Signed-off-by: Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
---
 builtin/diff.c         |    3 +++
 diff.c                 |    5 ++++-
 t/t4052-stat-output.sh |   11 +++++++++--
 3 files changed, 16 insertions(+), 3 deletions(-)

diff --git a/builtin/diff.c b/builtin/diff.c
index 387afa7..81b6bae 100644
--- a/builtin/diff.c
+++ b/builtin/diff.c
@@ -285,6 +285,9 @@ int cmd_diff(int argc, const char **argv, const char *prefix)
 	/* Otherwise, we are doing the usual "git" diff */
 	rev.diffopt.skip_stat_unmatch = !!diff_auto_refresh_index;
 
+	/* Scale to real terminal size */
+	rev.diffopt.stat_width = -1;
+
 	/* Default to let external and textconv be used */
 	DIFF_OPT_SET(&rev.diffopt, ALLOW_EXTERNAL);
 	DIFF_OPT_SET(&rev.diffopt, ALLOW_TEXTCONV);
diff --git a/diff.c b/diff.c
index e0590a3..7478277 100644
--- a/diff.c
+++ b/diff.c
@@ -1343,7 +1343,10 @@ static void show_stats(struct diffstat_t *data, struct diff_options *options)
 		line_prefix = msg->buf;
 	}
 
-	width = options->stat_width ? options->stat_width : 80;
+	if (options->stat_width == -1)
+		width = term_columns();
+	else
+		width = options->stat_width ? options->stat_width : 80;
 	name_width = options->stat_name_width ? options->stat_name_width : 50;
 	count = options->stat_count ? options->stat_count : data->nr;
 
diff --git a/t/t4052-stat-output.sh b/t/t4052-stat-output.sh
index f766c47..29c06e5 100755
--- a/t/t4052-stat-output.sh
+++ b/t/t4052-stat-output.sh
@@ -83,6 +83,10 @@ cat >expect80 <<'EOF'
  abcd | 1000 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 EOF
 
+cat >expect200 <<'EOF'
+ abcd | 1000 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+EOF
+
 while read verb expect cmd args
 do
 	test_expect_success "$cmd $verb COLUMNS (big change)" '
@@ -92,7 +96,7 @@ do
 	'
 done <<\EOF
 ignores expect80 format-patch -1 --stdout
-ignores expect80 diff HEAD^ HEAD --stat
+respects expect200 diff HEAD^ HEAD --stat
 ignores expect80 show --stat
 ignores expect80 log -1 --stat
 EOF
@@ -146,6 +150,9 @@ EOF
 cat >expect80 <<'EOF'
  ...aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa | 1000 ++++++++++++++++++++
 EOF
+cat >expect200 <<'EOF'
+ ...aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa | 1000 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+EOF
 while read verb expect cmd args
 do
 	test_expect_success "$cmd $verb COLUMNS (long filename)" '
@@ -155,7 +162,7 @@ do
 	'
 done <<\EOF
 ignores expect80 format-patch -1 --stdout
-ignores expect80 diff HEAD^ HEAD --stat
+respects expect200 diff HEAD^ HEAD --stat
 ignores expect80 show --stat
 ignores expect80 log -1 --stat
 EOF
-- 
1.7.9.2.399.gdf4d.dirty

^ permalink raw reply related	[flat|nested] 24+ messages in thread

* [PATCH v7a 3/9] show --stat: use the full terminal width
  2012-03-01 12:26             ` [PATCH v7a 1/9] diff --stat: tests for long filenames and big change counts Zbigniew Jędrzejewski-Szmek
  2012-03-01 12:26               ` [PATCH v7a 2/9] diff --stat: use the full terminal width Zbigniew Jędrzejewski-Szmek
@ 2012-03-01 12:26               ` Zbigniew Jędrzejewski-Szmek
  2012-03-01 12:26               ` [PATCH v7a 4/9] log " Zbigniew Jędrzejewski-Szmek
                                 ` (5 subsequent siblings)
  7 siblings, 0 replies; 24+ messages in thread
From: Zbigniew Jędrzejewski-Szmek @ 2012-03-01 12:26 UTC (permalink / raw)
  To: git, gitster; +Cc: pclouds, j.sixt, Zbigniew Jędrzejewski-Szmek

Make show --stat behave like diff --stat and use the full terminal
width.

Signed-off-by: Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
---
 builtin/log.c          |    2 ++
 t/t4052-stat-output.sh |    4 ++--
 2 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/builtin/log.c b/builtin/log.c
index 7d1f6f8..d37ae26 100644
--- a/builtin/log.c
+++ b/builtin/log.c
@@ -447,6 +447,8 @@ int cmd_show(int argc, const char **argv, const char *prefix)
 	rev.diff = 1;
 	rev.always_show_header = 1;
 	rev.no_walk = 1;
+	rev.diffopt.stat_width = -1; 	/* Scale to real terminal size */
+
 	memset(&opt, 0, sizeof(opt));
 	opt.def = "HEAD";
 	opt.tweak = show_rev_tweak_rev;
diff --git a/t/t4052-stat-output.sh b/t/t4052-stat-output.sh
index 29c06e5..56d3899 100755
--- a/t/t4052-stat-output.sh
+++ b/t/t4052-stat-output.sh
@@ -97,7 +97,7 @@ do
 done <<\EOF
 ignores expect80 format-patch -1 --stdout
 respects expect200 diff HEAD^ HEAD --stat
-ignores expect80 show --stat
+respects expect200 show --stat
 ignores expect80 log -1 --stat
 EOF
 
@@ -163,7 +163,7 @@ do
 done <<\EOF
 ignores expect80 format-patch -1 --stdout
 respects expect200 diff HEAD^ HEAD --stat
-ignores expect80 show --stat
+respects expect200 show --stat
 ignores expect80 log -1 --stat
 EOF
 
-- 
1.7.9.2.399.gdf4d.dirty

^ permalink raw reply related	[flat|nested] 24+ messages in thread

* [PATCH v7a 4/9] log --stat: use the full terminal width
  2012-03-01 12:26             ` [PATCH v7a 1/9] diff --stat: tests for long filenames and big change counts Zbigniew Jędrzejewski-Szmek
  2012-03-01 12:26               ` [PATCH v7a 2/9] diff --stat: use the full terminal width Zbigniew Jędrzejewski-Szmek
  2012-03-01 12:26               ` [PATCH v7a 3/9] show " Zbigniew Jędrzejewski-Szmek
@ 2012-03-01 12:26               ` Zbigniew Jędrzejewski-Szmek
  2012-03-01 12:26               ` [PATCH v7a 5/9] merge " Zbigniew Jędrzejewski-Szmek
                                 ` (4 subsequent siblings)
  7 siblings, 0 replies; 24+ messages in thread
From: Zbigniew Jędrzejewski-Szmek @ 2012-03-01 12:26 UTC (permalink / raw)
  To: git, gitster; +Cc: pclouds, j.sixt, Zbigniew Jędrzejewski-Szmek

Make log --stat behave like diff --stat and use the full terminal
width.

Signed-off-by: Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
---
 builtin/log.c          |    1 +
 t/t4052-stat-output.sh |    4 ++--
 2 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/builtin/log.c b/builtin/log.c
index d37ae26..075a427 100644
--- a/builtin/log.c
+++ b/builtin/log.c
@@ -77,6 +77,7 @@ static void cmd_log_init_defaults(struct rev_info *rev)
 		get_commit_format(fmt_pretty, rev);
 	rev->verbose_header = 1;
 	DIFF_OPT_SET(&rev->diffopt, RECURSIVE);
+	rev->diffopt.stat_width = -1; /* use full terminal width */
 	rev->abbrev_commit = default_abbrev_commit;
 	rev->show_root_diff = default_show_root;
 	rev->subject_prefix = fmt_patch_subject_prefix;
diff --git a/t/t4052-stat-output.sh b/t/t4052-stat-output.sh
index 56d3899..f81d427 100755
--- a/t/t4052-stat-output.sh
+++ b/t/t4052-stat-output.sh
@@ -98,7 +98,7 @@ done <<\EOF
 ignores expect80 format-patch -1 --stdout
 respects expect200 diff HEAD^ HEAD --stat
 respects expect200 show --stat
-ignores expect80 log -1 --stat
+respects expect200 log -1 --stat
 EOF
 
 cat >expect <<'EOF'
@@ -164,7 +164,7 @@ done <<\EOF
 ignores expect80 format-patch -1 --stdout
 respects expect200 diff HEAD^ HEAD --stat
 respects expect200 show --stat
-ignores expect80 log -1 --stat
+respects expect200 log -1 --stat
 EOF
 
 cat >expect <<'EOF'
-- 
1.7.9.2.399.gdf4d.dirty

^ permalink raw reply related	[flat|nested] 24+ messages in thread

* [PATCH v7a 5/9] merge --stat: use the full terminal width
  2012-03-01 12:26             ` [PATCH v7a 1/9] diff --stat: tests for long filenames and big change counts Zbigniew Jędrzejewski-Szmek
                                 ` (2 preceding siblings ...)
  2012-03-01 12:26               ` [PATCH v7a 4/9] log " Zbigniew Jędrzejewski-Szmek
@ 2012-03-01 12:26               ` Zbigniew Jędrzejewski-Szmek
  2012-03-01 12:26               ` [PATCH v7a 6/9] diff --stat: use a maximum of 5/8 for the filename part Zbigniew Jędrzejewski-Szmek
                                 ` (3 subsequent siblings)
  7 siblings, 0 replies; 24+ messages in thread
From: Zbigniew Jędrzejewski-Szmek @ 2012-03-01 12:26 UTC (permalink / raw)
  To: git, gitster; +Cc: pclouds, j.sixt, Zbigniew Jędrzejewski-Szmek

Make merge --stat behave like diff --stat and use the full terminal
width.

Signed-off-by: Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
---
 builtin/merge.c        |    1 +
 t/t4052-stat-output.sh |    8 ++++----
 2 files changed, 5 insertions(+), 4 deletions(-)

diff --git a/builtin/merge.c b/builtin/merge.c
index b4fbc60..b1cd90c 100644
--- a/builtin/merge.c
+++ b/builtin/merge.c
@@ -399,6 +399,7 @@ static void finish(struct commit *head_commit,
 	if (new_head && show_diffstat) {
 		struct diff_options opts;
 		diff_setup(&opts);
+		opts.stat_width = -1; /* use full terminal width */
 		opts.output_format |=
 			DIFF_FORMAT_SUMMARY | DIFF_FORMAT_DIFFSTAT;
 		opts.detect_rename = DIFF_DETECT_RENAME;
diff --git a/t/t4052-stat-output.sh b/t/t4052-stat-output.sh
index f81d427..954c16f 100755
--- a/t/t4052-stat-output.sh
+++ b/t/t4052-stat-output.sh
@@ -168,9 +168,9 @@ respects expect200 log -1 --stat
 EOF
 
 cat >expect <<'EOF'
- abcd | 1000 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+ abcd | 1000 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 EOF
-test_expect_success 'merge --stat ignores COLUMNS (big change)' '
+test_expect_success 'merge --stat respects COLUMNS (big change)' '
 	git checkout -b branch HEAD^^ &&
 	COLUMNS=100 git merge --stat --no-ff master^ >output &&
 	grep " | " output >actual
@@ -178,9 +178,9 @@ test_expect_success 'merge --stat ignores COLUMNS (big change)' '
 '
 
 cat >expect <<'EOF'
- ...aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa | 1000 ++++++++++++++++++++
+ ...aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa | 1000 ++++++++++++++++++++++++++++++++++++++++
 EOF
-test_expect_success 'merge --stat ignores COLUMNS (long filename)' '
+test_expect_success 'merge --stat respects COLUMNS (long filename)' '
 	COLUMNS=100 git merge --stat --no-ff master >output &&
 	grep " | " output >actual
 	test_cmp expect actual
-- 
1.7.9.2.399.gdf4d.dirty

^ permalink raw reply related	[flat|nested] 24+ messages in thread

* [PATCH v7a 6/9] diff --stat: use a maximum of 5/8 for the filename part
  2012-03-01 12:26             ` [PATCH v7a 1/9] diff --stat: tests for long filenames and big change counts Zbigniew Jędrzejewski-Szmek
                                 ` (3 preceding siblings ...)
  2012-03-01 12:26               ` [PATCH v7a 5/9] merge " Zbigniew Jędrzejewski-Szmek
@ 2012-03-01 12:26               ` Zbigniew Jędrzejewski-Szmek
  2012-03-01 17:18                 ` Junio C Hamano
  2012-03-26 23:45                 ` Jeff King
  2012-03-01 12:26               ` [PATCH v7a 7/9] diff --stat: add a test for output with COLUMNS=40 Zbigniew Jędrzejewski-Szmek
                                 ` (2 subsequent siblings)
  7 siblings, 2 replies; 24+ messages in thread
From: Zbigniew Jędrzejewski-Szmek @ 2012-03-01 12:26 UTC (permalink / raw)
  To: git, gitster; +Cc: pclouds, j.sixt, Zbigniew Jędrzejewski-Szmek

The way that available columns are divided between the filename part
and the graph part is modified to use as many columns as necessary for
the filenames and the rest for the graph.

If there isn't enough columns to print both the filename and the
graph, at least 5/8 of available space is devoted to filenames. On a
standard 80 column terminal, or if not connected to a terminal and
using the default of 80 columns, this gives the same partition as
before.

The effect of this change is visible in the patch to the test vector
in t4014; with a small change with long filename, it stops truncating
the name part too short, and also allocates a bit more columns to the
graph for larger changes.  t4052 shows a similar change.

Signed-off-by: Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
---
 Documentation/diff-options.txt |   14 ++++---
 diff.c                         |   90 ++++++++++++++++++++++++++--------------
 t/t4052-stat-output.sh         |   16 +++----
 3 files changed, 76 insertions(+), 44 deletions(-)

diff --git a/Documentation/diff-options.txt b/Documentation/diff-options.txt
index 9f7cba2..6b9408f 100644
--- a/Documentation/diff-options.txt
+++ b/Documentation/diff-options.txt
@@ -53,13 +53,15 @@ endif::git-format-patch[]
 	Generate a diff using the "patience diff" algorithm.
 
 --stat[=<width>[,<name-width>[,<count>]]]::
-	Generate a diffstat.  You can override the default
-	output width for 80-column terminal by `--stat=<width>`.
-	The width of the filename part can be controlled by
-	giving another width to it separated by a comma.
+	Generate a diffstat. By default, as much space as necessary
+	will be used for the filename part, and the rest for
+	the graph part. Maximum width defaults to terminal width,
+	or 80 columns if not connected to a terminal, and can be
+	overriden by `<width>`. The width of the filename part can be
+	limited by giving another width `<name-width>` after a comma.
 	By giving a third parameter `<count>`, you can limit the
-	output to the first `<count>` lines, followed by
-	`...` if there are more.
+	output to the first `<count>` lines, followed by `...` if
+	there are more.
 +
 These parameters can also be set individually with `--stat-width=<width>`,
 `--stat-name-width=<name-width>` and `--stat-count=<count>`.
diff --git a/diff.c b/diff.c
index 7478277..1656310 100644
--- a/diff.c
+++ b/diff.c
@@ -1329,7 +1329,7 @@ static void show_stats(struct diffstat_t *data, struct diff_options *options)
 	int i, len, add, del, adds = 0, dels = 0;
 	uintmax_t max_change = 0, max_len = 0;
 	int total_files = data->nr;
-	int width, name_width, count;
+	int width, name_width, graph_width, number_width = 4, count;
 	const char *reset, *add_c, *del_c;
 	const char *line_prefix = "";
 	int extra_shown = 0;
@@ -1343,28 +1343,15 @@ static void show_stats(struct diffstat_t *data, struct diff_options *options)
 		line_prefix = msg->buf;
 	}
 
-	if (options->stat_width == -1)
-		width = term_columns();
-	else
-		width = options->stat_width ? options->stat_width : 80;
-	name_width = options->stat_name_width ? options->stat_name_width : 50;
 	count = options->stat_count ? options->stat_count : data->nr;
 
-	/* Sanity: give at least 5 columns to the graph,
-	 * but leave at least 10 columns for the name.
-	 */
-	if (width < 25)
-		width = 25;
-	if (name_width < 10)
-		name_width = 10;
-	else if (width < name_width + 15)
-		name_width = width - 15;
-
-	/* Find the longest filename and max number of changes */
 	reset = diff_get_color_opt(options, DIFF_RESET);
 	add_c = diff_get_color_opt(options, DIFF_FILE_NEW);
 	del_c = diff_get_color_opt(options, DIFF_FILE_OLD);
 
+	/*
+	 * Find the longest filename and max number of changes
+	 */
 	for (i = 0; (i < count) && (i < data->nr); i++) {
 		struct diffstat_file *file = data->files[i];
 		uintmax_t change = file->added + file->deleted;
@@ -1385,19 +1372,62 @@ static void show_stats(struct diffstat_t *data, struct diff_options *options)
 	}
 	count = i; /* min(count, data->nr) */
 
-	/* Compute the width of the graph part;
-	 * 10 is for one blank at the beginning of the line plus
-	 * " | count " between the name and the graph.
+	/*
+	 * We have width = stat_width or term_columns() columns total.
+	 * We want a maximum of min(max_len, stat_name_width) for the name part.
+	 * We also need 1 for " " and 4 + decimal_width(max_change)
+	 * for " | NNNN " and one the empty column at the end, altogether
+	 * 6 + decimal_width(max_change).
+	 *
+	 * If there's not enough space, we will use the smaller of
+	 * stat_name_width (if set) and 5/8*width for the filename,
+	 * and the rest for constant elements + graph part.
+	 * (5/8 gives 50 for filename and 30 for the constant parts + graph
+	 * for the standard terminal size).
 	 *
-	 * From here on, name_width is the width of the name area,
-	 * and width is the width of the graph area.
+	 * In other words: stat_width limits the maximum width, and
+	 * stat_name_width fixes the maximum width of the filename,
+	 * and is also used to divide available columns if there
+	 * aren't enough.
 	 */
-	name_width = (name_width < max_len) ? name_width : max_len;
-	if (width < (name_width + 10) + max_change)
-		width = width - (name_width + 10);
+
+	if (options->stat_width == -1)
+		width = term_columns();
 	else
-		width = max_change;
+		width = options->stat_width ? options->stat_width : 80;
 
+	/*
+	 * Guarantee 3/8*16==6 for the graph part
+	 * and 5/8*16==10 for the filename part
+	 */
+	if (width < 16 + 6 + number_width)
+		width = 16 + 6 + number_width;
+
+	/*
+	 * First assign sizes that are wanted, ignoring available width.
+	 */
+	graph_width = max_change;
+	name_width = (options->stat_name_width > 0 &&
+		      options->stat_name_width < max_len) ?
+		options->stat_name_width : max_len;
+
+	/*
+	 * Adjust adjustable widths not to exceed maximum width
+	 */
+	if (name_width + number_width + 6 + graph_width > width) {
+		if (graph_width > width * 3/8 - number_width - 6)
+			graph_width = width * 3/8 - number_width - 6;
+		if (name_width > width - number_width - 6 - graph_width)
+			name_width = width - number_width - 6 - graph_width;
+		else
+			graph_width = width - number_width - 6 - name_width;
+	}
+
+	/*
+	 * From here name_width is the width of the name area,
+	 * and graph_width is the width of the graph area.
+	 * max_change is used to scale graph properly.
+	 */
 	for (i = 0; i < count; i++) {
 		const char *prefix = "";
 		char *name = data->files[i]->print_name;
@@ -1453,18 +1483,18 @@ static void show_stats(struct diffstat_t *data, struct diff_options *options)
 		adds += add;
 		dels += del;
 
-		if (width <= max_change) {
+		if (graph_width <= max_change) {
 			int total = add + del;
 
-			total = scale_linear(add + del, width, max_change);
+			total = scale_linear(add + del, graph_width, max_change);
 			if (total < 2 && add && del)
 				/* width >= 2 due to the sanity check */
 				total = 2;
 			if (add < del) {
-				add = scale_linear(add, width, max_change);
+				add = scale_linear(add, graph_width, max_change);
 				del = total - add;
 			} else {
-				del = scale_linear(del, width, max_change);
+				del = scale_linear(del, graph_width, max_change);
 				add = total - del;
 			}
 		}
diff --git a/t/t4052-stat-output.sh b/t/t4052-stat-output.sh
index 954c16f..d0ed0dc 100755
--- a/t/t4052-stat-output.sh
+++ b/t/t4052-stat-output.sh
@@ -22,18 +22,18 @@ test_expect_success 'preparation' '
 while read cmd args
 do
 	cat >expect <<-'EOF'
-	 ...aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa |    1 +
+	 ...aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa |    1 +
 	EOF
-	test_expect_success "$cmd: a short graph bar does not extend to the full width" '
+	test_expect_success "$cmd: small change with long name gives more space to the name" '
 		git $cmd $args >output &&
 		grep " | " output >actual &&
 		test_cmp expect actual
 	'
 
 	cat >expect <<-'EOF'
-	 ...aaaaaaaaaaaaaaaaaaaaaa |    1 +
+	 ...aaaaaaaaaaaaaaaaaaaaaaaaaa |    1 +
 	EOF
-	test_expect_success "$cmd --stat=width: name is chopped to leave room to the right of a short bar" '
+	test_expect_success "$cmd --stat=width: a long name is given more room when the bar is short" '
 		git $cmd $args --stat=40 >output &&
 		grep " | " output >actual &&
 		test_cmp expect actual
@@ -131,11 +131,11 @@ test_expect_success 'preparation for long filename tests' '
 '
 
 cat >expect <<'EOF'
- ...aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa | 1000 +++++
+ ...aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa | 1000 ++++++++++++
 EOF
 while read cmd args
 do
-	test_expect_success "$cmd --stat=width with big change and long name favors name part" '
+	test_expect_success "$cmd --stat=width with big change is more balanced" '
 		git $cmd $args --stat-width=60 >output &&
 		grep " | " output >actual &&
 		test_cmp expect actual
@@ -151,7 +151,7 @@ cat >expect80 <<'EOF'
  ...aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa | 1000 ++++++++++++++++++++
 EOF
 cat >expect200 <<'EOF'
- ...aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa | 1000 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+ aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa | 1000 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 EOF
 while read verb expect cmd args
 do
@@ -178,7 +178,7 @@ test_expect_success 'merge --stat respects COLUMNS (big change)' '
 '
 
 cat >expect <<'EOF'
- ...aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa | 1000 ++++++++++++++++++++++++++++++++++++++++
+ aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa | 1000 +++++++++++++++++++++++++++++++++++++++
 EOF
 test_expect_success 'merge --stat respects COLUMNS (long filename)' '
 	COLUMNS=100 git merge --stat --no-ff master >output &&
-- 
1.7.9.2.399.gdf4d.dirty

^ permalink raw reply related	[flat|nested] 24+ messages in thread

* [PATCH v7a 7/9] diff --stat: add a test for output with COLUMNS=40
  2012-03-01 12:26             ` [PATCH v7a 1/9] diff --stat: tests for long filenames and big change counts Zbigniew Jędrzejewski-Szmek
                                 ` (4 preceding siblings ...)
  2012-03-01 12:26               ` [PATCH v7a 6/9] diff --stat: use a maximum of 5/8 for the filename part Zbigniew Jędrzejewski-Szmek
@ 2012-03-01 12:26               ` Zbigniew Jędrzejewski-Szmek
  2012-03-01 12:26               ` [PATCH v7a 8/9] diff --stat: enable limiting of the graph part Zbigniew Jędrzejewski-Szmek
  2012-03-01 12:26               ` [PATCH v7a 9/9] diff --stat: add config option to limit graph width Zbigniew Jędrzejewski-Szmek
  7 siblings, 0 replies; 24+ messages in thread
From: Zbigniew Jędrzejewski-Szmek @ 2012-03-01 12:26 UTC (permalink / raw)
  To: git, gitster; +Cc: pclouds, j.sixt, Zbigniew Jędrzejewski-Szmek

In preparation for the introduction on the limit of the width of the
graph part, a new test with COLUMNS=40 is added to check that the
environment variable influences diff, show, log, but not format-patch.
A new test is added because limiting the graph part makes COLUMNS=200
stop influencing diff --stat behaviour, which isn't wide enough now.
The old test with COLUMNS=200 is retained to check for regressions.

Signed-off-by: Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
---
 t/t4052-stat-output.sh |   19 +++++++++++++++++++
 1 file changed, 19 insertions(+)

diff --git a/t/t4052-stat-output.sh b/t/t4052-stat-output.sh
index d0ed0dc..9a8f62d 100755
--- a/t/t4052-stat-output.sh
+++ b/t/t4052-stat-output.sh
@@ -101,6 +101,25 @@ respects expect200 show --stat
 respects expect200 log -1 --stat
 EOF
 
+cat >expect40 <<'EOF'
+ abcd | 1000 ++++++++++++++++++++++++++
+EOF
+
+while read verb expect cmd args
+do
+	test_expect_success "$cmd $verb not enough COLUMNS (big change)" '
+		COLUMNS=40 git $cmd $args >output
+		grep " | " output >actual &&
+		test_cmp "$expect" actual
+	'
+done <<\EOF
+ignores expect80 format-patch -1 --stdout
+respects expect40 diff HEAD^ HEAD --stat
+respects expect40 show --stat
+respects expect40 log -1 --stat
+EOF
+
+
 cat >expect <<'EOF'
  abcd | 1000 ++++++++++++++++++++++++++
 EOF
-- 
1.7.9.2.399.gdf4d.dirty

^ permalink raw reply related	[flat|nested] 24+ messages in thread

* [PATCH v7a 8/9] diff --stat: enable limiting of the graph part
  2012-03-01 12:26             ` [PATCH v7a 1/9] diff --stat: tests for long filenames and big change counts Zbigniew Jędrzejewski-Szmek
                                 ` (5 preceding siblings ...)
  2012-03-01 12:26               ` [PATCH v7a 7/9] diff --stat: add a test for output with COLUMNS=40 Zbigniew Jędrzejewski-Szmek
@ 2012-03-01 12:26               ` Zbigniew Jędrzejewski-Szmek
  2012-03-01 12:26               ` [PATCH v7a 9/9] diff --stat: add config option to limit graph width Zbigniew Jędrzejewski-Szmek
  7 siblings, 0 replies; 24+ messages in thread
From: Zbigniew Jędrzejewski-Szmek @ 2012-03-01 12:26 UTC (permalink / raw)
  To: git, gitster; +Cc: pclouds, j.sixt, Zbigniew Jędrzejewski-Szmek

A new option --stat-graph-width=<width> can be used to limit the width
of the graph part even is more space is available. Up to <width>
columns will be used for the graph.

If commits changing a lot of lines are displayed in a wide terminal
window (200 or more columns), and the +- graph uses the full width,
the output can be hard to comfortably scan with a horizontal movement
of human eyes. Messages wrapped to about 80 columns would be
interspersed with very long +- lines. It makes sense to limit the
width of the graph part to a fixed value (e.g. 70 columns), even if
more columns are available.

Signed-off-by: Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
---
 Documentation/diff-options.txt |    2 ++
 diff.c                         |   23 +++++++++++++++++++++--
 diff.h                         |    1 +
 t/t4052-stat-output.sh         |    6 ++++++
 4 files changed, 30 insertions(+), 2 deletions(-)

diff --git a/Documentation/diff-options.txt b/Documentation/diff-options.txt
index 6b9408f..d34efd5 100644
--- a/Documentation/diff-options.txt
+++ b/Documentation/diff-options.txt
@@ -59,6 +59,8 @@ endif::git-format-patch[]
 	or 80 columns if not connected to a terminal, and can be
 	overriden by `<width>`. The width of the filename part can be
 	limited by giving another width `<name-width>` after a comma.
+	The width of the graph part can be limited by using
+	`--stat-graph-width=<width>`.
 	By giving a third parameter `<count>`, you can limit the
 	output to the first `<count>` lines, followed by `...` if
 	there are more.
diff --git a/diff.c b/diff.c
index 1656310..8f2abc8 100644
--- a/diff.c
+++ b/diff.c
@@ -1375,13 +1375,15 @@ static void show_stats(struct diffstat_t *data, struct diff_options *options)
 	/*
 	 * We have width = stat_width or term_columns() columns total.
 	 * We want a maximum of min(max_len, stat_name_width) for the name part.
+	 * We want a maximum of min(max_change, stat_graph_width) for the +- part.
 	 * We also need 1 for " " and 4 + decimal_width(max_change)
 	 * for " | NNNN " and one the empty column at the end, altogether
 	 * 6 + decimal_width(max_change).
 	 *
 	 * If there's not enough space, we will use the smaller of
 	 * stat_name_width (if set) and 5/8*width for the filename,
-	 * and the rest for constant elements + graph part.
+	 * and the rest for constant elements + graph part, but no more
+	 * than stat_graph_width for the graph part.
 	 * (5/8 gives 50 for filename and 30 for the constant parts + graph
 	 * for the standard terminal size).
 	 *
@@ -1406,7 +1408,9 @@ static void show_stats(struct diffstat_t *data, struct diff_options *options)
 	/*
 	 * First assign sizes that are wanted, ignoring available width.
 	 */
-	graph_width = max_change;
+	graph_width = (options->stat_graph_width &&
+		       options->stat_graph_width < max_change) ?
+		options->stat_graph_width : max_change;
 	name_width = (options->stat_name_width > 0 &&
 		      options->stat_name_width < max_len) ?
 		options->stat_name_width : max_len;
@@ -1417,6 +1421,9 @@ static void show_stats(struct diffstat_t *data, struct diff_options *options)
 	if (name_width + number_width + 6 + graph_width > width) {
 		if (graph_width > width * 3/8 - number_width - 6)
 			graph_width = width * 3/8 - number_width - 6;
+		if (options->stat_graph_width &&
+		    graph_width > options->stat_graph_width)
+			graph_width = options->stat_graph_width;
 		if (name_width > width - number_width - 6 - graph_width)
 			name_width = width - number_width - 6 - graph_width;
 		else
@@ -3289,6 +3296,7 @@ static int stat_opt(struct diff_options *options, const char **av)
 	char *end;
 	int width = options->stat_width;
 	int name_width = options->stat_name_width;
+	int graph_width = options->stat_graph_width;
 	int count = options->stat_count;
 	int argcount = 1;
 
@@ -3317,6 +3325,16 @@ static int stat_opt(struct diff_options *options, const char **av)
 				name_width = strtoul(av[1], &end, 10);
 				argcount = 2;
 			}
+		} else if (!prefixcmp(arg, "-graph-width")) {
+			arg += strlen("-graph-width");
+			if (*arg == '=')
+				graph_width = strtoul(arg + 1, &end, 10);
+			else if (!*arg && !av[1])
+				die("Option '--stat-graph-width' requires a value");
+			else if (!*arg) {
+				graph_width = strtoul(av[1], &end, 10);
+				argcount = 2;
+			}
 		} else if (!prefixcmp(arg, "-count")) {
 			arg += strlen("-count");
 			if (*arg == '=')
@@ -3342,6 +3360,7 @@ static int stat_opt(struct diff_options *options, const char **av)
 		return 0;
 	options->output_format |= DIFF_FORMAT_DIFFSTAT;
 	options->stat_name_width = name_width;
+	options->stat_graph_width = graph_width;
 	options->stat_width = width;
 	options->stat_count = count;
 	return argcount;
diff --git a/diff.h b/diff.h
index ae71f4c..2021a1d 100644
--- a/diff.h
+++ b/diff.h
@@ -129,6 +129,7 @@ struct diff_options {
 
 	int stat_width;
 	int stat_name_width;
+	int stat_graph_width;
 	int stat_count;
 	const char *word_regex;
 	enum diff_words_type word_diff;
diff --git a/t/t4052-stat-output.sh b/t/t4052-stat-output.sh
index 9a8f62d..3d823af 100755
--- a/t/t4052-stat-output.sh
+++ b/t/t4052-stat-output.sh
@@ -136,6 +136,12 @@ do
 		grep " | " output >actual &&
 		test_cmp expect actual
 	'
+
+	test_expect_success "$cmd --stat-graph--width with big change" '
+		git $cmd $args --stat-graph-width=26 >output
+		grep " | " output >actual &&
+		test_cmp expect actual
+	'
 done <<\EOF
 format-patch -1 --stdout
 diff HEAD^ HEAD --stat
-- 
1.7.9.2.399.gdf4d.dirty

^ permalink raw reply related	[flat|nested] 24+ messages in thread

* [PATCH v7a 9/9] diff --stat: add config option to limit graph width
  2012-03-01 12:26             ` [PATCH v7a 1/9] diff --stat: tests for long filenames and big change counts Zbigniew Jędrzejewski-Szmek
                                 ` (6 preceding siblings ...)
  2012-03-01 12:26               ` [PATCH v7a 8/9] diff --stat: enable limiting of the graph part Zbigniew Jędrzejewski-Szmek
@ 2012-03-01 12:26               ` Zbigniew Jędrzejewski-Szmek
  7 siblings, 0 replies; 24+ messages in thread
From: Zbigniew Jędrzejewski-Szmek @ 2012-03-01 12:26 UTC (permalink / raw)
  To: git, gitster; +Cc: pclouds, j.sixt, Zbigniew Jędrzejewski-Szmek

Config option diff.statGraphWidth=<width> is equivalent to
--stat-graph-width=<width>, except that the config option is ignored
by format-patch.

For the graph-width limiting to be usable, it should happen
'automatically' once configured, hence the config option.
Nevertheless, graph width limiting only makes sense when used on a
wide terminal, so it should not influence the output of format-patch,
which adheres to the 80-column standard.

Signed-off-by: Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
---
 Documentation/diff-config.txt          |    4 ++++
 Documentation/diff-options.txt         |   16 +++++++++-------
 builtin/diff.c                         |    3 ++-
 builtin/log.c                          |    1 +
 builtin/merge.c                        |    1 +
 contrib/completion/git-completion.bash |    1 +
 diff.c                                 |    8 ++++++++
 t/t4052-stat-output.sh                 |    6 ++++++
 8 files changed, 32 insertions(+), 8 deletions(-)

diff --git a/Documentation/diff-config.txt b/Documentation/diff-config.txt
index 1aed79e..6aa1be0 100644
--- a/Documentation/diff-config.txt
+++ b/Documentation/diff-config.txt
@@ -52,6 +52,10 @@ directories with less than 10% of the total amount of changed files,
 and accumulating child directory counts in the parent directories:
 `files,10,cumulative`.
 
+diff.statGraphWidth::
+	Limit the width of the graph part in --stat output. If set, applies
+	to all commands generating --stat outuput except format-patch.
+
 diff.external::
 	If this config variable is set, diff generation is not
 	performed using the internal diff machinery, but using the
diff --git a/Documentation/diff-options.txt b/Documentation/diff-options.txt
index d34efd5..87f0a5f 100644
--- a/Documentation/diff-options.txt
+++ b/Documentation/diff-options.txt
@@ -54,13 +54,15 @@ endif::git-format-patch[]
 
 --stat[=<width>[,<name-width>[,<count>]]]::
 	Generate a diffstat. By default, as much space as necessary
-	will be used for the filename part, and the rest for
-	the graph part. Maximum width defaults to terminal width,
-	or 80 columns if not connected to a terminal, and can be
-	overriden by `<width>`. The width of the filename part can be
-	limited by giving another width `<name-width>` after a comma.
-	The width of the graph part can be limited by using
-	`--stat-graph-width=<width>`.
+	will be used for the filename part, and the rest for the graph
+	part. Maximum width defaults to terminal width, or 80 columns
+	if not connected to a terminal, and can be overriden by
+	`<width>`. The width of the filename part can be limited by
+	giving another width `<name-width>` after a comma. The width
+	of the graph part can be limited by using
+	`--stat-graph-width=<width>` (affects all commands generating
+	a stat graph) or by setting `diff.statGraphWidth=<width>`
+	(does not affect `git format-patch`).
 	By giving a third parameter `<count>`, you can limit the
 	output to the first `<count>` lines, followed by `...` if
 	there are more.
diff --git a/builtin/diff.c b/builtin/diff.c
index 81b6bae..424c815 100644
--- a/builtin/diff.c
+++ b/builtin/diff.c
@@ -285,8 +285,9 @@ int cmd_diff(int argc, const char **argv, const char *prefix)
 	/* Otherwise, we are doing the usual "git" diff */
 	rev.diffopt.skip_stat_unmatch = !!diff_auto_refresh_index;
 
-	/* Scale to real terminal size */
+	/* Scale to real terminal size and respect statGraphWidth config */
 	rev.diffopt.stat_width = -1;
+	rev.diffopt.stat_graph_width = -1;
 
 	/* Default to let external and textconv be used */
 	DIFF_OPT_SET(&rev.diffopt, ALLOW_EXTERNAL);
diff --git a/builtin/log.c b/builtin/log.c
index 075a427..8a47012 100644
--- a/builtin/log.c
+++ b/builtin/log.c
@@ -78,6 +78,7 @@ static void cmd_log_init_defaults(struct rev_info *rev)
 	rev->verbose_header = 1;
 	DIFF_OPT_SET(&rev->diffopt, RECURSIVE);
 	rev->diffopt.stat_width = -1; /* use full terminal width */
+	rev->diffopt.stat_graph_width = -1; /* respect statGraphWidth config */
 	rev->abbrev_commit = default_abbrev_commit;
 	rev->show_root_diff = default_show_root;
 	rev->subject_prefix = fmt_patch_subject_prefix;
diff --git a/builtin/merge.c b/builtin/merge.c
index b1cd90c..34a5034 100644
--- a/builtin/merge.c
+++ b/builtin/merge.c
@@ -400,6 +400,7 @@ static void finish(struct commit *head_commit,
 		struct diff_options opts;
 		diff_setup(&opts);
 		opts.stat_width = -1; /* use full terminal width */
+		opts.stat_graph_width = -1; /* respect statGraphWidth config */
 		opts.output_format |=
 			DIFF_FORMAT_SUMMARY | DIFF_FORMAT_DIFFSTAT;
 		opts.detect_rename = DIFF_DETECT_RENAME;
diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash
index 78be195..bacf403 100755
--- a/contrib/completion/git-completion.bash
+++ b/contrib/completion/git-completion.bash
@@ -2118,6 +2118,7 @@ _git_config ()
 		core.whitespace
 		core.worktree
 		diff.autorefreshindex
+		diff.statGraphWidth
 		diff.external
 		diff.ignoreSubmodules
 		diff.mnemonicprefix
diff --git a/diff.c b/diff.c
index 8f2abc8..4525cda 100644
--- a/diff.c
+++ b/diff.c
@@ -31,6 +31,7 @@ static const char *external_diff_cmd_cfg;
 int diff_auto_refresh_index = 1;
 static int diff_mnemonic_prefix;
 static int diff_no_prefix;
+static int diff_stat_graph_width;
 static int diff_dirstat_permille_default = 30;
 static struct diff_options default_diff_options;
 
@@ -156,6 +157,10 @@ int git_diff_ui_config(const char *var, const char *value, void *cb)
 		diff_no_prefix = git_config_bool(var, value);
 		return 0;
 	}
+	if (!strcmp(var, "diff.statgraphwidth")) {
+		diff_stat_graph_width = git_config_int(var, value);
+		return 0;
+	}
 	if (!strcmp(var, "diff.external"))
 		return git_config_string(&external_diff_cmd_cfg, var, value);
 	if (!strcmp(var, "diff.wordregex"))
@@ -1398,6 +1403,9 @@ static void show_stats(struct diffstat_t *data, struct diff_options *options)
 	else
 		width = options->stat_width ? options->stat_width : 80;
 
+	if (options->stat_graph_width == -1)
+		options->stat_graph_width = diff_stat_graph_width;
+
 	/*
 	 * Guarantee 3/8*16==6 for the graph part
 	 * and 5/8*16==10 for the filename part
diff --git a/t/t4052-stat-output.sh b/t/t4052-stat-output.sh
index 3d823af..328aa8f 100755
--- a/t/t4052-stat-output.sh
+++ b/t/t4052-stat-output.sh
@@ -112,6 +112,12 @@ do
 		grep " | " output >actual &&
 		test_cmp "$expect" actual
 	'
+
+	test_expect_success "$cmd $verb statGraphWidth config" '
+		git -c diff.statGraphWidth=26 $cmd $args >output
+		grep " | " output >actual &&
+		test_cmp "$expect" actual
+	'
 done <<\EOF
 ignores expect80 format-patch -1 --stdout
 respects expect40 diff HEAD^ HEAD --stat
-- 
1.7.9.2.399.gdf4d.dirty

^ permalink raw reply related	[flat|nested] 24+ messages in thread

* Re: [PATCH v7a 6/9] diff --stat: use a maximum of 5/8 for the filename part
  2012-03-01 12:26               ` [PATCH v7a 6/9] diff --stat: use a maximum of 5/8 for the filename part Zbigniew Jędrzejewski-Szmek
@ 2012-03-01 17:18                 ` Junio C Hamano
  2012-03-26 23:45                 ` Jeff King
  1 sibling, 0 replies; 24+ messages in thread
From: Junio C Hamano @ 2012-03-01 17:18 UTC (permalink / raw)
  To: Zbigniew Jędrzejewski-Szmek; +Cc: git, pclouds, j.sixt

Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> writes:

> The effect of this change is visible in the patch to the test vector
> in t4014; with a small change with long filename, it stops truncating
> the name part too short, and also allocates a bit more columns to the
> graph for larger changes.  t4052 shows a similar change.

I replaced 4014 with 4052 in the first sentence, and dropped the last
sentence and re-queued the whole series.

Thanks for cleaning it up.  Very much appreciated.

^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: [PATCH v7a 6/9] diff --stat: use a maximum of 5/8 for the filename part
  2012-03-01 12:26               ` [PATCH v7a 6/9] diff --stat: use a maximum of 5/8 for the filename part Zbigniew Jędrzejewski-Szmek
  2012-03-01 17:18                 ` Junio C Hamano
@ 2012-03-26 23:45                 ` Jeff King
  2012-03-27  5:10                   ` [PATCH] t4052: unset $COLUMNS inherited from environment Zbigniew Jędrzejewski-Szmek
  1 sibling, 1 reply; 24+ messages in thread
From: Jeff King @ 2012-03-26 23:45 UTC (permalink / raw)
  To: Zbigniew Jędrzejewski-Szmek; +Cc: git, gitster, pclouds, j.sixt

On Thu, Mar 01, 2012 at 01:26:43PM +0100, Zbigniew Jędrzejewski-Szmek wrote:

> ---
>  Documentation/diff-options.txt |   14 ++++---
>  diff.c                         |   90 ++++++++++++++++++++++++++--------------
>  t/t4052-stat-output.sh         |   16 +++----
>  3 files changed, 76 insertions(+), 44 deletions(-)

I am seeing test failures from t4052 in 'master'. Bisecting points to
1b058bc (diff --stat: use a maximum of 5/8 for the filename part,
2012-03-01). The output from the test script looks like this:

--- expect      2012-03-26 23:41:29.688039554 +0000
+++ actual      2012-03-26 23:41:29.696039549 +0000
@@ -1 +1 @@
- ...aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa |    1 +
+ ...aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa |    1 +
not ok - 8 diff: small change with long name gives more space to the name
#       
#                       git $cmd $args >output &&
#                       grep " | " output >actual &&
#                       test_cmp expect actual
#               

There are a few other failures, but they all have the same mismatched
length (the output is slightly longer than expected). I know Junio won't
push out a 'master' that doesn't pass the tests for him, so I'm
wondering if some environment information like the terminal width is
leaking through the test scripts.

I haven't actually investigated any further yet, but I thought I'd first
see if anything obvious occurs to you.

-Peff

^ permalink raw reply	[flat|nested] 24+ messages in thread

* [PATCH] t4052: unset $COLUMNS inherited from environment
  2012-03-26 23:45                 ` Jeff King
@ 2012-03-27  5:10                   ` Zbigniew Jędrzejewski-Szmek
  2012-03-27  5:17                     ` Jeff King
  2012-03-27  5:32                     ` [PATCH] t4052: unset $COLUMNS " Johannes Sixt
  0 siblings, 2 replies; 24+ messages in thread
From: Zbigniew Jędrzejewski-Szmek @ 2012-03-27  5:10 UTC (permalink / raw)
  To: git, gitster, peff
  Cc: Michael J Gruber, pclouds, j.sixt, Zbigniew Jędrzejewski-Szmek

$COLUMNS must be unset to not interfere with the tests. The tests
already ignore the terminal size because output is redirected to a
file, but $COLUMNS overrides terminal size detection and changes the
test output away from the standard 80 even if not on a terminal.

Reported-by: Jeff King <peff@peff.net>
Signed-off-by: Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
---
Stupid omission. Please apply.

 t/t4052-stat-output.sh |    1 +
 1 file changed, 1 insertion(+)

diff --git a/t/t4052-stat-output.sh b/t/t4052-stat-output.sh
index 328aa8f..1f47f1d 100755
--- a/t/t4052-stat-output.sh
+++ b/t/t4052-stat-output.sh
@@ -17,6 +17,7 @@ test_expect_success 'preparation' '
 	git commit -m message &&
 	echo a >"$name" &&
 	git commit -m message "$name"
+	sane_unset COLUMNS
 '
 
 while read cmd args
-- 
1.7.10.rc1.222.gc0040.dirty

^ permalink raw reply related	[flat|nested] 24+ messages in thread

* Re: [PATCH] t4052: unset $COLUMNS inherited from environment
  2012-03-27  5:10                   ` [PATCH] t4052: unset $COLUMNS inherited from environment Zbigniew Jędrzejewski-Szmek
@ 2012-03-27  5:17                     ` Jeff King
  2012-03-27  6:22                       ` [PATCH v2] tests: unset COLUMNS " Zbigniew Jędrzejewski-Szmek
  2012-03-27  5:32                     ` [PATCH] t4052: unset $COLUMNS " Johannes Sixt
  1 sibling, 1 reply; 24+ messages in thread
From: Jeff King @ 2012-03-27  5:17 UTC (permalink / raw)
  To: Zbigniew Jędrzejewski-Szmek
  Cc: git, gitster, Michael J Gruber, pclouds, j.sixt

On Tue, Mar 27, 2012 at 07:10:03AM +0200, Zbigniew Jędrzejewski-Szmek wrote:

> $COLUMNS must be unset to not interfere with the tests. The tests
> already ignore the terminal size because output is redirected to a
> file, but $COLUMNS overrides terminal size detection and changes the
> test output away from the standard 80 even if not on a terminal.
> 
> Reported-by: Jeff King <peff@peff.net>
> Signed-off-by: Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
> ---
> Stupid omission. Please apply.

Thanks. I had a feeling it was something like this, but when I went to
test again, I couldn't reproduce! It seems that COLUMNS is not exported
by default, but somehow I must have exported it accidentally.

> diff --git a/t/t4052-stat-output.sh b/t/t4052-stat-output.sh
> index 328aa8f..1f47f1d 100755
> --- a/t/t4052-stat-output.sh
> +++ b/t/t4052-stat-output.sh
> @@ -17,6 +17,7 @@ test_expect_success 'preparation' '
>  	git commit -m message &&
>  	echo a >"$name" &&
>  	git commit -m message "$name"
> +	sane_unset COLUMNS
>  '

Should we perhaps just unset it in test-lib.sh, along with the other
variables that cause an inconsistent test environment? This is the only
test script that breaks now, but there's no reason not to protect all of
the scripts.

-Peff

^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: [PATCH] t4052: unset $COLUMNS inherited from environment
  2012-03-27  5:10                   ` [PATCH] t4052: unset $COLUMNS inherited from environment Zbigniew Jędrzejewski-Szmek
  2012-03-27  5:17                     ` Jeff King
@ 2012-03-27  5:32                     ` Johannes Sixt
  1 sibling, 0 replies; 24+ messages in thread
From: Johannes Sixt @ 2012-03-27  5:32 UTC (permalink / raw)
  To: Zbigniew Jędrzejewski-Szmek
  Cc: git, gitster, peff, Michael J Gruber, pclouds

Am 3/27/2012 7:10, schrieb Zbigniew Jędrzejewski-Szmek:
> diff --git a/t/t4052-stat-output.sh b/t/t4052-stat-output.sh
> index 328aa8f..1f47f1d 100755
> --- a/t/t4052-stat-output.sh
> +++ b/t/t4052-stat-output.sh
> @@ -17,6 +17,7 @@ test_expect_success 'preparation' '
>  	git commit -m message &&
>  	echo a >"$name" &&
>  	git commit -m message "$name"
> +	sane_unset COLUMNS
>  '

Watch out, the && chain is broken here.

-- Hannes

^ permalink raw reply	[flat|nested] 24+ messages in thread

* [PATCH v2] tests: unset COLUMNS inherited from environment
  2012-03-27  5:17                     ` Jeff King
@ 2012-03-27  6:22                       ` Zbigniew Jędrzejewski-Szmek
  2012-03-27 18:44                         ` Jeff King
  0 siblings, 1 reply; 24+ messages in thread
From: Zbigniew Jędrzejewski-Szmek @ 2012-03-27  6:22 UTC (permalink / raw)
  To: git, gitster, peff
  Cc: Michael J Gruber, pclouds, j.sixt, Zbigniew Jędrzejewski-Szmek

$COLUMNS must be unset to not interfere with the tests. The tests
already ignore the terminal size because output is redirected to a
file, but COLUMNS overrides terminal size detection and changes the
test output away from the standard 80.

Reported-by: Jeff King <peff@peff.net>
Signed-off-by: Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
---
Right, it is better to unset $COLUMNS globally. t4016 was also affected.

 t/test-lib.sh |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/t/test-lib.sh b/t/test-lib.sh
index 30ed4d7..b7d7100 100644
--- a/t/test-lib.sh
+++ b/t/test-lib.sh
@@ -46,7 +46,7 @@ EDITOR=:
 # /usr/xpg4/bin/sh and /bin/ksh to bail out.  So keep the unsets
 # deriving from the command substitution clustered with the other
 # ones.
-unset VISUAL EMAIL LANGUAGE $(perl -e '
+unset VISUAL EMAIL LANGUAGE COLUMNS $(perl -e '
 	my @env = keys %ENV;
 	my $ok = join("|", qw(
 		TRACE
-- 
1.7.10.rc1.222.gc0040.dirty

^ permalink raw reply related	[flat|nested] 24+ messages in thread

* Re: [PATCH v2] tests: unset COLUMNS inherited from environment
  2012-03-27  6:22                       ` [PATCH v2] tests: unset COLUMNS " Zbigniew Jędrzejewski-Szmek
@ 2012-03-27 18:44                         ` Jeff King
  0 siblings, 0 replies; 24+ messages in thread
From: Jeff King @ 2012-03-27 18:44 UTC (permalink / raw)
  To: Zbigniew Jędrzejewski-Szmek
  Cc: git, gitster, Michael J Gruber, pclouds, j.sixt

On Tue, Mar 27, 2012 at 08:22:02AM +0200, Zbigniew Jędrzejewski-Szmek wrote:

> $COLUMNS must be unset to not interfere with the tests. The tests
> already ignore the terminal size because output is redirected to a
> file, but COLUMNS overrides terminal size detection and changes the
> test output away from the standard 80.
> 
> Reported-by: Jeff King <peff@peff.net>
> Signed-off-by: Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
> ---
> Right, it is better to unset $COLUMNS globally. t4016 was also affected.

Thanks. Solves the problem for me, and looks obviously correct.

-Peff

^ permalink raw reply	[flat|nested] 24+ messages in thread

* Incremental updates to What's cooking
  2012-03-20  0:23 What's cooking in git.git (Mar 2012, #07; Mon, 19) Junio C Hamano
@ 2012-03-20 23:35 ` Junio C Hamano
  0 siblings, 0 replies; 24+ messages in thread
From: Junio C Hamano @ 2012-03-20 23:35 UTC (permalink / raw)
  To: git

Again, just the highlights of the notable topics.

Not much has happened on the 'master' front.

[New Topics]

* am/completion-zsh-fix (2012-03-20) 1 commit
 - contrib/completion: "local var=()" is misinterpreted as function decl by zsh

Needs a bit better explanation.

* lp/maint-diff-three-dash-with-graph (2012-03-20) 3 commits
 - t4202: add test for "log --graph --stat -p" separator lines
 - log --graph: fix break in graph lines
 - log --graph --stat: three-dash separator should come after graph lines

The combination of two options "log --graph --stat" was an obscure corner
case nobody cared about, and did not correctly show the ancestry graph
lines.

I've split the original patch into three pieces, one for fixes to two
different issues and a test.  Also the test is adjusted so that the series
can be back-merged to older codebase that did not have 7f81463 (Use
correct grammar in diffstat summary line, 2012-02-01) that first appeared
in v1.7.9.2

* wk/gitweb-snapshot-use-if-modified-since (2012-03-20) 1 commit
 - Pull gitweb If-Modified-Since handling out into its own function and use for snapshots.

Unreviewed; the title looks way too long and does not sit well in the
shortlog output.

* jc/maint-merge-autoedit (2012-03-20) 1 commit
 - merge: backport GIT_MERGE_AUTOEDIT support

In 1.7.10, we added GIT_MERGE_AUTOEDIT=no environment variable to help
older scripts to let them refuse giving users a chance to explain the
merge, but forgot that 1.7.9 automatically opens an editor when merging an
annotated tag, and there is no equivalent escape hatch.  A merge of this
topic to 1.7.10 track becomes a no-op, but we may want to apply this to
the 1.7.9.x series.

[Cooking]

* ct/advise-push-default (2012-03-19) 1 commit
 - push: Provide situational hints for non-fast-forward error

Breaks down the cases in which "git push" fails due to non-ff into three
categories, and gives separate advise messages.  This should be a good
change regardless of mm/push-default-switch-warning topic.

* tr/maint-word-diff-regex-sticky (2012-03-14) 3 commits
  (merged to 'next' on 2012-03-20 at b3f67cd)
 + diff: tweak a _copy_ of diff_options with word-diff
 + diff: refactor the word-diff setup from builtin_diff_cmd
 + t4034: diff.*.wordregex should not be "sticky" in --word-diff

It would be nice to have this fix in 1.7.10 but perhaps we can wait until
1.7.10.1.

* nl/http-proxy-more (2012-03-15) 5 commits
  (merged to 'next' on 2012-03-20 at c004001)
 + http: rename HTTP_REAUTH to HTTP_AUTH_RETRY
 + http: Avoid limit of retrying request only twice
 + http: handle proxy authentication failure (error 407)
 + http: handle proxy proactive authentication
 + http: try http_proxy env var when http.proxy config option is not set

The code to talk to http proxies learn to use the same credential
API used to talk to the final http destinations.

[Stalled]

* th/difftool-diffall (2012-03-19) 9 commits
 . difftool: print list of valid tools with '--tool-help'
 . difftool: teach dir-diff to copy modified files back to working tree
 . difftool: teach difftool to handle directory diffs
 . difftool: replace system call with Git::command_noisy
 . difftool: eliminate setup_environment function
 . difftool: stop appending '.exe' to git
 . difftool: remove explicit change of PATH
 . difftool: exit(0) when usage is printed
 . difftool: parse options using Getopt::Long

Reworks the "diffall" contrib script into "difftool" framework.
Breaks tests when merged to 'pu'.

* jh/apply-free-patch (2012-03-20) 2 commits
 - apply: free patch->result
 - apply: do not leak patches and fragments

Valgrind reports quite a lot of discarded memory inside apply. I have a
slight suspicion that we should first clarify the ownership rules of
pieces of memory in this standalone program that was designed to be "run
once and let exit take care of the memory" before proceeding further.

* dg/test-from-elsewhere (2012-03-04) 2 commits
 - Support out-of-tree Valgrind tests
 - Allow overriding GIT_BUILD_DIR

Better support for out-of-tree test scripts, but it appears that the
approach needs to be rethought.  By repointing TEST_DIRECTORY to a
directory other than $(pwd)/.., an out of place test script can reach
test helpers and freshly built Git relative to it (GIT_BUILD_DIR is
a mere short-hand for $TEST_DIRECTORY/..).

Discussion stalled.

^ permalink raw reply	[flat|nested] 24+ messages in thread

end of thread, other threads:[~2012-03-27 18:44 UTC | newest]

Thread overview: 24+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-02-28  6:53 Incremental updates to What's cooking Junio C Hamano
2012-02-29  7:37 ` Zbigniew Jędrzejewski-Szmek
2012-02-29  8:39   ` Junio C Hamano
2012-02-29 13:50     ` Zbigniew Jędrzejewski-Szmek
2012-02-29 19:28       ` Junio C Hamano
2012-02-29 20:19         ` Zbigniew Jędrzejewski-Szmek
2012-02-29 20:48           ` Junio C Hamano
2012-03-01 12:26             ` [PATCH v7a 1/9] diff --stat: tests for long filenames and big change counts Zbigniew Jędrzejewski-Szmek
2012-03-01 12:26               ` [PATCH v7a 2/9] diff --stat: use the full terminal width Zbigniew Jędrzejewski-Szmek
2012-03-01 12:26               ` [PATCH v7a 3/9] show " Zbigniew Jędrzejewski-Szmek
2012-03-01 12:26               ` [PATCH v7a 4/9] log " Zbigniew Jędrzejewski-Szmek
2012-03-01 12:26               ` [PATCH v7a 5/9] merge " Zbigniew Jędrzejewski-Szmek
2012-03-01 12:26               ` [PATCH v7a 6/9] diff --stat: use a maximum of 5/8 for the filename part Zbigniew Jędrzejewski-Szmek
2012-03-01 17:18                 ` Junio C Hamano
2012-03-26 23:45                 ` Jeff King
2012-03-27  5:10                   ` [PATCH] t4052: unset $COLUMNS inherited from environment Zbigniew Jędrzejewski-Szmek
2012-03-27  5:17                     ` Jeff King
2012-03-27  6:22                       ` [PATCH v2] tests: unset COLUMNS " Zbigniew Jędrzejewski-Szmek
2012-03-27 18:44                         ` Jeff King
2012-03-27  5:32                     ` [PATCH] t4052: unset $COLUMNS " Johannes Sixt
2012-03-01 12:26               ` [PATCH v7a 7/9] diff --stat: add a test for output with COLUMNS=40 Zbigniew Jędrzejewski-Szmek
2012-03-01 12:26               ` [PATCH v7a 8/9] diff --stat: enable limiting of the graph part Zbigniew Jędrzejewski-Szmek
2012-03-01 12:26               ` [PATCH v7a 9/9] diff --stat: add config option to limit graph width Zbigniew Jędrzejewski-Szmek
2012-03-20  0:23 What's cooking in git.git (Mar 2012, #07; Mon, 19) Junio C Hamano
2012-03-20 23:35 ` Incremental updates to What's cooking Junio C Hamano

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.