]> git.ipfire.org Git - thirdparty/git.git/commitdiff
cocci: apply the "pretty.h" part of "the_repository.pending"
authorÆvar Arnfjörð Bjarmason <avarab@gmail.com>
Tue, 28 Mar 2023 13:58:51 +0000 (15:58 +0200)
committerJunio C Hamano <gitster@pobox.com>
Tue, 28 Mar 2023 14:36:45 +0000 (07:36 -0700)
Apply the part of "the_repository.pending.cocci" pertaining to
"pretty.h".

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
16 files changed:
archive.c
bisect.c
builtin/bisect.c
builtin/commit.c
builtin/notes.c
builtin/shortlog.c
contrib/coccinelle/the_repository.cocci
contrib/coccinelle/the_repository.pending.cocci
fmt-merge-msg.c
log-tree.c
notes-cache.c
object-name.c
pretty.c
pretty.h
sequencer.c
t/helper/test-revision-walking.c

index 0b48de0063491b430f2a9fb84b29f192ddc69a5e..d43687a5c44976d51c00a5cd5b0b6d7905a06078 100644 (file)
--- a/archive.c
+++ b/archive.c
@@ -59,7 +59,8 @@ static void format_subst(const struct commit *commit,
                strbuf_add(&fmt, b + 8, c - b - 8);
 
                strbuf_add(buf, src, b - src);
-               format_commit_message(commit, fmt.buf, buf, ctx);
+               repo_format_commit_message(the_repository, commit, fmt.buf,
+                                          buf, ctx);
                len -= c + 1 - src;
                src  = c + 1;
        }
index db7aa2032e17d00400a52687e24094879b723002..761dd48ad2050b5e30ffae1454771b6adf9d8793 100644 (file)
--- a/bisect.c
+++ b/bisect.c
@@ -752,7 +752,8 @@ enum bisect_error bisect_checkout(const struct object_id *bisect_rev,
        }
 
        commit = lookup_commit_reference(the_repository, bisect_rev);
-       format_commit_message(commit, "[%H] %s%n", &commit_msg, &pp);
+       repo_format_commit_message(the_repository, commit, "[%H] %s%n",
+                                  &commit_msg, &pp);
        fputs(commit_msg.buf, stdout);
        strbuf_release(&commit_msg);
 
