git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
* [PATCH] Move format-patch base commit and prerequisites before email signature
@ 2016-09-08  1:12 Josh Triplett
  2016-09-08 18:34 ` Junio C Hamano
  0 siblings, 1 reply; 14+ messages in thread
From: Josh Triplett @ 2016-09-08  1:12 UTC (permalink / raw)
  To: git

Any text below the "-- " for the email signature gets treated as part of
the signature, and many mail clients will trim it from the quoted text
for a reply.  Move it above the signature, so people can reply to it
more easily.

Add tests for the exact format of the email signature, and add tests to
ensure the email signature appears last.

(Patch by Junio Hamano; tests by Josh Triplett.)
Signed-off-by: Josh Triplett <josh@joshtriplett.org>
---

Does the above seem reasonable, for a patch that incorporates the
proposed patch from Message-Id
xmqqh99rpud4.fsf@gitster.mtv.corp.google.com and adds tests?
Alternatively, feel free to split this patch into two, the first with
you as the author.  I can confirm that the code change doesn't break any
existing tests; only the new tests added here check for it.  So a
two-patch series wouldn't result in any breakage after the first patch.

 builtin/log.c           |  4 ++--
 t/t4014-format-patch.sh | 22 +++++++++++++++++-----
 2 files changed, 19 insertions(+), 7 deletions(-)

diff --git a/builtin/log.c b/builtin/log.c
index 92dc34d..d69d5e6 100644
--- a/builtin/log.c
+++ b/builtin/log.c
@@ -1042,7 +1042,6 @@ static void make_cover_letter(struct rev_info *rev, int use_stdout,
 	diff_flush(&opts);
 
 	fprintf(rev->diffopt.file, "\n");
-	print_signature(rev->diffopt.file);
 }
 
 static const char *clean_message_id(const char *msg_id)
@@ -1720,6 +1719,7 @@ int cmd_format_patch(int argc, const char **argv, const char *prefix)
 		make_cover_letter(&rev, use_stdout,
 				  origin, nr, list, branch_name, quiet);
 		print_bases(&bases, rev.diffopt.file);
+		print_signature(rev.diffopt.file);
 		total++;
 		start_number--;
 	}
@@ -1779,13 +1779,13 @@ int cmd_format_patch(int argc, const char **argv, const char *prefix)
 		if (!use_stdout)
 			rev.shown_one = 0;
 		if (shown) {
+			print_bases(&bases, rev.diffopt.file);
 			if (rev.mime_boundary)
 				fprintf(rev.diffopt.file, "\n--%s%s--\n\n\n",
 				       mime_boundary_leader,
 				       rev.mime_boundary);
 			else
 				print_signature(rev.diffopt.file);
-			print_bases(&bases, rev.diffopt.file);
 		}
 		if (!use_stdout)
 			fclose(rev.diffopt.file);
diff --git a/t/t4014-format-patch.sh b/t/t4014-format-patch.sh
index b0579dd..a4af275 100755
--- a/t/t4014-format-patch.sh
+++ b/t/t4014-format-patch.sh
@@ -754,9 +754,22 @@ test_expect_success 'format-patch --ignore-if-in-upstream HEAD' '
 	git format-patch --ignore-if-in-upstream HEAD
 '
 
+git_version="$(git --version | sed "s/.* //")"
+
+signature() {
+	printf "%s\n%s\n\n" "-- " "${1:-$git_version}"
+}
+
+test_expect_success 'format-patch default signature' '
+	git format-patch --stdout -1 | tail -n 3 >output &&
+	signature >expect &&
+	test_cmp expect output
+'
+
 test_expect_success 'format-patch --signature' '
-	git format-patch --stdout --signature="my sig" -1 >output &&
-	grep "my sig" output
+	git format-patch --stdout --signature="my sig" -1 | tail -n 3 >output &&
+	signature "my sig" >expect &&
+	test_cmp expect output
 '
 
 test_expect_success 'format-patch with format.signature config' '
@@ -1502,12 +1515,11 @@ test_expect_success 'format-patch -o overrides format.outputDirectory' '
 
 test_expect_success 'format-patch --base' '
 	git checkout side &&
-	git format-patch --stdout --base=HEAD~3 -1 >patch &&
-	grep "^base-commit:" patch >actual &&
-	grep "^prerequisite-patch-id:" patch >>actual &&
+	git format-patch --stdout --base=HEAD~3 -1 | tail -n 6 >actual &&
 	echo "base-commit: $(git rev-parse HEAD~3)" >expected &&
 	echo "prerequisite-patch-id: $(git show --patch HEAD~2 | git patch-id --stable | awk "{print \$1}")" >>expected &&
 	echo "prerequisite-patch-id: $(git show --patch HEAD~1 | git patch-id --stable | awk "{print \$1}")" >>expected &&
+	signature >> expected &&
 	test_cmp expected actual
 '
 
base-commit: 6ebdac1bab966b720d776aa43ca188fe378b1f4b
-- 
git-series 0.8.10

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

* Re: [PATCH] Move format-patch base commit and prerequisites before email signature
  2016-09-08  1:12 [PATCH] Move format-patch base commit and prerequisites before email signature Josh Triplett
@ 2016-09-08 18:34 ` Junio C Hamano
  2016-09-08 18:54   ` Josh Triplett
  0 siblings, 1 reply; 14+ messages in thread
From: Junio C Hamano @ 2016-09-08 18:34 UTC (permalink / raw)
  To: Josh Triplett; +Cc: git

Josh Triplett <josh@joshtriplett.org> writes:

> Any text below the "-- " for the email signature gets treated as part of
> the signature, and many mail clients will trim it from the quoted text
> for a reply.  Move it above the signature, so people can reply to it
> more easily.
>
> Add tests for the exact format of the email signature, and add tests to
> ensure the email signature appears last.
>
> (Patch by Junio Hamano; tests by Josh Triplett.)
> Signed-off-by: Josh Triplett <josh@joshtriplett.org>
> ---
>
> Does the above seem reasonable, for a patch that incorporates the
> proposed patch from Message-Id
> xmqqh99rpud4.fsf@gitster.mtv.corp.google.com and adds tests?

Other than that I'd probably retitle it, your problem description
looks perfect.  I am still not sure if the code does a reasonable
thing in MIME case, though.

Thanks for tying the loose ends anyway.

> diff --git a/t/t4014-format-patch.sh b/t/t4014-format-patch.sh
> index b0579dd..a4af275 100755
> --- a/t/t4014-format-patch.sh
> +++ b/t/t4014-format-patch.sh
> @@ -754,9 +754,22 @@ test_expect_success 'format-patch --ignore-if-in-upstream HEAD' '
>  	git format-patch --ignore-if-in-upstream HEAD
>  '
>  
> +git_version="$(git --version | sed "s/.* //")"
> +
> +signature() {
> +	printf "%s\n%s\n\n" "-- " "${1:-$git_version}"
> +}

Hmph.  I would actually have expected that you would force a fixed
and an easily noticeable string via format.signature for the purpose
of the test, but I guess this test covers a lot more than what the
purpose of the main part of the patch does (i.e. enforces that the
default signature must be made from the version string of Git).  It
is not a bad thing to test, but it probably does not belong to this
change.  If you _were_ to split the patch in two, that is where I
probably would split, i.e. "we didn't test what the default signature
looks like, or we didn't make sure --signature option overrides the
default signature, so let's test it" as the preliminary preparation,
followed by "having base info after sig is inconvenient, let's move
it and make sure base info stays before sig with additional test" as
the second (and primary) patch.

But a single patch is fine.

Thanks.

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

* Re: [PATCH] Move format-patch base commit and prerequisites before email signature
  2016-09-08 18:34 ` Junio C Hamano
