@ -137,56 +137,11 @@ static int has_non_ascii(const char *s)
@@ -137,56 +137,11 @@ static int has_non_ascii(const char *s)
return 0;
}
void show_log(struct rev_info *opt, const char *sep)
void log_write_email_headers(struct rev_info *opt, const char *name,
const char **subject_p, const char **extra_headers_p)
{
struct strbuf msgbuf;
struct log_info *log = opt->loginfo;
struct commit *commit = log->commit, *parent = log->parent;
int abbrev = opt->diffopt.abbrev;
int abbrev_commit = opt->abbrev_commit ? opt->abbrev : 40;
const char *extra;
const char *subject = NULL, *extra_headers = opt->extra_headers;
opt->loginfo = NULL;
if (!opt->verbose_header) {
if (opt->left_right) {
if (commit->object.flags & BOUNDARY)
putchar('-');
else if (commit->object.flags & SYMMETRIC_LEFT)
putchar('<');
else
putchar('>');
}
fputs(diff_unique_abbrev(commit->object.sha1, abbrev_commit), stdout);
if (opt->parents)
show_parents(commit, abbrev_commit);
show_decorations(commit);
putchar(opt->diffopt.line_termination);
return;
}
/*
* The "oneline" format has several special cases:
* - The pretty-printed commit lacks a newline at the end
* of the buffer, but we do want to make sure that we
* have a newline there. If the separator isn't already
* a newline, add an extra one.
* - unlike other log messages, the one-line format does
* not have an empty line between entries.
*/
extra = "";
if (*sep != '\n' && opt->commit_format == CMIT_FMT_ONELINE)
extra = "\n";
if (opt->shown_one && opt->commit_format != CMIT_FMT_ONELINE)
putchar(opt->diffopt.line_termination);
opt->shown_one = 1;
/*
* Print header line of header..
*/
if (opt->commit_format == CMIT_FMT_EMAIL) {
char *sha1 = sha1_to_hex(commit->object.sha1);
const char *subject = NULL;
const char *extra_headers = opt->extra_headers;
if (opt->total > 0) {
static char buffer[64];
snprintf(buffer, sizeof(buffer),
@ -205,7 +160,7 @@ void show_log(struct rev_info *opt, const char *sep)
@@ -205,7 +160,7 @@ void show_log(struct rev_info *opt, const char *sep)
subject = "Subject: ";
}
printf("From %s Mon Sep 17 00:00:00 2001\n", sha1);
printf("From %s Mon Sep 17 00:00:00 2001\n", name);
if (opt->message_id)
printf("Message-Id: <%s>\n", opt->message_id);
if (opt->ref_message_id)
@ -239,11 +194,66 @@ void show_log(struct rev_info *opt, const char *sep)
@@ -239,11 +194,66 @@ void show_log(struct rev_info *opt, const char *sep)
"Content-Disposition: %s;"
" filename=\"%s.diff\"\n\n",
mime_boundary_leader, opt->mime_boundary,
sha1,
name,
opt->no_inline ? "attachment" : "inline",
sha1);
name);
opt->diffopt.stat_sep = buffer;
}
*subject_p = subject;
*extra_headers_p = extra_headers;
}
void show_log(struct rev_info *opt, const char *sep)
{
struct strbuf msgbuf;
struct log_info *log = opt->loginfo;
struct commit *commit = log->commit, *parent = log->parent;
int abbrev = opt->diffopt.abbrev;
int abbrev_commit = opt->abbrev_commit ? opt->abbrev : 40;
const char *extra;
const char *subject = NULL, *extra_headers = opt->extra_headers;
opt->loginfo = NULL;
if (!opt->verbose_header) {
if (opt->left_right) {
if (commit->object.flags & BOUNDARY)
putchar('-');
else if (commit->object.flags & SYMMETRIC_LEFT)
putchar('<');
else
putchar('>');
}
fputs(diff_unique_abbrev(commit->object.sha1, abbrev_commit), stdout);
if (opt->parents)
show_parents(commit, abbrev_commit);
show_decorations(commit);
putchar(opt->diffopt.line_termination);
return;
}
/*
* The "oneline" format has several special cases:
* - The pretty-printed commit lacks a newline at the end
* of the buffer, but we do want to make sure that we
* have a newline there. If the separator isn't already
* a newline, add an extra one.
* - unlike other log messages, the one-line format does
* not have an empty line between entries.
*/
extra = "";
if (*sep != '\n' && opt->commit_format == CMIT_FMT_ONELINE)
extra = "\n";
if (opt->shown_one && opt->commit_format != CMIT_FMT_ONELINE)
putchar(opt->diffopt.line_termination);
opt->shown_one = 1;
/*
* Print header line of header..
*/
if (opt->commit_format == CMIT_FMT_EMAIL) {
log_write_email_headers(opt, sha1_to_hex(commit->object.sha1),
&subject, &extra_headers);
} else if (opt->commit_format != CMIT_FMT_USERFORMAT) {
fputs(diff_get_color_opt(&opt->diffopt, DIFF_COMMIT), stdout);
if (opt->commit_format != CMIT_FMT_ONELINE)