Skip to content

Commit cd315b3

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 1245849 + 893dd55 commit cd315b3

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
@@ -363,24 +363,27 @@ void log_write_email_headers(struct rev_info *opt, struct commit *commit,
363363
const char *extra_headers = opt->extra_headers;
364364
const char *name = oid_to_hex(opt->zero_commit ?
365365
&null_oid : &commit->object.oid);
366+
struct strbuf message_ids = STRBUF_INIT;
366367

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

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

0 commit comments

Comments
 (0)