Skip to content

Commit 90354d9

Browse files
committed
Merge branch 'jc/format-patch-delay-message-id' into pu
The location "git format-patch --thread" adds the Message-Id: header in the series of header fields has been moved down, which may help working around a suspected bug in GMail MSA, reported at <CAHk-=whP1stFZNAaJiMi5eZ9rj0MRt20Y_yHVczZPH+O01d+sA@mail.gmail.com> * jc/format-patch-delay-message-id: format-patch: move message-id and related headers to the end
2 parents b133308 + 893dd55 commit 90354d9

File tree

1 file changed

+22
-8
lines changed

1 file changed

+22
-8
lines changed

log-tree.c

Lines changed: 22 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -364,24 +364,27 @@ void log_write_email_headers(struct rev_info *opt, struct commit *commit,
364364
const char *extra_headers = opt->extra_headers;
365365
const char *name = oid_to_hex(opt->zero_commit ?
366366
&null_oid : &commit->object.oid);
367+
struct strbuf message_ids = STRBUF_INIT;
367368

368369
*need_8bit_cte_p = 0; /* unknown */
369370

370371
fprintf(opt->diffopt.file, "From %s Mon Sep 17 00:00:00 2001\n", name);
371372
graph_show_oneline(opt->graph);
372-
if (opt->message_id) {
373-
fprintf(opt->diffopt.file, "Message-Id: <%s>\n", opt->message_id);
374-
graph_show_oneline(opt->graph);
375-
}
373+
374+
if (opt->message_id)
375+
strbuf_addf(&message_ids, "Message-Id: <%s>\n", opt->message_id);
376+
376377
if (opt->ref_message_ids && opt->ref_message_ids->nr > 0) {
377378
int i, n;
378379
n = opt->ref_message_ids->nr;
379-
fprintf(opt->diffopt.file, "In-Reply-To: <%s>\n", opt->ref_message_ids->items[n-1].string);
380+
strbuf_addf(&message_ids, "In-Reply-To: <%s>\n",
381+
opt->ref_message_ids->items[n-1].string);
380382
for (i = 0; i < n; i++)
381-
fprintf(opt->diffopt.file, "%s<%s>\n", (i > 0 ? "\t" : "References: "),
382-
opt->ref_message_ids->items[i].string);
383-
graph_show_oneline(opt->graph);
383+
strbuf_addf(&message_ids, "%s<%s>\n",
384+
(i > 0 ? "\t" : "References: "),
385+
opt->ref_message_ids->items[i].string);
384386
}
387+
385388
if (opt->mime_boundary && maybe_multipart) {
386389
static struct strbuf subject_buffer = STRBUF_INIT;
387390
static struct strbuf buffer = STRBUF_INIT;
@@ -426,6 +429,17 @@ void log_write_email_headers(struct rev_info *opt, struct commit *commit,
426429
opt->diffopt.stat_sep = buffer.buf;
427430
strbuf_release(&filename);
428431
}
432+
433+
if (message_ids.len) {
434+
static struct strbuf buf = STRBUF_INIT;
435+
436+
strbuf_reset(&buf);
437+
strbuf_addbuf(&buf, &message_ids);
438+
if (extra_headers)
439+
strbuf_addstr(&buf, extra_headers);
440+
extra_headers = buf.buf;
441+
}
442+
429443
*extra_headers_p = extra_headers;
430444
}
431445

0 commit comments

Comments
 (0)