@ 2016-09-08 18:54   ` Josh Triplett
  2016-09-08 19:11     ` Junio C Hamano
  2016-09-08 20:08     ` Jeff King
  0 siblings, 2 replies; 14+ messages in thread
From: Josh Triplett @ 2016-09-08 18:54 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: git

On Thu, Sep 08, 2016 at 11:34:15AM -0700, Junio C Hamano wrote:
> Josh Triplett <josh@joshtriplett.org> writes:
> 
> > Any text below the "-- " for the email signature gets treated as part of
> > the signature, and many mail clients will trim it from the quoted text
> > for a reply.  Move it above the signature, so people can reply to it
> > more easily.
> >
> > Add tests for the exact format of the email signature, and add tests to
> > ensure the email signature appears last.
> >
> > (Patch by Junio Hamano; tests by Josh Triplett.)
> > Signed-off-by: Josh Triplett <josh@joshtriplett.org>
> > ---
> >
> > Does the above seem reasonable, for a patch that incorporates the
> > proposed patch from Message-Id
> > xmqqh99rpud4.fsf@gitster.mtv.corp.google.com and adds tests?
> 
> Other than that I'd probably retitle it,

Ah, true, I should have titled it "format-patch: move base commit ...".

> your problem description
> looks perfect.  I am still not sure if the code does a reasonable
> thing in MIME case, though.

It *looks* correct to me.

> Thanks for tying the loose ends anyway.
> 
> > diff --git a/t/t4014-format-patch.sh b/t/t4014-format-patch.sh
> > index b0579dd..a4af275 100755
> > --- a/t/t4014-format-patch.sh
> > +++ b/t/t4014-format-patch.sh
> > @@ -754,9 +754,22 @@ test_expect_success 'format-patch --ignore-if-in-upstream HEAD' '
> >  	git format-patch --ignore-if-in-upstream HEAD
> >  '
> >  
> > +git_version="$(git --version | sed "s/.* //")"
> > +
> > +signature() {
> > +	printf "%s\n%s\n\n" "-- " "${1:-$git_version}"
> > +}
> 
> Hmph.  I would actually have expected that you would force a fixed
> and an easily noticeable string via format.signature for the purpose
> of the test,

One of the git tests already did that.  I just modified that test to
test the exact signature format and that it appears at the end, rather
than just grepping to check that the signature string appears somewhere.
Then when doing so, I realized that I should check the default case too
(at which point that test change probably should have gone in a separate
patch).

> but I guess this test covers a lot more than what the
> purpose of the main part of the patch does (i.e. enforces that the
> default signature must be made from the version string of Git).  It
> is not a bad thing to test, but it probably does not belong to this
> change.  If you _were_ to split the patch in two, that is where I
> probably would split, i.e. "we didn't test what the default signature
> looks like, or we didn't make sure --signature option overrides the
> default signature, so let's test it" as the preliminary preparation,
> followed by "having base info after sig is inconvenient, let's move
> it and make sure base info stays before sig with additional test" as
> the second (and primary) patch.
>
> But a single patch is fine.
> 
> Thanks.

If any other change ends up being necessary, I'll split the patch in v2.

- Josh Triplett

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

* Re: [PATCH] Move format-patch base commit and prerequisites before email signature
  2016-09-08 18:54   ` Josh Triplett
