Re: "Problems" with git format-patch --thread email header ordering

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Linus Torvalds <torvalds@xxxxxxxxxxxxxxxxxxxx> writes:

> While it's true that header ordering isn't specified, there's a common
> "canonical" order that the headers are listed in. To quote rfc822:
> ...
>             body must occur AFTER  the  headers.   It  is  recommended
>             that,  if  present,  headers be sent in the order "Return-
>             Path", "Received", "Date",  "From",  "Subject",  "Sender",
>             "To", "cc", etc.
>
> But git format-patch does create the email headers out in a different
> order than the one recommended.  When you do "git format-patch
> --thread" to create the emails, the header ordering looks roughly like
> this:
>
>   Message-Id: <cover.1552606170.git.torvalds@xxxxxxxxxxxxxxxxxxxx>
>   From: Linus Torvalds <torvalds@xxxxxxxxxxxxxxxxxxxx>
>   Date: Thu, 14 Mar 2019 16:29:30 -0700
>   Subject: [PATCH 0/6] *** SUBJECT HERE ***
>   MIME-Version: 1.0
>   Content-Type: text/plain; charset=UTF-8
>   Content-Transfer-Encoding: 8bit
> ...
> And yes, if somebody from Google on this list wants to bring this up
> with the gmail team, I wish you the best of luck. Let me know how it
> goes.

I obviously won't do the last one myself, but if the issue is only
to swap from and date, then this may be sufficient, perhaps?

I suspect that there would be fallouts in t/ directory before we can
call this a fix.

 pretty.c | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/pretty.c b/pretty.c
index f496f0f128..40c7236fbc 100644
--- a/pretty.c
+++ b/pretty.c
@@ -452,6 +452,14 @@ void pp_user_info(struct pretty_print_context *pp,
 		map_user(pp->mailmap, &mailbuf, &maillen, &namebuf, &namelen);
 
 	if (cmit_fmt_is_mail(pp->fmt)) {
+
+		/* 
+		 * Date: before From:
+		 * cf. <CAHk-=whP1stFZNAaJiMi5eZ9rj0MRt20Y_yHVczZPH+O01d+sA@xxxxxxxxxxxxxx>
+		 */
+		strbuf_addf(sb, "Date: %s\n",
+			    show_ident_date(&ident, DATE_MODE(RFC2822)));
+
 		if (pp->from_ident && ident_cmp(pp->from_ident, &ident)) {
 			struct strbuf buf = STRBUF_INIT;
 
@@ -502,8 +510,7 @@ void pp_user_info(struct pretty_print_context *pp,
 		break;
 	case CMIT_FMT_EMAIL:
 	case CMIT_FMT_MBOXRD:
-		strbuf_addf(sb, "Date: %s\n",
-			    show_ident_date(&ident, DATE_MODE(RFC2822)));
+		/* has been done much earlier */
 		break;
 	case CMIT_FMT_FULLER:
 		strbuf_addf(sb, "%sDate: %s\n", what,



[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux