git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
* [PATCH] format-patch: respect --stat when explicitly specified
@ 2018-11-06 10:48 Leif Lindholm
  2018-11-06 15:56 ` Duy Nguyen
  2018-11-07 16:49 ` [PATCH v2] format-patch: respect --stat in cover letter's diffstat Nguyễn Thái Ngọc Duy
  0 siblings, 2 replies; 10+ messages in thread
From: Leif Lindholm @ 2018-11-06 10:48 UTC (permalink / raw)
  To: git; +Cc: Laszlo Ersek, Nguyễn Thái Ngọc Duy,
	Junio C Hamano

Commit 43662b23abbd
("format-patch: keep cover-letter diffstat wrapped in 72 columns") made
format-patch keep the diffstat to within 72 characters. However, it does
this even when --stat is explicitly set on the command line.

Make it possible to explicitly override the new mechanism, using --stat,
matching the functionality before this change. This also matches the
output in the case of non-cover-letter files.

Cc: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Cc: Junio C Hamano <gitster@pobox.com>
Reported-by: Laszlo Ersek <lersek@redhat.com>
Signed-off-by: Leif Lindholm <leif.lindholm@linaro.org>
---

Note:
In TianoCore we have LotsOfGloriousFilesNamedInReallyLongCamelCase, so
our official submission guidelines specify the use of --stat.

 builtin/log.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/builtin/log.c b/builtin/log.c