@ 2016-09-08 19:11     ` Junio C Hamano
  2016-09-08 20:08     ` Jeff King
  1 sibling, 0 replies; 14+ messages in thread
From: Junio C Hamano @ 2016-09-08 19:11 UTC (permalink / raw)
  To: Josh Triplett; +Cc: git

Josh Triplett <josh@joshtriplett.org> writes:

> If any other change ends up being necessary, I'll split the patch in v2.

Thanks. I do not see anything else offhand myself, but other people
watching the topic from the sideline may spot something we missed.


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

* Re: [PATCH] Move format-patch base commit and prerequisites before email signature
  2016-09-08 18:54   ` Josh Triplett
  2016-09-08 19:11     ` Junio C Hamano
@ 2016-09-08 20:08     ` Jeff King
  2016-09-08 21:24       ` Junio C Hamano
  1 sibling, 1 reply; 14+ messages in thread
From: Jeff King @ 2016-09-08 20:08 UTC (permalink / raw)
  To: Josh Triplett; +Cc: Junio C Hamano, git

On Thu, Sep 08, 2016 at 11:54:08AM -0700, Josh Triplett wrote:

> > your problem description
> > looks perfect.  I am still not sure if the code does a reasonable
> > thing in MIME case, though.
> 
> It *looks* correct to me.

Hmm. It looks correct to me, too; we stick it just after the patch, so
with "--attach" it is part of the text/x-patch, which is reasonable.

But looking at the results of "--attach" from _before_ your patch, it
looks totally broken. The "base" information comes _after the final
delimiter of the multipart/mixed. Most mailers would just throw it away
when decoding the multipart, I think.

So this is actually fixing a bug, and you could probably add a test
(though I am not sure we have anything in git that actually parses
multipart messages _or_ that carefully consumes the base-commit info, so
it might be hard to test in practice).

-Peff

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

* Re: [PATCH] Move format-patch base commit and prerequisites before email signature
  2016-09-08 20:08     ` Jeff King
@ 2016-09-08 21:24       ` Junio C Hamano
  2016-09-09 19:41         ` Junio C Hamano
  0 siblings, 1 reply; 14+ messages in thread
From: Junio C Hamano @ 2016-09-08 21:24 UTC (permalink / raw)
  To: Jeff King; +Cc: Josh Triplett, git

Jeff King <peff@peff.net> writes:

> On Thu, Sep 08, 2016 at 11:54:08AM -0700, Josh Triplett wrote:
>
>> > your problem description
>> > looks perfect.  I am still not sure if the code does a reasonable
>> > thing in MIME case, though.
>> 
>> It *looks* correct to me.
> 
> Hmm. It looks correct to me, too; ...
> ...
> So this is actually fixing a bug,...

Yes, I actually wanted to hear that from Josh and have that in the
proposed log message ;-).

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

* Re: [PATCH] Move format-patch base commit and prerequisites before email signature
  2016-09-08 21:24       ` Junio C Hamano
@ 2016-09-09 19:41         ` Junio C Hamano
  2016-09-09 20:07           ` Josh Triplett
  0 siblings, 1 reply; 14+ messages in thread
From: Junio C Hamano @ 2016-09-09 19:41 UTC (permalink / raw)
  To: Josh Triplett, Jeff King; +Cc: git

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

