cocci: apply the "pretty.h" part of "the_repository.pending"

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>
This commit is contained in:
Ævar Arnfjörð Bjarmason 2023-03-28 15:58:51 +02:00 committed by Junio C Hamano
parent bc726bd075
commit bab821646a
16 changed files with 54 additions and 35 deletions

View File

@ -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;
}

View File

@ -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);

View 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),

View 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);
}

View 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,

View 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>";

View File

@ -87,6 +87,10 @@
|
- has_object_file_with_flags
+ repo_has_object_file_with_flags
// pretty.h
|
- format_commit_message
+ repo_format_commit_message
)
(
+ the_repository,

View 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

View 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)

View 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;

View 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);

View 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);
}
/*

View File

@ -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;
}

View File

@ -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

View 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));
}

View 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);
}