threads / patch / 44035

patchMove format-patch base commit and prerequisites before email signature

Subject: [PATCH] Move format-patch base commit and prerequisites before email signature

## tl;dr

14 messages between Sep 8, 2016 and Sep 15, 2016. Diffs are folded; open one to read it.

replies: 13people: 3as markdown or json

Josh Triplett· Sep 8, 2016, 01:12 UTC · lore

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(-)
Show changes to 2 files +19 −7

builtin/log.c, t/t4014-format-patch.sh

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
Junio C Hamano· Sep 8, 2016, 18:34 UTC · re: Josh Triplett · lore

Re: [PATCH] Move format-patch base commit and prerequisites before email signature

Josh Triplett <josh@joshtriplett.org> writes:
Show 15 quoted lines
> 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.
Show 13 quoted lines
> 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.
Josh Triplett· Sep 8, 2016, 18:54 UTC · re: Junio C Hamano · lore

Re: [PATCH] Move format-patch base commit and prerequisites before email signature

On Thu, Sep 08, 2016 at 11:34:15AM -0700, Junio C Hamano wrote:
Show 19 quoted lines
> 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.
Show 19 quoted lines
> 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).

Show 15 quoted lines
> 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
Junio C Hamano· Sep 8, 2016, 19:11 UTC · re: Josh Triplett · lore

Re: [PATCH] Move format-patch base commit and prerequisites before email signature

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.

Jeff King· Sep 8, 2016, 20:08 UTC · re: Josh Triplett · lore

Re: [PATCH] Move format-patch base commit and prerequisites before email signature

On Thu, Sep 08, 2016 at 11:54:08AM -0700, Josh Triplett wrote:
Show 5 quoted lines
> > 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
Junio C Hamano· Sep 8, 2016, 21:24 UTC · re: Jeff King · lore

Re: [PATCH] Move format-patch base commit and prerequisites before email signature

Jeff King <peff@peff.net> writes:
Show 11 quoted lines
> 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 ;-).

Junio C Hamano· Sep 9, 2016, 19:41 UTC · re: Junio C Hamano · lore

Re: [PATCH] Move format-patch base commit and prerequisites before email signature

Junio C Hamano <gitster@pobox.com> writes:
Show 16 quoted lines
> 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(-)
Show changes to 2 files +27 −7

builtin/log.c, t/t4014-format-patch.sh

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
Josh Triplett· Sep 9, 2016, 20:07 UTC · re: Junio C Hamano · lore

Re: [PATCH] Move format-patch base commit and prerequisites before email signature

On Fri, Sep 09, 2016 at 12:41:56PM -0700, Junio C Hamano wrote:
Show 40 quoted lines
> 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.
Show 101 quoted lines
>  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
> 
Junio C Hamano· Sep 9, 2016, 20:51 UTC · re: Josh Triplett · lore

Re: [PATCH] Move format-patch base commit and prerequisites before email signature

Josh Triplett <josh@joshtriplett.org> writes:
Show 21 quoted lines
> 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?

Josh Triplett· Sep 9, 2016, 21:00 UTC · re: Junio C Hamano · lore

Re: [PATCH] Move format-patch base commit and prerequisites before email signature

On Fri, Sep 09, 2016 at 01:51:04PM -0700, Junio C Hamano wrote:
Show 29 quoted lines
> 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?

Junio C Hamano· Sep 9, 2016, 21:16 UTC · re: Josh Triplett · lore

Re: [PATCH] Move format-patch base commit and prerequisites before email signature

Josh Triplett <josh@joshtriplett.org> writes:
Show 5 quoted lines
> 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.
Junio C Hamano· Sep 14, 2016, 22:57 UTC · re: Junio C Hamano · lore

Re: [PATCH] Move format-patch base commit and prerequisites before email signature

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(-)
Show changes to builtin/log.c +1 −1
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
Josh Triplett· Sep 14, 2016, 23:52 UTC · re: Junio C Hamano · lore

Re: [PATCH] Move format-patch base commit and prerequisites before email signature

On Wed, Sep 14, 2016 at 03:57:36PM -0700, Junio C Hamano wrote:
Show 10 quoted lines
> 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:

Show changes to t/t4014-format-patch.sh +3 −2
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 &&
Junio C Hamano· Sep 15, 2016, 17:06 UTC · re: Josh Triplett · lore

Re: [PATCH] Move format-patch base commit and prerequisites before email signature

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.
Show 16 quoted lines
> 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 &&

← back to recent threads