Skip to content

Commit b84d013

Browse files
committed
pretty: separate out the logic to decide the use of in-body from
When pretty-printing the log message for a given commit in the e-mail format (e.g. "git format-patch"), we add an in-body "From:" header when the author identity of the commit is different from the identity of the person whose identity appears in the header of the e-mail (the latter is passed with them "--from" option). Split out the logic into a helper function, as we would want to extend the condition further. Signed-off-by: Junio C Hamano <[email protected]>
1 parent 07ee72d commit b84d013

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

pretty.c

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -477,6 +477,14 @@ static void append_line_with_color(struct strbuf *sb, struct grep_opt *opt,
477477
}
478478
}
479479

480+
static int use_in_body_from(const struct pretty_print_context *pp,
481+
const struct ident_split *ident)
482+
{
483+
if (ident_cmp(pp->from_ident, ident))
484+
return 1;
485+
return 0;
486+
}
487+
480488
void pp_user_info(struct pretty_print_context *pp,
481489
const char *what, struct strbuf *sb,
482490
const char *line, const char *encoding)
@@ -503,7 +511,7 @@ void pp_user_info(struct pretty_print_context *pp,
503511
map_user(pp->mailmap, &mailbuf, &maillen, &namebuf, &namelen);
504512

505513
if (cmit_fmt_is_mail(pp->fmt)) {
506-
if (pp->from_ident && ident_cmp(pp->from_ident, &ident)) {
514+
if (pp->from_ident && use_in_body_from(pp, &ident)) {
507515
struct strbuf buf = STRBUF_INIT;
508516

509517
strbuf_addstr(&buf, "From: ");

0 commit comments

Comments
 (0)