Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.kernel.org/pub/scm/git/git.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2022-08-30 00:38:35 +0300
committerJunio C Hamano <gitster@pobox.com>2022-08-30 00:39:13 +0300
commitb84d01393679d0e09d6fd198e771f2d1f5563986 (patch)
tree8a874f813852585ffea6819bc1072eabc208001b /pretty.c
parent07ee72db0e97b5c233f8ada0abb412248c2f1c6f (diff)
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 <gitster@pobox.com>
Diffstat (limited to 'pretty.c')
-rw-r--r--pretty.c10
1 files changed, 9 insertions, 1 deletions
diff --git a/pretty.c b/pretty.c
index 6d819103fb..cf418a6b20 100644
--- a/pretty.c
+++ b/pretty.c
@@ -477,6 +477,14 @@ end:
}
}
+static int use_in_body_from(const struct pretty_print_context *pp,
+ const struct ident_split *ident)
+{
+ if (ident_cmp(pp->from_ident, ident))
+ return 1;
+ return 0;
+}
+
void pp_user_info(struct pretty_print_context *pp,
const char *what, struct strbuf *sb,
const char *line, const char *encoding)
@@ -503,7 +511,7 @@ void pp_user_info(struct pretty_print_context *pp,
map_user(pp->mailmap, &mailbuf, &maillen, &namebuf, &namelen);
if (cmit_fmt_is_mail(pp->fmt)) {
- if (pp->from_ident && ident_cmp(pp->from_ident, &ident)) {
+ if (pp->from_ident && use_in_body_from(pp, &ident)) {
struct strbuf buf = STRBUF_INIT;
strbuf_addstr(&buf, "From: ");