> Jeff King <peff@peff.net> writes:
>
>> On Thu, Sep 08, 2016 at 11:54:08AM -0700, Josh Triplett wrote:
>>
>>> > your problem description
>>> > looks perfect.  I am still not sure if the code does a reasonable
>>> > thing in MIME case, though.
>>> 
>>> It *looks* correct to me.
>> 
>> Hmm. It looks correct to me, too; ...
>> ...
>> So this is actually fixing a bug,...
>
> Yes, I actually wanted to hear that from Josh and have that in the
> proposed log message ;-).

So here is a suggested replacement.  I notice that in the MIME case,
we do not leave any blank line between the last line of the patch
and the baseinfo, which makes it look a bit strange, e.g. output of
"format-patch --attach=mimemime -1" may end like this:

    +       test_write_lines 1 2 >expect &&
    +       test_cmp expect actual
    +'
    +
     test_expect_success 'format-patch --pretty=mboxrd' '
            sp=" " &&
            cat >msg <<-INPUT_END &&
    base-commit: 6ebdac1bab966b720d776aa43ca188fe378b1f4b

    --------------mimemime--

We may want to tweak it a bit further.

-- >8 --
From: Josh Triplett <josh@joshtriplett.org>
Date: Wed, 7 Sep 2016 18:12:01 -0700
Subject: [PATCH] format-patch: show base info before email signature

Any text below the "-- " for the email signature gets treated as part of
the signature, and many mail clients will trim it from the quoted text
for a reply.  Move it above the signature, so people can reply to it
more easily.

Similarly, when producing the patch as a MIME attachment, the
original code placed the base info after the attached part, which
would be discarded.  Move the base info to the end of the part,
still inside the part boundary.

Add tests for the exact format of the email signature, and add tests
to ensure that the base info appears before the email signature when
producing a plain-text output, and that it appears before the part
boundary when producing a MIME attachment.

Signed-off-by: Josh Triplett <josh@joshtriplett.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
---
 builtin/log.c           |  4 ++--
 t/t4014-format-patch.sh | 30 +++++++++++++++++++++++++-----
 2 files changed, 27 insertions(+), 7 deletions(-)

diff --git a/builtin/log.c b/builtin/log.c
index 92dc34d..d69d5e6 100644
--- a/builtin/log.c
+++ b/builtin/log.c
@@ -1042,7 +1042,6 @@ static void make_cover_letter(struct rev_info *rev, int use_stdout,
 	diff_flush(&opts);
 
 	fprintf(rev->diffopt.file, "\n");
-	print_signature(rev->diffopt.file);
 }
 
 static const char *clean_message_id(const char *msg_id)
@@ -1720,6 +1719,7 @@ int cmd_format_patch(int argc, const char **argv, const char *prefix)
 		make_cover_letter(&rev, use_stdout,
 				  origin, nr, list, branch_name, quiet);
 		print_bases(&bases, rev.diffopt.file);
+		print_signature(rev.diffopt.file);
 		total++;
 		start_number--;
 	}
@@ -1779,13 +1779,13 @@ int cmd_format_patch(int argc, const char **argv, const char *prefix)
 		if (!use_stdout)
 			rev.shown_one = 0;
 		if (shown) {
+			print_bases(&bases, rev.diffopt.file);
 			if (rev.mime_boundary)
 				fprintf(rev.diffopt.file, "\n--%s%s--\n\n\n",
 				       mime_boundary_leader,
 				       rev.mime_boundary);
 			else
 				print_signature(rev.diffopt.file);
-			print_bases(&bases, rev.diffopt.file);
 		}
 		if (!use_stdout)
 			fclose(rev.diffopt.file);
diff --git a/t/t4014-format-patch.sh b/t/t4014-format-patch.sh
index b0579dd..535857e 100755
--- a/t/t4014-format-patch.sh
+++ b/t/t4014-format-patch.sh
@@ -754,9 +754,22 @@ test_expect_success 'format-patch --ignore-if-in-upstream HEAD' '
 	git format-patch --ignore-if-in-upstream HEAD
 '
 
+git_version="$(git --version | sed "s/.* //")"
+
+signature() {
+	printf "%s\n%s\n\n" "-- " "${1:-$git_version}"
+}
+
+test_expect_success 'format-patch default signature' '
+	git format-patch --stdout -1 | tail -n 3 >output &&
+	signature >expect &&
+	test_cmp expect output
+'
+
 test_expect_success 'format-patch --signature' '
-	git format-patch --stdout --signature="my sig" -1 >output &&
-	grep "my sig" output
+	git format-patch --stdout --signature="my sig" -1 | tail -n 3 >output &&
+	signature "my sig" >expect &&
+	test_cmp expect output
 '
 
 test_expect_success 'format-patch with format.signature config' '
@@ -1502,12 +1515,11 @@ test_expect_success 'format-patch -o overrides format.outputDirectory' '
 
 test_expect_success 'format-patch --base' '
 	git checkout side &&