index 061d4fd86..07e6ae2c1 100644
--- a/builtin/log.c
+++ b/builtin/log.c
@@ -1009,7 +1009,8 @@ static void show_diffstat(struct rev_info *rev,
 
 	memcpy(&opts, &rev->diffopt, sizeof(opts));
 	opts.output_format = DIFF_FORMAT_SUMMARY | DIFF_FORMAT_DIFFSTAT;
-	opts.stat_width = MAIL_DEFAULT_WRAP;
+	if (rev->diffopt.stat_width == -1)
+		opts.stat_width = MAIL_DEFAULT_WRAP;
 
 	diff_setup_done(&opts);
 
-- 
2.11.0


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

* Re: [PATCH] format-patch: respect --stat when explicitly specified
  2018-11-06 10:48 [PATCH] format-patch: respect --stat when explicitly specified Leif Lindholm
@ 2018-11-06 15:56 ` Duy Nguyen
  2018-11-06 16:17   ` Laszlo Ersek
  2018-11-06 16:31   ` Leif Lindholm
  2018-11-07 16:49 ` [PATCH v2] format-patch: respect --stat in cover letter's diffstat Nguyễn Thái Ngọc Duy
  1 sibling, 2 replies; 10+ messages in thread
From: Duy Nguyen @ 2018-11-06 15:56 UTC (permalink / raw)
  To: leif.lindholm; +Cc: Git Mailing List, lersek, Junio C Hamano

On Tue, Nov 6, 2018 at 11:48 AM Leif Lindholm <leif.lindholm@linaro.org> wrote:
>
> Commit 43662b23abbd
> ("format-patch: keep cover-letter diffstat wrapped in 72 columns") made
> format-patch keep the diffstat to within 72 characters. However, it does
> this even when --stat is explicitly set on the command line.
>
> Make it possible to explicitly override the new mechanism, using --stat,
> matching the functionality before this change. This also matches the
> output in the case of non-cover-letter files.
>
> Cc: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
> Cc: Junio C Hamano <gitster@pobox.com>
> Reported-by: Laszlo Ersek <lersek@redhat.com>
> Signed-off-by: Leif Lindholm <leif.lindholm@linaro.org>
> ---
>
> Note:
> In TianoCore we have LotsOfGloriousFilesNamedInReallyLongCamelCase, so
> our official submission guidelines specify the use of --stat.
>
>  builtin/log.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/builtin/log.c b/builtin/log.c
> index 061d4fd86..07e6ae2c1 100644
> --- a/builtin/log.c
> +++ b/builtin/log.c
> @@ -1009,7 +1009,8 @@ static void show_diffstat(struct rev_info *rev,
>
>         memcpy(&opts, &rev->diffopt, sizeof(opts));
>         opts.output_format = DIFF_FORMAT_SUMMARY | DIFF_FORMAT_DIFFSTAT;
> -       opts.stat_width = MAIL_DEFAULT_WRAP;
> +       if (rev->diffopt.stat_width == -1)

I don't think we get -1 here when stat_width is not defined. The
"undefined" value is zero but I'm pretty sure we get MAIL_DEFAULT_WRAP
in here unless you specify --stat.

So I think you can just drop the below assignment. But if you want to
be on the safe side, check for zero stat_width instead of -1 and set
MAIL_DEFAULT_WRAP.

> +               opts.stat_width = MAIL_DEFAULT_WRAP;

How about a test to make sure this will not be broken in future?

>
>         diff_setup_done(&opts);
>
> --
> 2.11.0
-- 
Duy

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

* Re: [PATCH] format-patch: respect --stat when explicitly specified
  2018-11-06 15:56 ` Duy Nguyen
@ 2018-11-06 16:17   ` Laszlo Ersek
  2018-11-06 16:20     ` Duy Nguyen
  2018-11-06 16:31   ` Leif Lindholm
  1 sibling, 1 reply; 10+ messages in thread
From: Laszlo Ersek @ 2018-11-06 16:17 UTC (permalink / raw)
  To: Duy Nguyen, leif.lindholm; +Cc: Git Mailing List, Junio C Hamano

On 11/06/18 16:56, Duy Nguyen wrote:
> On Tue, Nov 6, 2018 at 11:48 AM Leif Lindholm <leif.lindholm@linaro.org> wrote:
>>
>> Commit 43662b23abbd
>> ("format-patch: keep cover-letter diffstat wrapped in 72 columns") made
>> format-patch keep the diffstat to within 72 characters. However, it does
>> this even when --stat is explicitly set on the command line.
>>
>> Make it possible to explicitly override the new mechanism, using --stat,
>> matching the functionality before this change. This also matches the
>> output in the case of non-cover-letter files.
>>
>> Cc: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
>> Cc: Junio C Hamano <gitster@pobox.com>
>> Reported-by: Laszlo Ersek <lersek@redhat.com>
>> Signed-off-by: Leif Lindholm <leif.lindholm@linaro.org>
>> ---
>>
>> Note:
>> In TianoCore we have LotsOfGloriousFilesNamedInReallyLongCamelCase, so
>> our official submission guidelines specify the use of --stat.
>>
>>  builtin/log.c | 3 ++-
>>  1 file changed, 2 insertions(+), 1 deletion(-)
>>
>> diff --git a/builtin/log.c b/builtin/log.c
>> index 061d4fd86..07e6ae2c1 100644
>> --- a/builtin/log.c
>> +++ b/builtin/log.c
>> @@ -1009,7 +1009,8 @@ static void show_diffstat(struct rev_info *rev,
>>
>>         memcpy(&opts, &rev->diffopt, sizeof(opts));
>>         opts.output_format = DIFF_FORMAT_SUMMARY | DIFF_FORMAT_DIFFSTAT;
>> -       opts.stat_width = MAIL_DEFAULT_WRAP;
>> +       if (rev->diffopt.stat_width == -1)
> 
> I don't think we get -1 here when stat_width is not defined. The
> "undefined" value is zero but I'm pretty sure we get MAIL_DEFAULT_WRAP
> in here unless you specify --stat.
> 
> So I think you can just drop the below assignment. But if you want to
> be on the safe side, check for zero stat_width instead of -1 and set
> MAIL_DEFAULT_WRAP.

Looks like I'll have to test v2 then...

> 
>> +               opts.stat_width = MAIL_DEFAULT_WRAP;
> 
> How about a test to make sure this will not be broken in future?

Oh, looks like I won't have to test this patch at all! ;)

(Just kidding, I'll test the next iteration.)

Thanks,
Laszlo

> 
>>
>>         diff_setup_done(&opts);
>>
>> --
>> 2.11.0


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

* Re: [PATCH] format-patch: respect --stat when explicitly specified
  2018-11-06 16:17   ` Laszlo Ersek
@ 2018-11-06 16:20     ` Duy Nguyen
  0 siblings, 0 replies; 10+ messages in thread
From: Duy Nguyen @ 2018-11-06 16:20 UTC (permalink / raw)
  To: lersek; +Cc: leif.lindholm, Git Mailing List, Junio C Hamano

On Tue, Nov 6, 2018 at 5:18 PM Laszlo Ersek <lersek@redhat.com> wrote:
> >> +               opts.stat_width = MAIL_DEFAULT_WRAP;
> >
> > How about a test to make sure this will not be broken in future?
>
> Oh, looks like I won't have to test this patch at all! ;)
>
> (Just kidding, I'll test the next iteration.)

Just to be clear I didn't mean you didn't test it. I meant adding a
new test case to our test suite.
-- 
Duy

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

* Re: [PATCH] format-patch: respect --stat when explicitly specified
  2018-11-06 15:56 ` Duy Nguyen
  2018-11-06 16:17   ` Laszlo Ersek
@ 2018-11-06 16:31   ` Leif Lindholm
  2018-11-06 17:13     ` Duy Nguyen
  1 sibling, 1 reply; 10+ messages in thread
From: Leif Lindholm @ 2018-11-06 16:31 UTC (permalink / raw)
  To: Duy Nguyen; +Cc: Git Mailing List, lersek, Junio C Hamano

On Tue, Nov 06, 2018 at 04:56:11PM +0100, Duy Nguyen wrote:
> On Tue, Nov 6, 2018 at 11:48 AM Leif Lindholm <leif.lindholm@linaro.org> wrote:
> >
> > Commit 43662b23abbd
> > ("format-patch: keep cover-letter diffstat wrapped in 72 columns") made
> > format-patch keep the diffstat to within 72 characters. However, it does
> > this even when --stat is explicitly set on the command line.
> >
> > Make it possible to explicitly override the new mechanism, using --stat,
> > matching the functionality before this change. This also matches the
> > output in the case of non-cover-letter files.
> >
> > Cc: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
> > Cc: Junio C Hamano <gitster@pobox.com>
> > Reported-by: Laszlo Ersek <lersek@redhat.com>
> > Signed-off-by: Leif Lindholm <leif.lindholm@linaro.org>
> > ---
> >
> > Note:
> > In TianoCore we have LotsOfGloriousFilesNamedInReallyLongCamelCase, so
> > our official submission guidelines specify the use of --stat.
> >
> >  builtin/log.c | 3 ++-
> >  1 file changed, 2 insertions(+), 1 deletion(-)
> >
> > diff --git a/builtin/log.c b/builtin/log.c
> > index 061d4fd86..07e6ae2c1 100644
> > --- a/builtin/log.c
> > +++ b/builtin/log.c
> > @@ -1009,7 +1009,8 @@ static void show_diffstat(struct rev_info *rev,
> >
> >         memcpy(&opts, &rev->diffopt, sizeof(opts));
> >         opts.output_format = DIFF_FORMAT_SUMMARY | DIFF_FORMAT_DIFFSTAT;
> > -       opts.stat_width = MAIL_DEFAULT_WRAP;
> > +       if (rev->diffopt.stat_width == -1)
> 
> I don't think we get -1 here when stat_width is not defined. The
> "undefined" value is zero but I'm pretty sure we get MAIL_DEFAULT_WRAP
> in here unless you specify --stat.

From what I could tell, if nothing is specified on command line,
rev->diffopt.stat_width is set to -1 at this point (I assumed by
rev->cmd_log_init_defaults(), but didn't go digging).

The patched version certainly gives the <= 2.16.* behaviour with
--stat and still restricts stat lines to 72 characters without.

> So I think you can just drop the below assignment. But if you want to
> be on the safe side, check for zero stat_width instead of -1 and set
> MAIL_DEFAULT_WRAP.
> 
> > +               opts.stat_width = MAIL_DEFAULT_WRAP;
> 
> How about a test to make sure this will not be broken in future?

Sure. Only today was the first time I had a look at the git sources,
so some guidance would be most appreciated.

Should I add a function to t/t4014-format-patch.sh and just put
something longer than a/file for the expect template?

/
    Leif

> >
> >         diff_setup_done(&opts);
> >
> > --
> > 2.11.0
> -- 
> Duy

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

* Re: [PATCH] format-patch: respect --stat when explicitly specified
  2018-11-06 16:31   ` Leif Lindholm
@ 2018-11-06 17:13     ` Duy Nguyen
  2018-11-06 17:25       ` Leif Lindholm
  0 siblings, 1 reply; 10+ messages in thread
From: Duy Nguyen @ 2018-11-06 17:13 UTC (permalink / raw)
  To: leif.lindholm; +Cc: Git Mailing List, lersek, Junio C Hamano

On Tue, Nov 6, 2018 at 5:31 PM Leif Lindholm <leif.lindholm@linaro.org> wrote:
> > > diff --git a/builtin/log.c b/builtin/log.c
> > > index 061d4fd86..07e6ae2c1 100644
> > > --- a/builtin/log.c
> > > +++ b/builtin/log.c
> > > @@ -1009,7 +1009,8 @@ static void show_diffstat(struct rev_info *rev,
> > >
> > >         memcpy(&opts, &rev->diffopt, sizeof(opts));
> > >         opts.output_format = DIFF_FORMAT_SUMMARY | DIFF_FORMAT_DIFFSTAT;
> > > -       opts.stat_width = MAIL_DEFAULT_WRAP;
> > > +       if (rev->diffopt.stat_width == -1)
> >
> > I don't think we get -1 here when stat_width is not defined. The
> > "undefined" value is zero but I'm pretty sure we get MAIL_DEFAULT_WRAP
> > in here unless you specify --stat.
>
> From what I could tell, if nothing is specified on command line,
> rev->diffopt.stat_width is set to -1 at this point (I assumed by
> rev->cmd_log_init_defaults(), but didn't go digging).

I thought the same but could find where cmd_log_.. is called by
format-patch. I was not even sure if I read the code correctly so I
ran the command through gdb. It was definitely not called.

> The patched version certainly gives the <= 2.16.* behaviour with
> --stat and still restricts stat lines to 72 characters without.
>
> > So I think you can just drop the below assignment. But if you want to
> > be on the safe side, check for zero stat_width instead of -1 and set
> > MAIL_DEFAULT_WRAP.
> >
> > > +               opts.stat_width = MAIL_DEFAULT_WRAP;
> >
> > How about a test to make sure this will not be broken in future?
>
> Sure. Only today was the first time I had a look at the git sources,
> so some guidance would be most appreciated.

No problem (and if you don't have time to do it, just say the word and
I will continue; this is my bug after all)

> Should I add a function to t/t4014-format-patch.sh and just put
> something longer than a/file for the expect template?

First of all the README file in that directory could give pretty good
basic instructions.

Back to this test, I think you could start by copying to a new test
(the whole "test_expect_success" block, optionally including the
"expect" file creation too), add --stat there and see what it looks
like. For stat testing, t4052 could also be a good example. Or perhaps
the test should be added in t4052 because it already supports long
file name ($name is 120 char long).
-- 
Duy

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

* Re: [PATCH] format-patch: respect --stat when explicitly specified
  2018-11-06 17:13     ` Duy Nguyen
@ 2018-11-06 17:25       ` Leif Lindholm
  2018-11-06 17:27         ` Duy Nguyen
  0 siblings, 1 reply; 10+ messages in thread
From: Leif Lindholm @ 2018-11-06 17:25 UTC (permalink / raw)
  To: Duy Nguyen; +Cc: Git Mailing List, lersek, Junio C Hamano

On Tue, Nov 06, 2018 at 06:13:00PM +0100, Duy Nguyen wrote:
> On Tue, Nov 6, 2018 at 5:31 PM Leif Lindholm <leif.lindholm@linaro.org> wrote:
> > > > diff --git a/builtin/log.c b/builtin/log.c
> > > > index 061d4fd86..07e6ae2c1 100644
> > > > --- a/builtin/log.c
> > > > +++ b/builtin/log.c
> > > > @@ -1009,7 +1009,8 @@ static void show_diffstat(struct rev_info *rev,
> > > >
> > > >         memcpy(&opts, &rev->diffopt, sizeof(opts));
> > > >         opts.output_format = DIFF_FORMAT_SUMMARY | DIFF_FORMAT_DIFFSTAT;
> > > > -       opts.stat_width = MAIL_DEFAULT_WRAP;
> > > > +       if (rev->diffopt.stat_width == -1)
> > >
> > > I don't think we get -1 here when stat_width is not defined. The
> > > "undefined" value is zero but I'm pretty sure we get MAIL_DEFAULT_WRAP
> > > in here unless you specify --stat.
> >
> > From what I could tell, if nothing is specified on command line,
> > rev->diffopt.stat_width is set to -1 at this point (I assumed by
> > rev->cmd_log_init_defaults(), but didn't go digging).
> 
> I thought the same but could find where cmd_log_.. is called by
> format-patch. I was not even sure if I read the code correctly so I
> ran the command through gdb. It was definitely not called.

Huh...

> > The patched version certainly gives the <= 2.16.* behaviour with
> > --stat and still restricts stat lines to 72 characters without.
> >
> > > So I think you can just drop the below assignment. But if you want to
> > > be on the safe side, check for zero stat_width instead of -1 and set
> > > MAIL_DEFAULT_WRAP.
> > >
> > > > +               opts.stat_width = MAIL_DEFAULT_WRAP;
> > >
> > > How about a test to make sure this will not be broken in future?
> >
> > Sure. Only today was the first time I had a look at the git sources,
> > so some guidance would be most appreciated.
> 
> No problem (and if you don't have time to do it, just say the word and
> I will continue; this is my bug after all)

Weeeell, if you're offering, I would certainly appreciate not having
to dig deeper into this. I've got a patch review backlog the length of
my arm in another project...

> > Should I add a function to t/t4014-format-patch.sh and just put
> > something longer than a/file for the expect template?
> 
> First of all the README file in that directory could give pretty good
> basic instructions.
> 
> Back to this test, I think you could start by copying to a new test
> (the whole "test_expect_success" block, optionally including the
> "expect" file creation too), add --stat there and see what it looks
> like. For stat testing, t4052 could also be a good example. Or perhaps
> the test should be added in t4052 because it already supports long
> file name ($name is 120 char long).

(Thanks!)

/
    Leif

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

* Re: [PATCH] format-patch: respect --stat when explicitly specified
  2018-11-06 17:25       ` Leif Lindholm
@ 2018-11-06 17:27         ` Duy Nguyen
  0 siblings, 0 replies; 10+ messages in thread
From: Duy Nguyen @ 2018-11-06 17:27 UTC (permalink / raw)
  To: Leif Lindholm; +Cc: Git Mailing List, lersek, Junio C Hamano

On Tue, Nov 6, 2018 at 6:25 PM Leif Lindholm <leif.lindholm@linaro.org> wrote:
> > > Sure. Only today was the first time I had a look at the git sources,
> > > so some guidance would be most appreciated.
> >
> > No problem (and if you don't have time to do it, just say the word and
> > I will continue; this is my bug after all)
>
> Weeeell, if you're offering, I would certainly appreciate not having
> to dig deeper into this. I've got a patch review backlog the length of
> my arm in another project...

Your loss. Your name is not going to be in git.git then (j/k). Thanks
for the report. I'll double, triple check, add tests and resubmit
soon.
-- 
Duy

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

* [PATCH v2] format-patch: respect --stat in cover letter's diffstat
  2018-11-06 10:48 [PATCH] format-patch: respect --stat when explicitly specified Leif Lindholm
  2018-11-06 15:56 ` Duy Nguyen
@ 2018-11-07 16:49 ` Nguyễn Thái Ngọc Duy
  2018-11-07 22:21   ` Laszlo Ersek
  1 sibling, 1 reply; 10+ messages in thread
From: Nguyễn Thái Ngọc Duy @ 2018-11-07 16:49 UTC (permalink / raw)
  To: leif.lindholm; +Cc: git, gitster, lersek, pclouds

Commit 43662b23ab (format-patch: keep cover-letter diffstat wrapped in
72 columns - 2018-01-24) uncondtionally sets stat width to 72 when
generating diffstat for the cover letter, ignoring --stat from command
line. But it should only do so when stat width is still default
(i.e. stat_width == 0).

In order to fix this, we should only set stat_width if stat_width is
zero. But it will never be. Commit 071dd0ba43 (format-patch: reduce
patch diffstat width to 72 - 2018-02-01) makes sure that default stat
width will be 72 (ignoring $COLUMNS, but could still be overriden by
--stat). So all we need to do here is drop the assignment.

Reported-by: Laszlo Ersek <lersek@redhat.com>
Helped-by: Leif Lindholm <leif.lindholm@linaro.org>
Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
---
 builtin/log.c          |  2 --
 t/t4052-stat-output.sh | 48 +++++++++++++++++++++++++++++-------------
 2 files changed, 33 insertions(+), 17 deletions(-)

diff --git a/builtin/log.c b/builtin/log.c
index 061d4fd864..1a39c6e52a 100644
--- a/builtin/log.c
+++ b/builtin/log.c
@@ -1009,8 +1009,6 @@ static void show_diffstat(struct rev_info *rev,
 
 	memcpy(&opts, &rev->diffopt, sizeof(opts));
 	opts.output_format = DIFF_FORMAT_SUMMARY | DIFF_FORMAT_DIFFSTAT;
-	opts.stat_width = MAIL_DEFAULT_WRAP;
-
 	diff_setup_done(&opts);
 
 	diff_tree_oid(get_commit_tree_oid(origin),
diff --git a/t/t4052-stat-output.sh b/t/t4052-stat-output.sh
index 6e2cf933f7..b1ce0d9b97 100755
--- a/t/t4052-stat-output.sh
+++ b/t/t4052-stat-output.sh
@@ -44,42 +44,50 @@ show --stat
 log -1 --stat
 EOF
 
-while read cmd args
+cat >expect.40 <<-'EOF'
+ ...aaaaaaaaaaaaaaaaaaaaaaaaaaaaa | 1 +
+EOF
+cat >expect.6030 <<-'EOF'
+ ...aaaaaaaaaaaaaaaaaaaaaaaaaaa | 1 +
+EOF
+cat >expect2.40 <<-'EOF'
+ ...aaaaaaaaaaaaaaaaaaaaaaaaaaaaa | 1 +
+ ...aaaaaaaaaaaaaaaaaaaaaaaaaaaaa | 1 +
+EOF
+cat >expect2.6030 <<-'EOF'
+ ...aaaaaaaaaaaaaaaaaaaaaaaaaaa | 1 +
+ ...aaaaaaaaaaaaaaaaaaaaaaaaaaa | 1 +
+EOF
+while read expect cmd args
 do
-	cat >expect <<-'EOF'
-	 ...aaaaaaaaaaaaaaaaaaaaaaaaaaaaa | 1 +
-	EOF
 	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
+		test_cmp $expect.40 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
+		test_cmp $expect.40 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_cmp $expect.6030 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
+		test_cmp $expect.6030 actual
 	'
 done <<\EOF
-format-patch -1 --stdout
-diff HEAD^ HEAD --stat
-show --stat
-log -1 --stat
+expect2 format-patch --cover-letter -1 --stdout
+expect diff HEAD^ HEAD --stat
+expect show --stat
+expect log -1 --stat
 EOF
 
 
@@ -95,6 +103,16 @@ test_expect_success 'preparation for big change tests' '
 	git commit -m message abcd
 '
 
+cat >expect72 <<'EOF'
+ abcd | 1000 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+ abcd | 1000 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+EOF
+test_expect_success "format-patch --cover-letter ignores COLUMNS (big change)" '
+	COLUMNS=200 git format-patch -1 --stdout --cover-letter >output &&
+	grep " | " output >actual &&
+	test_cmp expect72 actual
+'
+
 cat >expect72 <<'EOF'
  abcd | 1000 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 EOF
-- 
2.19.1.1005.gac84295441


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

* Re: [PATCH v2] format-patch: respect --stat in cover letter's diffstat
  2018-11-07 16:49 ` [PATCH v2] format-patch: respect --stat in cover letter's diffstat Nguyễn Thái Ngọc Duy
@ 2018-11-07 22:21   ` Laszlo Ersek
  0 siblings, 0 replies; 10+ messages in thread
From: Laszlo Ersek @ 2018-11-07 22:21 UTC (permalink / raw)
  To: Nguyễn Thái Ngọc Duy, leif.lindholm; +Cc: git, gitster

On 11/07/18 17:49, Nguyễn Thái Ngọc Duy wrote:
> Commit 43662b23ab (format-patch: keep cover-letter diffstat wrapped in
> 72 columns - 2018-01-24) uncondtionally sets stat width to 72 when
> generating diffstat for the cover letter, ignoring --stat from command
> line. But it should only do so when stat width is still default
> (i.e. stat_width == 0).
> 
> In order to fix this, we should only set stat_width if stat_width is
> zero. But it will never be. Commit 071dd0ba43 (format-patch: reduce
> patch diffstat width to 72 - 2018-02-01) makes sure that default stat
> width will be 72 (ignoring $COLUMNS, but could still be overriden by
> --stat). So all we need to do here is drop the assignment.
> 
> Reported-by: Laszlo Ersek <lersek@redhat.com>
> Helped-by: Leif Lindholm <leif.lindholm@linaro.org>
> Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
> ---
>  builtin/log.c          |  2 --
>  t/t4052-stat-output.sh | 48 +++++++++++++++++++++++++++++-------------
>  2 files changed, 33 insertions(+), 17 deletions(-)
> 
> diff --git a/builtin/log.c b/builtin/log.c
> index 061d4fd864..1a39c6e52a 100644
> --- a/builtin/log.c
> +++ b/builtin/log.c
> @@ -1009,8 +1009,6 @@ static void show_diffstat(struct rev_info *rev,
>  
>  	memcpy(&opts, &rev->diffopt, sizeof(opts));
>  	opts.output_format = DIFF_FORMAT_SUMMARY | DIFF_FORMAT_DIFFSTAT;
> -	opts.stat_width = MAIL_DEFAULT_WRAP;
> -
>  	diff_setup_done(&opts);
>  
>  	diff_tree_oid(get_commit_tree_oid(origin),

Because I plan to use the patch on top of v2.19.1 (until the next major
release, v2.20, is made), that's also where I applied and tested the patch.

With master @ a4b8ab5363a3, this patch targets show_diffstat(). At
v2.19.1, commit fa5b7ea670f4 ("format-patch: allow additional generated
content in make_cover_letter()", 2018-07-23) had not occurred yet, so
there the subject code still lived in make_cover_letter(). On my end,
git-am has applied the hunk to make_cover_letter() seamlessly.

I tested the patch with "--stat=1000 --stat-graph-width=20", formatting
an edk2 series that contained commit 1ed6498c4a02
("UefiCpuPkg/CommonFeature: Skip locking when the feature is disabled",
2018-11-07). The long pathname
"UefiCpuPkg/Library/CpuCommonFeaturesLib/FeatureControl.c" is no longer
truncated in the cumulative diffstat, in the cover letter.

Tested-by: Laszlo Ersek <lersek@redhat.com>

> diff --git a/t/t4052-stat-output.sh b/t/t4052-stat-output.sh
> [...]

I didn't try to run the test suite (I wasn't conscious of it anyway); I
built & installed git with

  nice make -j4 prefix=... all doc info
  nice make prefix=... install install-doc install-html install-info

I also wasn't watching the make log. So if those make targets don't
include the test suite, then I didn't exercise the new test case.

Thank you!
Laszlo

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

end of thread, other threads:[~2018-11-07 22:21 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-11-06 10:48 [PATCH] format-patch: respect --stat when explicitly specified Leif Lindholm
2018-11-06 15:56 ` Duy Nguyen
2018-11-06 16:17   ` Laszlo Ersek
2018-11-06 16:20     ` Duy Nguyen
2018-11-06 16:31   ` Leif Lindholm
2018-11-06 17:13     ` Duy Nguyen
2018-11-06 17:25       ` Leif Lindholm
2018-11-06 17:27         ` Duy Nguyen
2018-11-07 16:49 ` [PATCH v2] format-patch: respect --stat in cover letter's diffstat Nguyễn Thái Ngọc Duy
2018-11-07 22:21   ` Laszlo Ersek

Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).