]> git.ipfire.org Git - thirdparty/git.git/blobdiff - log-tree.c
Git 2.45
[thirdparty/git.git] / log-tree.c
index 78e678e0e7926934e8d27005540e59e1cf3c9a39..16031b44e75076f6e8f537cdbd11212eb6eaf268 100644 (file)
@@ -470,16 +470,19 @@ void fmt_output_email_subject(struct strbuf *sb, struct rev_info *opt)
 }
 
 void log_write_email_headers(struct rev_info *opt, struct commit *commit,
-                            const char **extra_headers_p,
+                            char **extra_headers_p,
                             int *need_8bit_cte_p,
                             int maybe_multipart)
 {
-       const char *extra_headers = opt->extra_headers;
+       struct strbuf headers = STRBUF_INIT;
        const char *name = oid_to_hex(opt->zero_commit ?
                                      null_oid() : &commit->object.oid);
 
        *need_8bit_cte_p = 0; /* unknown */
 
+       if (opt->extra_headers && *opt->extra_headers)
+               strbuf_addstr(&headers, opt->extra_headers);
+
        fprintf(opt->diffopt.file, "From %s Mon Sep 17 00:00:00 2001\n", name);
        graph_show_oneline(opt->graph);
        if (opt->message_id) {
@@ -496,16 +499,13 @@ void log_write_email_headers(struct rev_info *opt, struct commit *commit,
                graph_show_oneline(opt->graph);
        }
        if (opt->mime_boundary && maybe_multipart) {
-               static struct strbuf subject_buffer = STRBUF_INIT;
                static struct strbuf buffer = STRBUF_INIT;
                struct strbuf filename =  STRBUF_INIT;
                *need_8bit_cte_p = -1; /* NEVER */
 
-               strbuf_reset(&subject_buffer);
                strbuf_reset(&buffer);
 
-               strbuf_addf(&subject_buffer,
-                        "%s"
+               strbuf_addf(&headers,
                         "MIME-Version: 1.0\n"
                         "Content-Type: multipart/mixed;"
                         " boundary=\"%s%s\"\n"
@@ -516,10 +516,8 @@ void log_write_email_headers(struct rev_info *opt, struct commit *commit,
                         "Content-Type: text/plain; "
                         "charset=UTF-8; format=fixed\n"
                         "Content-Transfer-Encoding: 8bit\n\n",
-                        extra_headers ? extra_headers : "",
                         mime_boundary_leader, opt->mime_boundary,
                         mime_boundary_leader, opt->mime_boundary);
-               extra_headers = subject_buffer.buf;
 
                if (opt->numbered_files)
                        strbuf_addf(&filename, "%d", opt->nr);
@@ -539,7 +537,7 @@ void log_write_email_headers(struct rev_info *opt, struct commit *commit,
                opt->diffopt.stat_sep = buffer.buf;
                strbuf_release(&filename);
        }
-       *extra_headers_p = extra_headers;
+       *extra_headers_p = headers.len ? strbuf_detach(&headers, NULL) : NULL;
 }
 
 static void show_sig_lines(struct rev_info *opt, int status, const char *bol)
@@ -775,7 +773,7 @@ void show_log(struct rev_info *opt)
                         */
                        show_reflog_message(opt->reflog_info,
                                            opt->commit_format == CMIT_FMT_ONELINE,
-                                           &opt->date_mode,
+                                           opt->date_mode,
                                            opt->date_mode_explicit);
                        if (opt->commit_format == CMIT_FMT_ONELINE)
                                return;
@@ -854,6 +852,7 @@ void show_log(struct rev_info *opt)
 
        strbuf_release(&msgbuf);
        free(ctx.notes_message);
+       free(ctx.after_subject);
 
        if (cmit_fmt_is_mail(ctx.fmt) && opt->idiff_oid1) {
                struct diff_queue_struct dq;
@@ -1008,7 +1007,7 @@ static int do_remerge_diff(struct rev_info *opt,
                           struct object_id *oid)
 {
        struct merge_options o;
-       struct commit_list *bases;
+       struct commit_list *bases = NULL;
        struct merge_result res = {0};
        struct pretty_print_context ctx = {0};
        struct commit *parent1 = parents->item;
@@ -1033,7 +1032,8 @@ static int do_remerge_diff(struct rev_info *opt,
        /* Parse the relevant commits and get the merge bases */
        parse_commit_or_die(parent1);
        parse_commit_or_die(parent2);
-       bases = repo_get_merge_bases(the_repository, parent1, parent2);
+       if (repo_get_merge_bases(the_repository, parent1, parent2, &bases) < 0)
+               exit(128);
 
        /* Re-merge the parents */
        merge_incore_recursive(&o, bases, parent1, parent2, &res);