-	git format-patch --stdout --base=HEAD~3 -1 >patch &&
-	grep "^base-commit:" patch >actual &&
-	grep "^prerequisite-patch-id:" patch >>actual &&
+	git format-patch --stdout --base=HEAD~3 -1 | tail -n 6 >actual &&
 	echo "base-commit: $(git rev-parse HEAD~3)" >expected &&
 	echo "prerequisite-patch-id: $(git show --patch HEAD~2 | git patch-id --stable | awk "{print \$1}")" >>expected &&
 	echo "prerequisite-patch-id: $(git show --patch HEAD~1 | git patch-id --stable | awk "{print \$1}")" >>expected &&
+	signature >> expected &&
 	test_cmp expected actual
 '
 
@@ -1605,6 +1617,14 @@ test_expect_success 'format-patch --base overrides format.useAutoBase' '
 	test_cmp expected actual
 '
 
+test_expect_success 'format-patch --base with --attach' '
+	git format-patch --attach=mimemime --stdout --base=HEAD~ -1 >patch &&
+	sed -n -e "/^base-commit:/s/.*/1/p" -e "/^---*mimemime--$/s/.*/2/p" \
+		patch >actual &&
+	test_write_lines 1 2 >expect &&
+	test_cmp expect actual
+'
+
 test_expect_success 'format-patch --pretty=mboxrd' '
 	sp=" " &&
 	cat >msg <<-INPUT_END &&
-- 
2.10.0-339-gc0c747f


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

