Jonathan Nieder wrote: > Subject: [PATCH 5/5] pretty: Respect --abbrev option [...] > Signed-off-by: Will Palmer <wmpalmer@xxxxxxxxx> > Signed-off-by: Jonathan Nieder <jrnieder@xxxxxxxxx> This patch was by Will Palmer <wmpalmer@xxxxxxxxx> (except two of the tests). Since I don’t use ‘git send-email’, I keep forgetting to include the From: pseudo-header. Sorry for the trouble, Jonathan diff --git a/pretty.c b/pretty.c index 1430616..e5dea91 100644 --- a/pretty.c +++ b/pretty.c @@ -908,6 +908,7 @@ static void pp_header(enum cmit_fmt fmt, const char *encoding, const struct commit *commit, const char **msg_p, + const char **author_p, struct strbuf *sb) { int parents_shown = 0; @@ -954,6 +955,8 @@ static void pp_header(enum cmit_fmt fmt, * FULLER shows both authors and dates. */ if (!memcmp(line, "author ", 7)) { + if (author_p) + *author_p = line + 7; strbuf_grow(sb, linelen + 80); pp_user_info("Author", fmt, sb, line + 7, dmode, encoding); } @@ -1004,6 +1007,22 @@ void pp_title_line(enum cmit_fmt fmt, strbuf_release(&title); } +static void pp_in_body_author(struct strbuf *sb, + const char *author_line) +{ + const char *author_end, *sender; + + author_end = strchr(author_line, '>') + 1; + sender = git_author_info(IDENT_NO_DATE); + if (!strncmp(author_line, sender, author_end - author_line)) + return; + + strbuf_addstr(sb, "From: "); + strbuf_add(sb, author_line, author_end - author_line); + strbuf_addch(sb, '\n'); + strbuf_addch(sb, '\n'); +} + void pp_remainder(enum cmit_fmt fmt, const char **msg_p, struct strbuf *sb, @@ -1057,6 +1076,7 @@ void pretty_print_commit(enum cmit_fmt fmt, const struct commit *commit, unsigned long beginning_of_body; int indent = 4; const char *msg = commit->buffer; + const char *author = NULL; char *reencoded; const char *encoding; int need_8bit_cte = context->need_8bit_cte; @@ -1082,15 +1102,13 @@ void pretty_print_commit(enum cmit_fmt fmt, const struct commit *commit, int i, ch, in_body; for (in_body = i = 0; (ch = msg[i]); i++) { - if (!in_body) { - /* author could be non 7-bit ASCII but - * the log may be so; skip over the - * header part first. - */ - if (ch == '\n' && msg[i+1] == '\n') - in_body = 1; - } - else if (non_ascii(ch)) { + /* + * If the author is non 7-bit ASCII but + * the log is 7bit, we still need a + * Content-type field, in case an in-body + * From: line is required. + */ + if (non_ascii(ch)) { need_8bit_cte = 1; break; } @@ -1098,7 +1116,7 @@ void pretty_print_commit(enum cmit_fmt fmt, const struct commit *commit, } pp_header(fmt, context->abbrev, context->date_mode, encoding, - commit, &msg, sb); + commit, &msg, &author, sb); if (fmt != CMIT_FMT_ONELINE && !context->subject) { strbuf_addch(sb, '\n'); } @@ -1111,6 +1129,9 @@ void pretty_print_commit(enum cmit_fmt fmt, const struct commit *commit, pp_title_line(fmt, &msg, sb, context->subject, context->after_subject, encoding, need_8bit_cte); + if (fmt == CMIT_FMT_EMAIL) + pp_in_body_author(sb, author); + beginning_of_body = sb->len; if (fmt != CMIT_FMT_ONELINE) pp_remainder(fmt, &msg, sb, indent); -- -- To unsubscribe from this list: send the line "unsubscribe git" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html