]> git.ipfire.org Git - thirdparty/git.git/blobdiff - pretty.c
format-patch: allow forcing the use of in-body From: header
[thirdparty/git.git] / pretty.c
index ee6114e3f0aa1dcf8737794bbe8dc8f6e23f5f7b..b7553e3fe09ddec3104f3b34adfd21189b84e261 100644 (file)
--- a/pretty.c
+++ b/pretty.c
@@ -477,6 +477,16 @@ end:
        }
 }
 
+static int use_in_body_from(const struct pretty_print_context *pp,
+                           const struct ident_split *ident)
+{
+       if (pp->rev && pp->rev->force_in_body_from)
+               return 1;
+       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 +513,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: ");
@@ -1575,23 +1585,7 @@ static size_t format_commit_one(struct strbuf *sb, /* in UTF-8 */
                                strbuf_addstr(sb, c->signature_check.primary_key_fingerprint);
                        break;
                case 'T':
-                       switch (c->signature_check.trust_level) {
-                       case TRUST_UNDEFINED:
-                               strbuf_addstr(sb, "undefined");
-                               break;
-                       case TRUST_NEVER:
-                               strbuf_addstr(sb, "never");
-                               break;
-                       case TRUST_MARGINAL:
-                               strbuf_addstr(sb, "marginal");
-                               break;
-                       case TRUST_FULLY:
-                               strbuf_addstr(sb, "fully");
-                               break;
-                       case TRUST_ULTIMATE:
-                               strbuf_addstr(sb, "ultimate");
-                               break;
-                       }
+                       strbuf_addstr(sb, gpg_trust_level_to_str(c->signature_check.trust_level));
                        break;
                default:
                        return 0;