* Re: [PATCH] Move format-patch base commit and prerequisites before email signature
  2016-09-09 19:41         ` Junio C Hamano
@ 2016-09-09 20:07           ` Josh Triplett
  2016-09-09 20:51             ` Junio C Hamano
  0 siblings, 1 reply; 14+ messages in thread
From: Josh Triplett @ 2016-09-09 20:07 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: Jeff King, git

On Fri, Sep 09, 2016 at 12:41:56PM -0700, Junio C Hamano wrote:
> So here is a suggested replacement.  I notice that in the MIME case,
> we do not leave any blank line between the last line of the patch
> and the baseinfo, which makes it look a bit strange, e.g. output of
> "format-patch --attach=mimemime -1" may end like this:
> 
>     +       test_write_lines 1 2 >expect &&
>     +       test_cmp expect actual
>     +'
>     +
>      test_expect_success 'format-patch --pretty=mboxrd' '
>             sp=" " &&
>             cat >msg <<-INPUT_END &&
>     base-commit: 6ebdac1bab966b720d776aa43ca188fe378b1f4b
> 
>     --------------mimemime--
> 
> We may want to tweak it a bit further.
> 
> -- >8 --
> From: Josh Triplett <josh@joshtriplett.org>
> Date: Wed, 7 Sep 2016 18:12:01 -0700
> Subject: [PATCH] format-patch: show base info before email signature
> 
> Any text below the "-- " for the email signature gets treated as part of
> the signature, and many mail clients will trim it from the quoted text
> for a reply.  Move it above the signature, so people can reply to it
> more easily.
> 
> Similarly, when producing the patch as a MIME attachment, the
> original code placed the base info after the attached part, which
> would be discarded.  Move the base info to the end of the part,
> still inside the part boundary.
> 
> Add tests for the exact format of the email signature, and add tests
> to ensure that the base info appears before the email signature when
> producing a plain-text output, and that it appears before the part
> boundary when producing a MIME attachment.
> 
> Signed-off-by: Josh Triplett <josh@joshtriplett.org>
> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Looks good to me.

>  builtin/log.c           |  4 ++--
>  t/t4014-format-patch.sh | 30 +++++++++++++++++++++++++-----
>  2 files changed, 27 insertions(+), 7 deletions(-)
> 
> diff --git a/builtin/log.c b/builtin/log.c
> index 92dc34d..d69d5e6 100644
> --- a/builtin/log.c
> +++ b/builtin/log.c
> @@ -1042,7 +1042,6 @@ static void make_cover_letter(struct rev_info *rev, int use_stdout,
>  	diff_flush(&opts);
>  
>  	fprintf(rev->diffopt.file, "\n");
> -	print_signature(rev->diffopt.file);
>  }
>  
>  static const char *clean_message_id(const char *msg_id)
> @@ -1720,6 +1719,7 @@ int cmd_format_patch(int argc, const char **argv, const char *prefix)
>  		make_cover_letter(&rev, use_stdout,
>  				  origin, nr, list, branch_name, quiet);
>  		print_bases(&bases, rev.diffopt.file);
> +		print_signature(rev.diffopt.file);
>  		total++;
>  		start_number--;
>  	}
> @@ -1779,13 +1779,13 @@ int cmd_format_patch(int argc, const char **argv, const char *prefix)
>  		if (!use_stdout)
>  			rev.shown_one = 0;
>  		if (shown) {
> +			print_bases(&bases, rev.diffopt.file);
>  			if (rev.mime_boundary)
>  				fprintf(rev.diffopt.file, "\n--%s%s--\n\n\n",
>  				       mime_boundary_leader,
>  				       rev.mime_boundary);
>  			else
>  				print_signature(rev.diffopt.file);
> -			print_bases(&bases, rev.diffopt.file);
>  		}
>  		if (!use_stdout)
>  			fclose(rev.diffopt.file);
> diff --git a/t/t4014-format-patch.sh b/t/t4014-format-patch.sh
> index b0579dd..535857e 100755
> --- a/t/t4014-format-patch.sh
> +++ b/t/t4014-format-patch.sh
> @@ -754,9 +754,22 @@ test_expect_success 'format-patch --ignore-if-in-upstream HEAD' '
>  	git format-patch --ignore-if-in-upstream HEAD
>  '
>  
> +git_version="$(git --version | sed "s/.* //")"
> +
> +signature() {
> +	printf "%s\n%s\n\n" "-- " "${1:-$git_version}"
> +}
> +
> +test_expect_success 'format-patch default signature' '
> +	git format-patch --stdout -1 | tail -n 3 >output &&
> +	signature >expect &&
> +	test_cmp expect output
> +'
> +
>  test_expect_success 'format-patch --signature' '
> -	git format-patch --stdout --signature="my sig" -1 >output &&
> -	grep "my sig" output
> +	git format-patch --stdout --signature="my sig" -1 | tail -n 3 >output &&
> +	signature "my sig" >expect &&
> +	test_cmp expect output
>  '
>  
>  test_expect_success 'format-patch with format.signature config' '
> @@ -1502,12 +1515,11 @@ test_expect_success 'format-patch -o overrides format.outputDirectory' '
>  
>  test_expect_success 'format-patch --base' '
>  	git checkout side &&
> -	git format-patch --stdout --base=HEAD~3 -1 >patch &&
> -	grep "^base-commit:" patch >actual &&
> -	grep "^prerequisite-patch-id:" patch >>actual &&
> +	git format-patch --stdout --base=HEAD~3 -1 | tail -n 6 >actual &&
>  	echo "base-commit: $(git rev-parse HEAD~3)" >expected &&
>  	echo "prerequisite-patch-id: $(git show --patch HEAD~2 | git patch-id --stable | awk "{print \$1}")" >>expected &&
>  	echo "prerequisite-patch-id: $(git show --patch HEAD~1 | git patch-id --stable | awk "{print \$1}")" >>expected &&
> +	signature >> expected &&
>  	test_cmp expected actual
>  '
>  
> @@ -1605,6 +1617,14 @@ test_expect_success 'format-patch --base overrides format.useAutoBase' '
>  	test_cmp expected actual
>  '
>  
> +test_expect_success 'format-patch --base with --attach' '
> +	git format-patch --attach=mimemime --stdout --base=HEAD~ -1 >patch &&
> +	sed -n -e "/^base-commit:/s/.*/1/p" -e "/^---*mimemime--$/s/.*/2/p" \
> +		patch >actual &&
> +	test_write_lines 1 2 >expect &&
> +	test_cmp expect actual
> +'
> +
>  test_expect_success 'format-patch --pretty=mboxrd' '
>  	sp=" " &&
>  	cat >msg <<-INPUT_END &&
> -- 
> 2.10.0-339-gc0c747f
> 

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

* Re: [PATCH] Move format-patch base commit and prerequisites before email signature
  2016-09-09 20:07           ` Josh Triplett
@ 2016-09-09 20:51             ` Junio C Hamano
  2016-09-09 21:00               ` Josh Triplett
  0 siblings, 1 reply; 14+ messages in thread
From: Junio C Hamano @ 2016-09-09 20:51 UTC (permalink / raw)
  To: Josh Triplett; +Cc: Jeff King, git

Josh Triplett <josh@joshtriplett.org> writes:

> On Fri, Sep 09, 2016 at 12:41:56PM -0700, Junio C Hamano wrote:
>> So here is a suggested replacement.  I notice that in the MIME case,
>> we do not leave any blank line between the last line of the patch
>> and the baseinfo, which makes it look a bit strange, e.g. output of
>> "format-patch --attach=mimemime -1" may end like this:
>> 
>>     +       test_write_lines 1 2 >expect &&
>>     +       test_cmp expect actual
>>     +'
>>     +
>>      test_expect_success 'format-patch --pretty=mboxrd' '
>>             sp=" " &&
>>             cat >msg <<-INPUT_END &&
>>     base-commit: 6ebdac1bab966b720d776aa43ca188fe378b1f4b
>> 
>>     --------------mimemime--
>> 
>> We may want to tweak it a bit further.
>>  ...
>
> Looks good to me.