index 7d51eecab8222d902d3a1682eb29bc3203e2a7f8..34ba7b18f69d03b00b9109d440fb4918bf9cb0ae 100644 (file)
@@ -265,7 +265,8 @@ static void log_commit(FILE *fp, char *fmt, const char *state,
        struct strbuf commit_msg = STRBUF_INIT;
        char *label = xstrfmt(fmt, state);
 
-       format_commit_message(commit, "%s", &commit_msg, &pp);
+       repo_format_commit_message(the_repository, commit, "%s", &commit_msg,
+                                  &pp);
 
        fprintf(fp, "# %s: [%s] %s\n", label, oid_to_hex(&commit->object.oid),
                commit_msg.buf);
@@ -603,8 +604,8 @@ static int bisect_skipped_commits(struct bisect_terms *terms)
 
        while ((commit = get_revision(&revs)) != NULL) {
                strbuf_reset(&commit_name);
-               format_commit_message(commit, "%s",
-                                     &commit_name, &pp);
+               repo_format_commit_message(the_repository, commit, "%s",
+                                          &commit_name, &pp);
                fprintf(fp, "# possible first %s commit: [%s] %s\n",
                        terms->term_bad, oid_to_hex(&commit->object.oid),
                        commit_name.buf);
@@ -633,7 +634,8 @@ static int bisect_successful(struct bisect_terms *terms)
 
        read_ref(bad_ref, &oid);
        commit = lookup_commit_reference_by_name(bad_ref);
-       format_commit_message(commit, "%s", &commit_name, &pp);
+       repo_format_commit_message(the_repository, commit, "%s", &commit_name,
+                                  &pp);
 
        res = append_to_file(git_path_bisect_log(), "# first %s commit: [%s] %s\n",
                            terms->term_bad, oid_to_hex(&commit->object.oid),
index bda6afc4bd6cf7cdc9c244431a7b988760ffd38d..92b7e8c56f7980e1d2db0de1f5527d7ea3c4f4fb 100644 (file)
@@ -719,7 +719,7 @@ static void prepare_amend_commit(struct commit *commit, struct strbuf *sb,
         * duplicate the subject line.
         */
        fmt = starts_with(subject, "amend!") ? "%b" : "%B";
-       format_commit_message(commit, fmt, sb, ctx);
+       repo_format_commit_message(the_repository, commit, fmt, sb, ctx);
        repo_unuse_commit_buffer(the_repository, commit, buffer);
 }
 
@@ -760,8 +760,9 @@ static int prepare_to_commit(const char *index_file, const char *prefix,
                        if (!c)
                                die(_("could not lookup commit %s"), squash_message);
                        ctx.output_encoding = get_commit_output_encoding();
-                       format_commit_message(c, "squash! %s\n\n", &sb,
-                                             &ctx);
+                       repo_format_commit_message(the_repository, c,
+                                                  "squash! %s\n\n", &sb,
+                                                  &ctx);
                }
        }
 
@@ -795,7 +796,8 @@ static int prepare_to_commit(const char *index_file, const char *prefix,
                        die(_("could not lookup commit %s"), fixup_commit);
                ctx.output_encoding = get_commit_output_encoding();
                fmt = xstrfmt("%s! %%s\n\n", fixup_prefix);
-               format_commit_message(commit, fmt, &sb, &ctx);
+               repo_format_commit_message(the_repository, commit, fmt, &sb,
+                                          &ctx);
                free(fmt);
                hook_arg1 = "message";
 
@@ -1135,7 +1137,8 @@ static const char *find_author_by_nickname(const char *name)
                struct pretty_print_context ctx = {0};
                ctx.date_mode.type = DATE_NORMAL;
                strbuf_release(&buf);
-               format_commit_message(commit, "%aN <%aE>", &buf, &ctx);
+               repo_format_commit_message(the_repository, commit,
+                                          "%aN <%aE>", &buf, &ctx);
                release_revisions(&revs);
                return strbuf_detach(&buf, NULL);
        }
index ba1daa4ff0f7a68ec2a2693433c54f56c4926c35..f4939176dae4f00a886e5b865c7ab576d812da0c 100644 (file)
@@ -742,7 +742,8 @@ static int merge_commit(struct notes_merge_options *o)
 
        /* Reuse existing commit message in reflog message */
        memset(&pretty_ctx, 0, sizeof(pretty_ctx));
-       format_commit_message(partial, "%s", &msg, &pretty_ctx);
+       repo_format_commit_message(the_repository, partial, "%s", &msg,
+                                  &pretty_ctx);
        strbuf_trim(&msg);
        strbuf_insertstr(&msg, 0, "notes: ");
        update_ref(msg.buf, o->local_ref, &oid,
index 8afd1ad865e3b459af3c9d40bd0643290ae439e8..62f91b8b9323d492308ddb3e279e998d782a722f 100644 (file)
@@ -223,7 +223,8 @@ static void insert_records_from_format(struct shortlog *log,
        for_each_string_list_item(item, &log->format) {
                strbuf_reset(&buf);
 
-               format_commit_message(commit, item->string, &buf, ctx);
+               repo_format_commit_message(the_repository, commit,
+                                          item->string, &buf, ctx);
 
                if (!shortlog_needs_dedup(log) || strset_add(dups, buf.buf))
                        insert_one_record(log, buf.buf, oneline);
@@ -249,7 +250,8 @@ void shortlog_add_commit(struct shortlog *log, struct commit *commit)
                if (log->user_format)
                        pretty_print_commit(&ctx, commit, &oneline);
                else
-                       format_commit_message(commit, "%s", &oneline, &ctx);
+                       repo_format_commit_message(the_repository, commit,
+                                                  "%s", &oneline, &ctx);
        }
        oneline_str = oneline.len ? oneline.buf : "<none>";
 
index fa159aba5b515218c10d0c97db1ba4790707861b..ff4c56114f1de57946668bd3925e929c72bc027f 100644 (file)
 |
 - has_object_file_with_flags
 + repo_has_object_file_with_flags
+// pretty.h
+|
+- format_commit_message
++ repo_format_commit_message
 )
   (
 + the_repository,
index 69e9694111e0e5c6c703660d9bcf37e7a6a1eba3..375850e773c34bde7586095825f7663c598dd1ae 100644 (file)
@@ -5,11 +5,7 @@
 @@
 @@
 (
-// pretty.h
-- format_commit_message
-+ repo_format_commit_message
 // packfile.h
-|
 - approximate_object_count
 + repo_approximate_object_count
 // promisor-remote.h
index e9c6623647d56f5548f022a50f9af31928da2320..62529344407b4148964148828c6041aeafc3a8b6 100644 (file)
@@ -385,7 +385,8 @@ static void shortlog(const char *name,
                if (subjects.nr > limit)
                        continue;
 
-               format_commit_message(commit, "%s", &sb, &ctx);
+               repo_format_commit_message(the_repository, commit, "%s", &sb,
+                                          &ctx);
                strbuf_ltrim(&sb);
 
                if (!sb.len)
index 1bd4d6ab00827aceb1e91079a4d54631fb24a4c9..7eee664cd239f85ef7a59efd86d352af8e463e74 100644 (file)
@@ -407,7 +407,8 @@ void fmt_output_commit(struct strbuf *filename,
        struct pretty_print_context ctx = {0};
        struct strbuf subject = STRBUF_INIT;
 
-       format_commit_message(commit, "%f", &subject, &ctx);
+       repo_format_commit_message(the_repository, commit, "%f", &subject,
+                                  &ctx);
        fmt_output_subject(filename, subject.buf, info);
        strbuf_release(&subject);
 }
@@ -985,8 +986,10 @@ static int do_remerge_diff(struct rev_info *opt,
        o.msg_header_prefix = "remerge";
 
        ctx.abbrev = DEFAULT_ABBREV;
-       format_commit_message(parent1, "%h (%s)", &parent1_desc, &ctx);
-       format_commit_message(parent2, "%h (%s)", &parent2_desc, &ctx);
+       repo_format_commit_message(the_repository, parent1, "%h (%s)",
+                                  &parent1_desc, &ctx);
+       repo_format_commit_message(the_repository, parent2, "%h (%s)",
+                                  &parent2_desc, &ctx);
        o.branch1 = parent1_desc.buf;
        o.branch2 = parent2_desc.buf;
 
index 3846609136022296baabbec45fc3064fef42b696..e5e9092d367dfc92efca709e59b59f709506f9a3 100644 (file)
@@ -23,7 +23,8 @@ static int notes_cache_match_validity(struct repository *r,
                return 0;
 
        memset(&pretty_ctx, 0, sizeof(pretty_ctx));
-       format_commit_message(commit, "%s", &msg, &pretty_ctx);
+       repo_format_commit_message(the_repository, commit, "%s", &msg,
+                                  &pretty_ctx);
        strbuf_trim(&msg);
 
        ret = !strcmp(msg.buf, validity);
index 2926f26251f850f8f65be6adf4d70697d7657553..df31f192ce3da5a796ce438d4ac48acc3ac7def9 100644 (file)
@@ -394,8 +394,10 @@ static int show_ambiguous_object(const struct object_id *oid, void *data)
                if (commit) {
                        struct pretty_print_context pp = {0};
                        pp.date_mode.type = DATE_SHORT;
-                       format_commit_message(commit, "%ad", &date, &pp);
-                       format_commit_message(commit, "%s", &msg, &pp);
+                       repo_format_commit_message(the_repository, commit,
+                                                  "%ad", &date, &pp);
+                       repo_format_commit_message(the_repository, commit,
+                                                  "%s", &msg, &pp);
                }
 
                /*
index 7e1614f67fe8e98eda90a8a82723fd4784ce6ff0..076d1c363e7237fbc8002f1a8016609c7ff81e63 100644 (file)
--- a/pretty.c
+++ b/pretty.c
@@ -2199,7 +2199,8 @@ void pretty_print_commit(struct pretty_print_context *pp,
        int need_8bit_cte = pp->need_8bit_cte;
 
        if (pp->fmt == CMIT_FMT_USERFORMAT) {
-               format_commit_message(commit, user_format, sb, pp);
+               repo_format_commit_message(the_repository, commit,
+                                          user_format, sb, pp);
                return;
        }
 
index f34e24c53a4925aec51cd62117654fdd5f7f980e..1e37c56d73d4d87cbfa5dfdd048cfc7dfc9dc510 100644 (file)
--- a/pretty.h
+++ b/pretty.h
@@ -120,10 +120,6 @@ void repo_format_commit_message(struct repository *r,
                        const struct commit *commit,
                        const char *format, struct strbuf *sb,
                        const struct pretty_print_context *context);
-#ifndef NO_THE_REPOSITORY_COMPATIBILITY_MACROS
-#define format_commit_message(c, f, s, con) \
-       repo_format_commit_message(the_repository, c, f, s, con)
-#endif
 
 /*
  * Parse given arguments from "arg", check it for correctness and
index 592b3d2875a0cca5c459785975a4d4cadc22ccaf..aa3ebb47d98f651fefbb277f5fca4d5ac2bed617 100644 (file)
@@ -1343,8 +1343,10 @@ void print_commit_summary(struct repository *r,
 
        strbuf_addstr(&format, "format:%h] %s");
 
-       format_commit_message(commit, "%an <%ae>", &author_ident, &pctx);
-       format_commit_message(commit, "%cn <%ce>", &committer_ident, &pctx);
+       repo_format_commit_message(the_repository, commit, "%an <%ae>",
+                                  &author_ident, &pctx);
+       repo_format_commit_message(the_repository, commit, "%cn <%ce>",
+                                  &committer_ident, &pctx);
        if (strbuf_cmp(&author_ident, &committer_ident)) {
                strbuf_addstr(&format, "\n Author: ");
                strbuf_addbuf_percentquote(&format, &author_ident);
@@ -1352,7 +1354,8 @@ void print_commit_summary(struct repository *r,
        if (flags & SUMMARY_SHOW_AUTHOR_DATE) {
                struct strbuf date = STRBUF_INIT;
 
-               format_commit_message(commit, "%ad", &date, &pctx);
+               repo_format_commit_message(the_repository, commit, "%ad",
+                                          &date, &pctx);
                strbuf_addstr(&format, "\n Date: ");
                strbuf_addbuf_percentquote(&format, &date);
                strbuf_release(&date);
@@ -2125,7 +2128,8 @@ static void refer_to_commit(struct replay_opts *opts,
                        .abbrev = DEFAULT_ABBREV,
                        .date_mode.type = DATE_SHORT,
                };
-               format_commit_message(commit, "%h (%s, %ad)", msgbuf, &ctx);
+               repo_format_commit_message(the_repository, commit,
+                                          "%h (%s, %ad)", msgbuf, &ctx);
        } else {
                strbuf_addstr(msgbuf, oid_to_hex(&commit->object.oid));
        }
index 4a45d5bac2af5678eda5ad8b49c7747a3973878e..c7b22cb33d577fbccc830b3037b7ddff659088f5 100644 (file)
@@ -19,7 +19,8 @@ static void print_commit(struct commit *commit)
        struct strbuf sb = STRBUF_INIT;
        struct pretty_print_context ctx = {0};
        ctx.date_mode.type = DATE_NORMAL;
-       format_commit_message(commit, " %m %s", &sb, &ctx);
+       repo_format_commit_message(the_repository, commit, " %m %s", &sb,
+                                  &ctx);
        printf("%s\n", sb.buf);
        strbuf_release(&sb);
 }