Linus Torvalds <[email protected]> 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: <[email protected]>
>   From: Linus Torvalds <[email protected]>
>   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...@mail.gmail.com>
+                */
+               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,

Reply via email to