Merge branch 'bc/format-patch-cover-no-attach'

"git format-patch --cover --attach" created a broken MIME multipart
message for the cover letter, which has been fixed by keeping the
cover letter as plain text file.

* bc/format-patch-cover-no-attach:
  format-patch: make cover letters always text/plain
This commit is contained in:
Junio C Hamano
2018-05-23 14:38:21 +09:00
4 changed files with 16 additions and 5 deletions

View File

@ -1019,7 +1019,7 @@ static void make_cover_letter(struct rev_info *rev, int use_stdout,
open_next_file(NULL, rev->numbered_files ? NULL : "cover-letter", rev, quiet)) open_next_file(NULL, rev->numbered_files ? NULL : "cover-letter", rev, quiet))
return; return;
log_write_email_headers(rev, head, &pp.after_subject, &need_8bit_cte); log_write_email_headers(rev, head, &pp.after_subject, &need_8bit_cte, 0);
for (i = 0; !need_8bit_cte && i < nr; i++) { for (i = 0; !need_8bit_cte && i < nr; i++) {
const char *buf = get_commit_buffer(list[i], NULL); const char *buf = get_commit_buffer(list[i], NULL);

View File

@ -362,7 +362,8 @@ void fmt_output_email_subject(struct strbuf *sb, struct rev_info *opt)
void log_write_email_headers(struct rev_info *opt, struct commit *commit, void log_write_email_headers(struct rev_info *opt, struct commit *commit,
const char **extra_headers_p, const char **extra_headers_p,
int *need_8bit_cte_p) int *need_8bit_cte_p,
int maybe_multipart)
{ {
const char *extra_headers = opt->extra_headers; const char *extra_headers = opt->extra_headers;
const char *name = oid_to_hex(opt->zero_commit ? 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,
opt->ref_message_ids->items[i].string); opt->ref_message_ids->items[i].string);
graph_show_oneline(opt->graph); graph_show_oneline(opt->graph);
} }
if (opt->mime_boundary) { if (opt->mime_boundary && maybe_multipart) {
static char subject_buffer[1024]; static char subject_buffer[1024];
static char buffer[1024]; static char buffer[1024];
struct strbuf filename = STRBUF_INIT; struct strbuf filename = STRBUF_INIT;
@ -611,7 +612,7 @@ void show_log(struct rev_info *opt)
if (cmit_fmt_is_mail(opt->commit_format)) { if (cmit_fmt_is_mail(opt->commit_format)) {
log_write_email_headers(opt, commit, &extra_headers, log_write_email_headers(opt, commit, &extra_headers,
&ctx.need_8bit_cte); &ctx.need_8bit_cte, 1);
ctx.rev = opt; ctx.rev = opt;
ctx.print_email_subject = 1; ctx.print_email_subject = 1;
} else if (opt->commit_format != CMIT_FMT_USERFORMAT) { } else if (opt->commit_format != CMIT_FMT_USERFORMAT) {

View File

@ -27,7 +27,8 @@ void format_decorations_extended(struct strbuf *sb, const struct commit *commit,
void show_decorations(struct rev_info *opt, struct commit *commit); void show_decorations(struct rev_info *opt, struct commit *commit);
void log_write_email_headers(struct rev_info *opt, struct commit *commit, void log_write_email_headers(struct rev_info *opt, struct commit *commit,
const char **extra_headers_p, const char **extra_headers_p,
int *need_8bit_cte_p); int *need_8bit_cte_p,
int maybe_multipart);
void load_ref_decorations(struct decoration_filter *filter, int flags); void load_ref_decorations(struct decoration_filter *filter, int flags);
#define FORMAT_PATCH_NAME_MAX 64 #define FORMAT_PATCH_NAME_MAX 64

View File

@ -1661,6 +1661,15 @@ test_expect_success 'format-patch --base with --attach' '
test_write_lines 1 2 >expect && test_write_lines 1 2 >expect &&
test_cmp expect actual test_cmp expect actual
' '
test_expect_success 'format-patch --attach cover-letter only is non-multipart' '
test_when_finished "rm -fr patches" &&
git format-patch -o patches --cover-letter --attach=mimemime --base=HEAD~ -1 &&
! egrep "^--+mimemime" patches/0000*.patch &&
egrep "^--+mimemime$" patches/0001*.patch >output &&
test_line_count = 2 output &&
egrep "^--+mimemime--$" patches/0001*.patch >output &&
test_line_count = 1 output
'
test_expect_success 'format-patch --pretty=mboxrd' ' test_expect_success 'format-patch --pretty=mboxrd' '
sp=" " && sp=" " &&