Skip to content

Commit 50cd54e

Browse files
bk2204gitster
authored andcommitted
format-patch: make cover letters always text/plain
When formatting a series of patches using --attach and --cover-letter, the cover letter lacks the closing MIME boundary, violating RFC 2046. Certain clients, such as Thunderbird, discard the message body in such a case. Since the cover letter is just one part and sending it as multipart/mixed is not very useful, always emit it as text/plain, avoiding the boundary problem altogether. Reported-by: Patrick Hemmer <[email protected]> Signed-off-by: brian m. carlson <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 468165c commit 50cd54e

File tree

4 files changed

+16
-5
lines changed

4 files changed

+16
-5
lines changed

builtin/log.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1019,7 +1019,7 @@ static void make_cover_letter(struct rev_info *rev, int use_stdout,
10191019
open_next_file(NULL, rev->numbered_files ? NULL : "cover-letter", rev, quiet))
10201020
return;
10211021

1022-
log_write_email_headers(rev, head, &pp.after_subject, &need_8bit_cte);
1022+
log_write_email_headers(rev, head, &pp.after_subject, &need_8bit_cte, 0);
10231023

10241024
for (i = 0; !need_8bit_cte && i < nr; i++) {
10251025
const char *buf = get_commit_buffer(list[i], NULL);

log-tree.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -362,7 +362,8 @@ void fmt_output_email_subject(struct strbuf *sb, struct rev_info *opt)
362362

363363
void log_write_email_headers(struct rev_info *opt, struct commit *commit,
364364
const char **extra_headers_p,
365-
int *need_8bit_cte_p)
365+
int *need_8bit_cte_p,
366+
int maybe_multipart)
366367
{
367368
const char *extra_headers = opt->extra_headers;
368369
const char *name = oid_to_hex(opt->zero_commit ?
@@ -385,7 +386,7 @@ void log_write_email_headers(struct rev_info *opt, struct commit *commit,
385386
opt->ref_message_ids->items[i].string);
386387
graph_show_oneline(opt->graph);
387388
}
388-
if (opt->mime_boundary) {
389+
if (opt->mime_boundary && maybe_multipart) {
389390
static char subject_buffer[1024];
390391
static char buffer[1024];
391392
struct strbuf filename = STRBUF_INIT;
@@ -610,7 +611,7 @@ void show_log(struct rev_info *opt)
610611

611612
if (cmit_fmt_is_mail(opt->commit_format)) {
612613
log_write_email_headers(opt, commit, &extra_headers,
613-
&ctx.need_8bit_cte);
614+
&ctx.need_8bit_cte, 1);
614615
ctx.rev = opt;
615616
ctx.print_email_subject = 1;
616617
} else if (opt->commit_format != CMIT_FMT_USERFORMAT) {

log-tree.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,8 @@ void format_decorations_extended(struct strbuf *sb, const struct commit *commit,
2727
void show_decorations(struct rev_info *opt, struct commit *commit);
2828
void log_write_email_headers(struct rev_info *opt, struct commit *commit,
2929
const char **extra_headers_p,
30-
int *need_8bit_cte_p);
30+
int *need_8bit_cte_p,
31+
int maybe_multipart);
3132
void load_ref_decorations(struct decoration_filter *filter, int flags);
3233

3334
#define FORMAT_PATCH_NAME_MAX 64

t/t4014-format-patch.sh

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1661,6 +1661,15 @@ test_expect_success 'format-patch --base with --attach' '
16611661
test_write_lines 1 2 >expect &&
16621662
test_cmp expect actual
16631663
'
1664+
test_expect_success 'format-patch --attach cover-letter only is non-multipart' '
1665+
test_when_finished "rm -fr patches" &&
1666+
git format-patch -o patches --cover-letter --attach=mimemime --base=HEAD~ -1 &&
1667+
! egrep "^--+mimemime" patches/0000*.patch &&
1668+
egrep "^--+mimemime$" patches/0001*.patch >output &&
1669+
test_line_count = 2 output &&
1670+
egrep "^--+mimemime--$" patches/0001*.patch >output &&
1671+
test_line_count = 1 output
1672+
'
16641673

16651674
test_expect_success 'format-patch --pretty=mboxrd' '
16661675
sp=" " &&

0 commit comments

Comments
 (0)