Thanks.

Do you mean that the base information that appears immediately after
the patch text (either for MIME case or plain-text) does not bother
you, though?

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

* Re: [PATCH] Move format-patch base commit and prerequisites before email signature
  2016-09-09 20:51             ` Junio C Hamano
@ 2016-09-09 21:00               ` Josh Triplett
  2016-09-09 21:16                 ` Junio C Hamano
  0 siblings, 1 reply; 14+ messages in thread
From: Josh Triplett @ 2016-09-09 21:00 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: Jeff King, git

On Fri, Sep 09, 2016 at 01:51:04PM -0700, Junio C Hamano wrote:
> Josh Triplett <josh@joshtriplett.org> writes:
> 
> > On Fri, Sep 09, 2016 at 12:41:56PM -0700, Junio C Hamano wrote:
> >> So here is a suggested replacement.  I notice that in the MIME case,
> >> we do not leave any blank line between the last line of the patch
> >> and the baseinfo, which makes it look a bit strange, e.g. output of
> >> "format-patch --attach=mimemime -1" may end like this:
> >> 
> >>     +       test_write_lines 1 2 >expect &&
> >>     +       test_cmp expect actual
> >>     +'
> >>     +
> >>      test_expect_success 'format-patch --pretty=mboxrd' '
> >>             sp=" " &&
> >>             cat >msg <<-INPUT_END &&
> >>     base-commit: 6ebdac1bab966b720d776aa43ca188fe378b1f4b
> >> 
> >>     --------------mimemime--
> >> 
> >> We may want to tweak it a bit further.
> >>  ...
> >
> > Looks good to me.
> 
> Thanks.
> 
> Do you mean that the base information that appears immediately after
> the patch text (either for MIME case or plain-text) does not bother
> you, though?

Sorry, I should have clarified that further.  I meant that the
additional tests looked good to me.

As it turns out, the patch I used to test this on happened to have a
blank line as the last line of context before the base-commit line, so
I'd overlooked this in the non-MIME case.  The issue you mentioned does
apply to both the MIME and non-MIME cases, and I agree that it needs
fixing.  It doesn't seem like a functional issue, but aesthetically it
doesn't look good.

Do you plan to make that change to print an additional blank line
(likely inside print_bases), or should I?

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

* Re: [PATCH] Move format-patch base commit and prerequisites before email signature
  2016-09-09 21:00               ` Josh Triplett
@ 2016-09-09 21:16                 ` Junio C Hamano
  2016-09-14 22:57                   ` Junio C Hamano
  0 siblings, 1 reply; 14+ messages in thread
From: Junio C Hamano @ 2016-09-09 21:16 UTC (permalink / raw)
  To: Josh Triplett; +Cc: Jeff King, git

Josh Triplett <josh@joshtriplett.org> writes:

> It doesn't seem like a functional issue, but aesthetically it
> doesn't look good.
>
> Do you plan to make that change to print an additional blank line
> (likely inside print_bases), or should I?

I do not mind doing it myself, but I am already in today's
integration cycle (which will merge a handful of topics to
'master'), so I won't get around to it for some time.  If you are
inclined to, please be my guest ;-)

Thanks.

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

* Re: [PATCH] Move format-patch base commit and prerequisites before email signature
  2016-09-09 21:16                 ` Junio C Hamano
@ 2016-09-14 22:57                   ` Junio C Hamano
  2016-09-14 23:52                     ` Josh Triplett
  0 siblings, 1 reply; 14+ messages in thread
From: Junio C Hamano @ 2016-09-14 22:57 UTC (permalink / raw)
  To: Josh Triplett; +Cc: Jeff King, git

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

> I do not mind doing it myself, but I am already in today's
> integration cycle (which will merge a handful of topics to
> 'master'), so I won't get around to it for some time.  If you are
> inclined to, please be my guest ;-)

I queued this on top for now; I think it can be just squashed into
your patch.  Please say "I agree" and I'll make it happen, or say
"that's wrong" followed by a replacement patch ;-).

Thanks.

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

diff --git a/builtin/log.c b/builtin/log.c
index d69d5e6..cd9c4a4 100644
--- a/builtin/log.c
+++ b/builtin/log.c
@@ -1360,7 +1360,7 @@ static void print_bases(struct base_tree_info *bases, FILE *file)
 		return;
 
 	/* Show the base commit */
-	fprintf(file, "base-commit: %s\n", oid_to_hex(&bases->base_commit));
+	fprintf(file, "\nbase-commit: %s\n", oid_to_hex(&bases->base_commit));
 
 	/* Show the prerequisite patches */
 	for (i = bases->nr_patch_id - 1; i >= 0; i--)
-- 
2.10.0-458-g8cce42d


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

* Re: [PATCH] Move format-patch base commit and prerequisites before email signature
  2016-09-14 22:57                   ` Junio C Hamano
