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:
43
pretty.c
43
pretty.c
@ -2077,11 +2077,11 @@ static void pp_header(struct pretty_print_context *pp,
|
||||
}
|
||||
}
|
||||
|
||||
void pp_title_line(struct pretty_print_context *pp,
|
||||
const char **msg_p,
|
||||
struct strbuf *sb,
|
||||
const char *encoding,
|
||||
int need_8bit_cte)
|
||||
void pp_email_subject(struct pretty_print_context *pp,
|
||||
const char **msg_p,
|
||||
struct strbuf *sb,
|
||||
const char *encoding,
|
||||
int need_8bit_cte)
|
||||
{
|
||||
static const int max_length = 78; /* per rfc2047 */
|
||||
struct strbuf title;
|
||||
@ -2091,19 +2091,14 @@ void pp_title_line(struct pretty_print_context *pp,
|
||||
pp->preserve_subject ? "\n" : " ");
|
||||
|
||||
strbuf_grow(sb, title.len + 1024);
|
||||
if (pp->print_email_subject) {
|
||||
if (pp->rev)
|
||||
fmt_output_email_subject(sb, pp->rev);
|
||||
if (pp->encode_email_headers &&
|
||||
needs_rfc2047_encoding(title.buf, title.len))
|
||||
add_rfc2047(sb, title.buf, title.len,
|
||||
encoding, RFC2047_SUBJECT);
|
||||
else
|
||||
strbuf_add_wrapped_bytes(sb, title.buf, title.len,
|
||||
fmt_output_email_subject(sb, pp->rev);
|
||||
if (pp->encode_email_headers &&
|
||||
needs_rfc2047_encoding(title.buf, title.len))
|
||||
add_rfc2047(sb, title.buf, title.len,
|
||||
encoding, RFC2047_SUBJECT);
|
||||
else
|
||||
strbuf_add_wrapped_bytes(sb, title.buf, title.len,
|
||||
-last_line_length(sb), 1, max_length);
|
||||
} else {
|
||||
strbuf_addbuf(sb, &title);
|
||||
}
|
||||
strbuf_addch(sb, '\n');
|
||||
|
||||
if (need_8bit_cte == 0) {
|
||||
@ -2126,9 +2121,8 @@ void pp_title_line(struct pretty_print_context *pp,
|
||||
if (pp->after_subject) {
|
||||
strbuf_addstr(sb, pp->after_subject);
|
||||
}
|
||||
if (cmit_fmt_is_mail(pp->fmt)) {
|
||||
strbuf_addch(sb, '\n');
|
||||
}
|
||||
|
||||
strbuf_addch(sb, '\n');
|
||||
|
||||
if (pp->in_body_headers.nr) {
|
||||
int i;
|
||||
@ -2320,7 +2314,7 @@ void pretty_print_commit(struct pretty_print_context *pp,
|
||||
}
|
||||
|
||||
pp_header(pp, encoding, commit, &msg, sb);
|
||||
if (pp->fmt != CMIT_FMT_ONELINE && !pp->print_email_subject) {
|
||||
if (pp->fmt != CMIT_FMT_ONELINE && !cmit_fmt_is_mail(pp->fmt)) {
|
||||
strbuf_addch(sb, '\n');
|
||||
}
|
||||
|
||||
@ -2328,8 +2322,11 @@ void pretty_print_commit(struct pretty_print_context *pp,
|
||||
msg = skip_blank_lines(msg);
|
||||
|
||||
/* These formats treat the title line specially. */
|
||||
if (pp->fmt == CMIT_FMT_ONELINE || cmit_fmt_is_mail(pp->fmt))
|
||||
pp_title_line(pp, &msg, sb, encoding, need_8bit_cte);
|
||||
if (pp->fmt == CMIT_FMT_ONELINE) {
|
||||
msg = format_subject(sb, msg, " ");
|
||||
strbuf_addch(sb, '\n');
|
||||
} else if (cmit_fmt_is_mail(pp->fmt))
|
||||
pp_email_subject(pp, &msg, sb, encoding, need_8bit_cte);
|
||||
|
||||
beginning_of_body = sb->len;
|
||||
if (pp->fmt != CMIT_FMT_ONELINE)
|
||||
|
Reference in New Issue
Block a user