Merge branch 'jk/pretty-subject-cleanup'
Code clean-up in the "git log" machinery that implements custom log message formatting. * jk/pretty-subject-cleanup: format-patch: fix leak of empty header string format-patch: simplify after-subject MIME header handling format-patch: return an allocated string from log_write_email_headers() log: do not set up extra_headers for non-email formats pretty: drop print_email_subject flag pretty: split oneline and email subject printing shortlog: stop setting pp.print_email_subject
This commit is contained in:
22
log-tree.c
22
log-tree.c
@@ -470,16 +470,19 @@ void fmt_output_email_subject(struct strbuf *sb, struct rev_info *opt)
|
||||
}
|
||||
|
||||
void log_write_email_headers(struct rev_info *opt, struct commit *commit,
|
||||
const char **extra_headers_p,
|
||||
char **extra_headers_p,
|
||||
int *need_8bit_cte_p,
|
||||
int maybe_multipart)
|
||||
{
|
||||
const char *extra_headers = opt->extra_headers;
|
||||
struct strbuf headers = STRBUF_INIT;
|
||||
const char *name = oid_to_hex(opt->zero_commit ?
|
||||
null_oid() : &commit->object.oid);
|
||||
|
||||
*need_8bit_cte_p = 0; /* unknown */
|
||||
|
||||
if (opt->extra_headers && *opt->extra_headers)
|
||||
strbuf_addstr(&headers, opt->extra_headers);
|
||||
|
||||
fprintf(opt->diffopt.file, "From %s Mon Sep 17 00:00:00 2001\n", name);
|
||||
graph_show_oneline(opt->graph);
|
||||
if (opt->message_id) {
|
||||
@@ -496,16 +499,13 @@ void log_write_email_headers(struct rev_info *opt, struct commit *commit,
|
||||
graph_show_oneline(opt->graph);
|
||||
}
|
||||
if (opt->mime_boundary && maybe_multipart) {
|
||||
static struct strbuf subject_buffer = STRBUF_INIT;
|
||||
static struct strbuf buffer = STRBUF_INIT;
|
||||
struct strbuf filename = STRBUF_INIT;
|
||||
*need_8bit_cte_p = -1; /* NEVER */
|
||||
|
||||
strbuf_reset(&subject_buffer);
|
||||
strbuf_reset(&buffer);
|
||||
|
||||
strbuf_addf(&subject_buffer,
|
||||
"%s"
|
||||
strbuf_addf(&headers,
|
||||
"MIME-Version: 1.0\n"
|
||||
"Content-Type: multipart/mixed;"
|
||||
" boundary=\"%s%s\"\n"
|
||||
@@ -516,10 +516,8 @@ void log_write_email_headers(struct rev_info *opt, struct commit *commit,
|
||||
"Content-Type: text/plain; "
|
||||
"charset=UTF-8; format=fixed\n"
|
||||
"Content-Transfer-Encoding: 8bit\n\n",
|
||||
extra_headers ? extra_headers : "",
|
||||
mime_boundary_leader, opt->mime_boundary,
|
||||
mime_boundary_leader, opt->mime_boundary);
|
||||
extra_headers = subject_buffer.buf;
|
||||
|
||||
if (opt->numbered_files)
|
||||
strbuf_addf(&filename, "%d", opt->nr);
|
||||
@@ -539,7 +537,7 @@ void log_write_email_headers(struct rev_info *opt, struct commit *commit,
|
||||
opt->diffopt.stat_sep = buffer.buf;
|
||||
strbuf_release(&filename);
|
||||
}
|
||||
*extra_headers_p = extra_headers;
|
||||
*extra_headers_p = headers.len ? strbuf_detach(&headers, NULL) : NULL;
|
||||
}
|
||||
|
||||
static void show_sig_lines(struct rev_info *opt, int status, const char *bol)
|
||||
@@ -678,7 +676,6 @@ void show_log(struct rev_info *opt)
|
||||
struct log_info *log = opt->loginfo;
|
||||
struct commit *commit = log->commit, *parent = log->parent;
|
||||
int abbrev_commit = opt->abbrev_commit ? opt->abbrev : the_hash_algo->hexsz;
|
||||
const char *extra_headers = opt->extra_headers;
|
||||
struct pretty_print_context ctx = {0};
|
||||
|
||||
opt->loginfo = NULL;
|
||||
@@ -739,10 +736,9 @@ void show_log(struct rev_info *opt)
|
||||
*/
|
||||
|
||||
if (cmit_fmt_is_mail(opt->commit_format)) {
|
||||
log_write_email_headers(opt, commit, &extra_headers,
|
||||
log_write_email_headers(opt, commit, &ctx.after_subject,
|
||||
&ctx.need_8bit_cte, 1);
|
||||
ctx.rev = opt;
|
||||
ctx.print_email_subject = 1;
|
||||
} else if (opt->commit_format != CMIT_FMT_USERFORMAT) {
|
||||
fputs(diff_get_color_opt(&opt->diffopt, DIFF_COMMIT), opt->diffopt.file);
|
||||
if (opt->commit_format != CMIT_FMT_ONELINE)
|
||||
@@ -808,7 +804,6 @@ void show_log(struct rev_info *opt)
|
||||
ctx.date_mode = opt->date_mode;
|
||||
ctx.date_mode_explicit = opt->date_mode_explicit;
|
||||
ctx.abbrev = opt->diffopt.abbrev;
|
||||
ctx.after_subject = extra_headers;
|
||||
ctx.preserve_subject = opt->preserve_subject;
|
||||
ctx.encode_email_headers = opt->encode_email_headers;
|
||||
ctx.reflog_info = opt->reflog_info;
|
||||
@@ -857,6 +852,7 @@ void show_log(struct rev_info *opt)
|
||||
|
||||
strbuf_release(&msgbuf);
|
||||
free(ctx.notes_message);
|
||||
free(ctx.after_subject);
|
||||
|
||||
if (cmit_fmt_is_mail(ctx.fmt) && opt->idiff_oid1) {
|
||||
struct diff_queue_struct dq;
|
||||
|
||||
Reference in New Issue
Block a user