]> git.ipfire.org Git - thirdparty/git.git/blobdiff - log-tree.c
The fifth batch
[thirdparty/git.git] / log-tree.c
index 337b9334cdbafe0d3ffd2bf2fd36898f6d112410..41416de4e3fbf130982455070f9118c0bcd1e469 100644 (file)
@@ -232,8 +232,10 @@ void load_ref_decorations(struct decoration_filter *filter, int flags)
                }
                decoration_loaded = 1;
                decoration_flags = flags;
-               for_each_ref(add_ref_decoration, filter);
-               head_ref(add_ref_decoration, filter);
+               refs_for_each_ref(get_main_ref_store(the_repository),
+                                 add_ref_decoration, filter);
+               refs_head_ref(get_main_ref_store(the_repository),
+                             add_ref_decoration, filter);
                for_each_commit_graft(add_graft_decoration, filter);
        }
 }
@@ -277,7 +279,8 @@ static const struct name_decoration *current_pointed_by_HEAD(const struct name_d
                return NULL;
 
        /* Now resolve and find the matching current branch */
-       branch_name = resolve_ref_unsafe("HEAD", 0, NULL, &rru_flags);
+       branch_name = refs_resolve_ref_unsafe(get_main_ref_store(the_repository),
+                                             "HEAD", 0, NULL, &rru_flags);
        if (!branch_name || !(rru_flags & REF_ISSYMREF))
                return NULL;
 
@@ -470,16 +473,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 +502,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 +519,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 +540,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)
@@ -678,7 +679,6 @@ void show_log(struct rev_info *opt)
        struct log_info *log = opt->loginfo;
        struct commit *commit = log->commit, *parent = log->parent;
        int abbrev_commit = opt->abbrev_commit ? opt->abbrev : the_hash_algo->hexsz;
-       const char *extra_headers = opt->extra_headers;
        struct pretty_print_context ctx = {0};
 
        opt->loginfo = NULL;
@@ -739,10 +739,9 @@ void show_log(struct rev_info *opt)
         */
 
        if (cmit_fmt_is_mail(opt->commit_format)) {
-               log_write_email_headers(opt, commit, &extra_headers,
+               log_write_email_headers(opt, commit, &ctx.after_subject,
                                        &ctx.need_8bit_cte, 1);
                ctx.rev = opt;
-               ctx.print_email_subject = 1;
        } else if (opt->commit_format != CMIT_FMT_USERFORMAT) {
                fputs(diff_get_color_opt(&opt->diffopt, DIFF_COMMIT), opt->diffopt.file);
                if (opt->commit_format != CMIT_FMT_ONELINE)
@@ -777,7 +776,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;
@@ -808,7 +807,6 @@ void show_log(struct rev_info *opt)
        ctx.date_mode = opt->date_mode;
        ctx.date_mode_explicit = opt->date_mode_explicit;
        ctx.abbrev = opt->diffopt.abbrev;
-       ctx.after_subject = extra_headers;
        ctx.preserve_subject = opt->preserve_subject;
        ctx.encode_email_headers = opt->encode_email_headers;
        ctx.reflog_info = opt->reflog_info;
@@ -857,6 +855,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;
@@ -1011,7 +1010,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;
@@ -1036,7 +1035,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);