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

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

 



Julian Andres Klode <jak@xxxxxxxxxxxxx> writes:

>> What Thomas Found out was that the exact same email with
>> 
>>     Message-Id/From/Date/Subject/To
>> 
>> (in that order) does not work, but
>> 
>>     Date/From/Subject/To/Message-Id
>> 
>> does work. Weird and "wonderful". But there might be a lot of other
>> orderings that work or don't.
>> 
>> Having looked through some other emails, I know that
>> 
>>     From/To/Subject/Date/Message-Id
>>     Subject/To/References/From/Message-ID/Date
>> 
>> also works.  Which makes me suspect that it's the Message-ID line that matters.
>
> I also know that gmail rewrites the Message-ID / creates one if it is
> missing or "odd" (such as ends in a .). It those probably makes sense
> in that twisted world view to require that to be fairly late...

Here is a patch that is not polished enough to be commited yet but
should be testable (as I suspect that existing tests need to be
adjusted).

-- >8 --

Subject: [PATCH] format-patch: move message-id and related headers to the end

It has been reported that GMail MSA has an undocumented limitation
that makes it reject or accept depending on some ordering of headers
in the incoming message.  The current suspicion is that they want to
see the Message-Id: header near the end, so let's try doing so and
see what happens..

Signed-off-by: Junio C Hamano <gitster@xxxxxxxxx>
---
 log-tree.c | 30 ++++++++++++++++++++++--------
 1 file changed, 22 insertions(+), 8 deletions(-)

diff --git a/log-tree.c b/log-tree.c
index 1e56df62a7..111b947264 100644
--- a/log-tree.c
+++ b/log-tree.c
@@ -363,24 +363,27 @@ void log_write_email_headers(struct rev_info *opt, struct commit *commit,
 	const char *extra_headers = opt->extra_headers;
 	const char *name = oid_to_hex(opt->zero_commit ?
 				      &null_oid : &commit->object.oid);
+	struct strbuf message_ids = STRBUF_INIT;
 
 	*need_8bit_cte_p = 0; /* unknown */
 
 	fprintf(opt->diffopt.file, "From %s Mon Sep 17 00:00:00 2001\n", name);
 	graph_show_oneline(opt->graph);
-	if (opt->message_id) {
-		fprintf(opt->diffopt.file, "Message-Id: <%s>\n", opt->message_id);
-		graph_show_oneline(opt->graph);
-	}
+
+	if (opt->message_id)
+		strbuf_addf(&message_ids, "Message-Id: <%s>\n", opt->message_id);
+
 	if (opt->ref_message_ids && opt->ref_message_ids->nr > 0) {
 		int i, n;
 		n = opt->ref_message_ids->nr;
-		fprintf(opt->diffopt.file, "In-Reply-To: <%s>\n", opt->ref_message_ids->items[n-1].string);
+		strbuf_addf(&message_ids, "In-Reply-To: <%s>\n",
+			    opt->ref_message_ids->items[n-1].string);
 		for (i = 0; i < n; i++)
-			fprintf(opt->diffopt.file, "%s<%s>\n", (i > 0 ? "\t" : "References: "),
-			       opt->ref_message_ids->items[i].string);
-		graph_show_oneline(opt->graph);
+			strbuf_addf(&message_ids, "%s<%s>\n",
+				    (i > 0 ? "\t" : "References: "),
+				    opt->ref_message_ids->items[i].string);
 	}
+
 	if (opt->mime_boundary && maybe_multipart) {
 		static struct strbuf subject_buffer = STRBUF_INIT;
 		static struct strbuf buffer = STRBUF_INIT;
@@ -425,6 +428,17 @@ void log_write_email_headers(struct rev_info *opt, struct commit *commit,
 		opt->diffopt.stat_sep = buffer.buf;
 		strbuf_release(&filename);
 	}
+
+	if (message_ids.len) {
+		static struct strbuf buf = STRBUF_INIT;
+
+		strbuf_reset(&buf);
+		strbuf_addbuf(&buf, &message_ids);
+		if (extra_headers)
+			strbuf_addstr(&buf, extra_headers);
+		extra_headers = buf.buf;
+	}
+
 	*extra_headers_p = extra_headers;
 }
 
-- 
2.21.0-197-g893dd55891




[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