]> git.ipfire.org Git - thirdparty/git.git/blobdiff - pretty.c
Start the 2.46 cycle
[thirdparty/git.git] / pretty.c
index 18f817604be682385c9d44ff1f11a876bd089172..7ead078998e6dae87087472ff81aa6e5f678f2a3 100644 (file)
--- a/pretty.c
+++ b/pretty.c
@@ -147,7 +147,7 @@ static struct cmt_fmt_map *find_commit_format_recursive(const char *sought,
        for (i = 0; i < commit_formats_len; i++) {
                size_t match_len;
 
-               if (!starts_with(commit_formats[i].name, sought))
+               if (!istarts_with(commit_formats[i].name, sought))
                        continue;
 
                match_len = strlen(commit_formats[i].name);
@@ -2077,11 +2077,11 @@ static void pp_header(struct pretty_print_context *pp,
        }
 }
 
-void pp_title_line(struct pretty_print_context *pp,
-                  const char **msg_p,
-                  struct strbuf *sb,
-                  const char *encoding,
-                  int need_8bit_cte)
+void pp_email_subject(struct pretty_print_context *pp,
+                     const char **msg_p,
+                     struct strbuf *sb,
+                     const char *encoding,
+                     int need_8bit_cte)
 {
        static const int max_length = 78; /* per rfc2047 */
        struct strbuf title;
@@ -2091,19 +2091,14 @@ void pp_title_line(struct pretty_print_context *pp,
                                pp->preserve_subject ? "\n" : " ");
 
        strbuf_grow(sb, title.len + 1024);
-       if (pp->print_email_subject) {
-               if (pp->rev)
-                       fmt_output_email_subject(sb, pp->rev);
-               if (pp->encode_email_headers &&
-                   needs_rfc2047_encoding(title.buf, title.len))
-                       add_rfc2047(sb, title.buf, title.len,
-                                               encoding, RFC2047_SUBJECT);
-               else
-                       strbuf_add_wrapped_bytes(sb, title.buf, title.len,
+       fmt_output_email_subject(sb, pp->rev);
+       if (pp->encode_email_headers &&
+           needs_rfc2047_encoding(title.buf, title.len))
+               add_rfc2047(sb, title.buf, title.len,
+                           encoding, RFC2047_SUBJECT);
+       else
+               strbuf_add_wrapped_bytes(sb, title.buf, title.len,
                                         -last_line_length(sb), 1, max_length);
-       } else {
-               strbuf_addbuf(sb, &title);
-       }
        strbuf_addch(sb, '\n');
 
        if (need_8bit_cte == 0) {
@@ -2126,9 +2121,8 @@ void pp_title_line(struct pretty_print_context *pp,
        if (pp->after_subject) {
                strbuf_addstr(sb, pp->after_subject);
        }
-       if (cmit_fmt_is_mail(pp->fmt)) {
-               strbuf_addch(sb, '\n');
-       }
+
+       strbuf_addch(sb, '\n');
 
        if (pp->in_body_headers.nr) {
                int i;
@@ -2320,7 +2314,7 @@ void pretty_print_commit(struct pretty_print_context *pp,
        }
 
        pp_header(pp, encoding, commit, &msg, sb);
-       if (pp->fmt != CMIT_FMT_ONELINE && !pp->print_email_subject) {
+       if (pp->fmt != CMIT_FMT_ONELINE && !cmit_fmt_is_mail(pp->fmt)) {
                strbuf_addch(sb, '\n');
        }
 
@@ -2328,8 +2322,11 @@ void pretty_print_commit(struct pretty_print_context *pp,
        msg = skip_blank_lines(msg);
 
        /* These formats treat the title line specially. */
-       if (pp->fmt == CMIT_FMT_ONELINE || cmit_fmt_is_mail(pp->fmt))
-               pp_title_line(pp, &msg, sb, encoding, need_8bit_cte);
+       if (pp->fmt == CMIT_FMT_ONELINE) {
+               msg = format_subject(sb, msg, " ");
+               strbuf_addch(sb, '\n');
+       } else if (cmit_fmt_is_mail(pp->fmt))
+               pp_email_subject(pp, &msg, sb, encoding, need_8bit_cte);
 
        beginning_of_body = sb->len;
        if (pp->fmt != CMIT_FMT_ONELINE)