@ 2016-09-14 23:52                     ` Josh Triplett
  2016-09-15 17:06                       ` Junio C Hamano
  0 siblings, 1 reply; 14+ messages in thread
From: Josh Triplett @ 2016-09-14 23:52 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: Jeff King, git

On Wed, Sep 14, 2016 at 03:57:36PM -0700, Junio C Hamano wrote:
> Junio C Hamano <gitster@pobox.com> writes:
> 
> > I do not mind doing it myself, but I am already in today's
> > integration cycle (which will merge a handful of topics to
> > 'master'), so I won't get around to it for some time.  If you are
> > inclined to, please be my guest ;-)
> 
> I queued this on top for now; I think it can be just squashed into
> your patch.  Please say "I agree" and I'll make it happen, or say
> "that's wrong" followed by a replacement patch ;-).

"I agree". :)

I'd suggest squashing in an *additional* patch to the testsuite to
ensure the presence of the blank line:

diff --git a/t/t4014-format-patch.sh b/t/t4014-format-patch.sh
index 535857e..8d90a6e 100755
--- a/t/t4014-format-patch.sh
+++ b/t/t4014-format-patch.sh
@@ -1515,8 +1515,9 @@ test_expect_success 'format-patch -o overrides format.outputDirectory' '
 
 test_expect_success 'format-patch --base' '
 	git checkout side &&
-	git format-patch --stdout --base=HEAD~3 -1 | tail -n 6 >actual &&
-	echo "base-commit: $(git rev-parse HEAD~3)" >expected &&
+	git format-patch --stdout --base=HEAD~3 -1 | tail -n 7 >actual &&
+	echo >expected &&
+	echo "base-commit: $(git rev-parse HEAD~3)" >>expected &&
 	echo "prerequisite-patch-id: $(git show --patch HEAD~2 | git patch-id --stable | awk "{print \$1}")" >>expected &&
 	echo "prerequisite-patch-id: $(git show --patch HEAD~1 | git patch-id --stable | awk "{print \$1}")" >>expected &&
 	signature >> expected &&

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

* Re: [PATCH] Move format-patch base commit and prerequisites before email signature
  2016-09-14 23:52                     ` Josh Triplett
@ 2016-09-15 17:06                       ` Junio C Hamano
  0 siblings, 0 replies; 14+ messages in thread
From: Junio C Hamano @ 2016-09-15 17:06 UTC (permalink / raw)
  To: Josh Triplett; +Cc: Jeff King, git

Josh Triplett <josh@joshtriplett.org> writes:

> I'd suggest squashing in an *additional* patch to the testsuite to
> ensure the presence of the blank line:

Thanks, will do.

> diff --git a/t/t4014-format-patch.sh b/t/t4014-format-patch.sh
> index 535857e..8d90a6e 100755
> --- a/t/t4014-format-patch.sh
> +++ b/t/t4014-format-patch.sh
> @@ -1515,8 +1515,9 @@ test_expect_success 'format-patch -o overrides format.outputDirectory' '
>  
>  test_expect_success 'format-patch --base' '
>  	git checkout side &&
> -	git format-patch --stdout --base=HEAD~3 -1 | tail -n 6 >actual &&
> -	echo "base-commit: $(git rev-parse HEAD~3)" >expected &&
> +	git format-patch --stdout --base=HEAD~3 -1 | tail -n 7 >actual &&
> +	echo >expected &&
> +	echo "base-commit: $(git rev-parse HEAD~3)" >>expected &&
>  	echo "prerequisite-patch-id: $(git show --patch HEAD~2 | git patch-id --stable | awk "{print \$1}")" >>expected &&
>  	echo "prerequisite-patch-id: $(git show --patch HEAD~1 | git patch-id --stable | awk "{print \$1}")" >>expected &&
>  	signature >> expected &&

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

end of thread, other threads:[~2016-09-15 17:06 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-09-08  1:12 [PATCH] Move format-patch base commit and prerequisites before email signature Josh Triplett
2016-09-08 18:34 ` Junio C Hamano
2016-09-08 18:54   ` Josh Triplett
2016-09-08 19:11     ` Junio C Hamano
2016-09-08 20:08     ` Jeff King
2016-09-08 21:24       ` Junio C Hamano
2016-09-09 19:41         ` Junio C Hamano
2016-09-09 20:07           ` Josh Triplett
2016-09-09 20:51             ` Junio C Hamano
2016-09-09 21:00               ` Josh Triplett
2016-09-09 21:16                 ` Junio C Hamano
2016-09-14 22:57                   ` Junio C Hamano
2016-09-14 23:52                     ` Josh Triplett
2016-09-15 17:06                       ` Junio C Hamano

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