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>
Ævar Arnfjörð Bjarmason committed
Mar 28, 2023 at 15:58 UTC
bab821646a74c446370fa8d01ca851f247df5033
16 files changed
+54
-35
archive.c
+2
-1
@@ -59,7 +59,8 @@ static void format_subst(const struct commit *commit,
59
strbuf_add(&fmt, b + 8, c - b - 8);
60
61
strbuf_add(buf, src, b - src);
62
- format_commit_message(commit, fmt.buf, buf, ctx);
62
+ repo_format_commit_message(the_repository, commit, fmt.buf,
63
+ buf, ctx);
64
len -= c + 1 - src;
65
src = c + 1;
66
}
bisect.c
+2
-1
@@ -752,7 +752,8 @@ enum bisect_error bisect_checkout(const struct object_id *bisect_rev,
752
}
753
754
commit = lookup_commit_reference(the_repository, bisect_rev);
755
- format_commit_message(commit, "[%H] %s%n", &commit_msg, &pp);
755
+ repo_format_commit_message(the_repository, commit, "[%H] %s%n",
756
+ &commit_msg, &pp);
757
fputs(commit_msg.buf, stdout);
758
strbuf_release(&commit_msg);
759
builtin/bisect.c
+6
-4
@@ -265,7 +265,8 @@ static void log_commit(FILE *fp, char *fmt, const char *state,
265
struct strbuf commit_msg = STRBUF_INIT;
266
char *label = xstrfmt(fmt, state);
267
268
- format_commit_message(commit, "%s", &commit_msg, &pp);
268
+ repo_format_commit_message(the_repository, commit, "%s", &commit_msg,
269
+ &pp);
270
271
fprintf(fp, "# %s: [%s] %s\n", label, oid_to_hex(&commit->object.oid),
272
commit_msg.buf);
@@ -603,8 +604,8 @@ static int bisect_skipped_commits(struct bisect_terms *terms)
604
605
while ((commit = get_revision(&revs)) != NULL) {
606
strbuf_reset(&commit_name);
606
- format_commit_message(commit, "%s",
607
- &commit_name, &pp);
607
+ repo_format_commit_message(the_repository, commit, "%s",
608
+ &commit_name, &pp);
609
fprintf(fp, "# possible first %s commit: [%s] %s\n",
610
terms->term_bad, oid_to_hex(&commit->object.oid),
611
commit_name.buf);
@@ -633,7 +634,8 @@ static int bisect_successful(struct bisect_terms *terms)
634
635
read_ref(bad_ref, &oid);
636
commit = lookup_commit_reference_by_name(bad_ref);
636
- format_commit_message(commit, "%s", &commit_name, &pp);
637
+ repo_format_commit_message(the_repository, commit, "%s", &commit_name,
638
+ &pp);
639
640
res = append_to_file(git_path_bisect_log(), "# first %s commit: [%s] %s\n",
641
terms->term_bad, oid_to_hex(&commit->object.oid),
builtin/commit.c
+8
-5
@@ -719,7 +719,7 @@ static void prepare_amend_commit(struct commit *commit, struct strbuf *sb,
719
* duplicate the subject line.
720
*/
721
fmt = starts_with(subject, "amend!") ? "%b" : "%B";
722
- format_commit_message(commit, fmt, sb, ctx);
722
+ repo_format_commit_message(the_repository, commit, fmt, sb, ctx);
723
repo_unuse_commit_buffer(the_repository, commit, buffer);
724
}
725
@@ -760,8 +760,9 @@ static int prepare_to_commit(const char *index_file, const char *prefix,
760
if (!c)
761
die(_("could not lookup commit %s"), squash_message);
762
ctx.output_encoding = get_commit_output_encoding();
763
- format_commit_message(c, "squash! %s\n\n", &sb,
764
- &ctx);
763
+ repo_format_commit_message(the_repository, c,
764
+ "squash! %s\n\n", &sb,
765
+ &ctx);
766
}
767
}
768
@@ -795,7 +796,8 @@ static int prepare_to_commit(const char *index_file, const char *prefix,
796
die(_("could not lookup commit %s"), fixup_commit);
797
ctx.output_encoding = get_commit_output_encoding();
798
fmt = xstrfmt("%s! %%s\n\n", fixup_prefix);
798
- format_commit_message(commit, fmt, &sb, &ctx);
799
+ repo_format_commit_message(the_repository, commit, fmt, &sb,
800
+ &ctx);
801
free(fmt);
802
hook_arg1 = "message";
803
@@ -1135,7 +1137,8 @@ static const char *find_author_by_nickname(const char *name)
1137
struct pretty_print_context ctx = {0};
1138
ctx.date_mode.type = DATE_NORMAL;
1139
strbuf_release(&buf);
1138
- format_commit_message(commit, "%aN <%aE>", &buf, &ctx);
1140
+ repo_format_commit_message(the_repository, commit,
1141
+ "%aN <%aE>", &buf, &ctx);
1142
release_revisions(&revs);
1143
return strbuf_detach(&buf, NULL);
1144
}
builtin/notes.c
+2
-1
@@ -742,7 +742,8 @@ static int merge_commit(struct notes_merge_options *o)
742
743
/* Reuse existing commit message in reflog message */
744
memset(&pretty_ctx, 0, sizeof(pretty_ctx));
745
- format_commit_message(partial, "%s", &msg, &pretty_ctx);
745
+ repo_format_commit_message(the_repository, partial, "%s", &msg,
746
+ &pretty_ctx);
747
strbuf_trim(&msg);
748
strbuf_insertstr(&msg, 0, "notes: ");
749
update_ref(msg.buf, o->local_ref, &oid,
builtin/shortlog.c
+4
-2
@@ -223,7 +223,8 @@ static void insert_records_from_format(struct shortlog *log,
223
for_each_string_list_item(item, &log->format) {
224
strbuf_reset(&buf);
225
226
- format_commit_message(commit, item->string, &buf, ctx);
226
+ repo_format_commit_message(the_repository, commit,
227
+ item->string, &buf, ctx);
228
229
if (!shortlog_needs_dedup(log) || strset_add(dups, buf.buf))
230
insert_one_record(log, buf.buf, oneline);
@@ -249,7 +250,8 @@ void shortlog_add_commit(struct shortlog *log, struct commit *commit)
250
if (log->user_format)
251
pretty_print_commit(&ctx, commit, &oneline);
252
else
252
- format_commit_message(commit, "%s", &oneline, &ctx);
253
+ repo_format_commit_message(the_repository, commit,
254
+ "%s", &oneline, &ctx);
255
}
256
oneline_str = oneline.len ? oneline.buf : "<none>";
257
contrib/coccinelle/the_repository.cocci
+4
@@ -87,6 +87,10 @@
87
|
88
- has_object_file_with_flags
89
+ repo_has_object_file_with_flags
90
+// pretty.h
91
+|
92
+- format_commit_message
93
++ repo_format_commit_message
94
)
95
(
96
+ the_repository,
contrib/coccinelle/the_repository.pending.cocci
-4
@@ -5,11 +5,7 @@
5
@@
6
@@
7
(
8
-// pretty.h
9
-- format_commit_message
10
-+ repo_format_commit_message
8
// packfile.h
12
-|
9
- approximate_object_count
10
+ repo_approximate_object_count
11
// promisor-remote.h
fmt-merge-msg.c
+2
-1
@@ -385,7 +385,8 @@ static void shortlog(const char *name,
385
if (subjects.nr > limit)
386
continue;
387
388
- format_commit_message(commit, "%s", &sb, &ctx);
388
+ repo_format_commit_message(the_repository, commit, "%s", &sb,
389
+ &ctx);
390
strbuf_ltrim(&sb);
391
392
if (!sb.len)
log-tree.c
+6
-3
@@ -407,7 +407,8 @@ void fmt_output_commit(struct strbuf *filename,
407
struct pretty_print_context ctx = {0};
408
struct strbuf subject = STRBUF_INIT;
409
410
- format_commit_message(commit, "%f", &subject, &ctx);
410
+ repo_format_commit_message(the_repository, commit, "%f", &subject,
411
+ &ctx);
412
fmt_output_subject(filename, subject.buf, info);
413
strbuf_release(&subject);
414
}
@@ -985,8 +986,10 @@ static int do_remerge_diff(struct rev_info *opt,
986
o.msg_header_prefix = "remerge";
987
988
ctx.abbrev = DEFAULT_ABBREV;
988
- format_commit_message(parent1, "%h (%s)", &parent1_desc, &ctx);
989
- format_commit_message(parent2, "%h (%s)", &parent2_desc, &ctx);
989
+ repo_format_commit_message(the_repository, parent1, "%h (%s)",
990
+ &parent1_desc, &ctx);
991
+ repo_format_commit_message(the_repository, parent2, "%h (%s)",
992
+ &parent2_desc, &ctx);
993
o.branch1 = parent1_desc.buf;
994
o.branch2 = parent2_desc.buf;
995
notes-cache.c
+2
-1
@@ -23,7 +23,8 @@ static int notes_cache_match_validity(struct repository *r,
23
return 0;
24
25
memset(&pretty_ctx, 0, sizeof(pretty_ctx));
26
- format_commit_message(commit, "%s", &msg, &pretty_ctx);
26
+ repo_format_commit_message(the_repository, commit, "%s", &msg,
27
+ &pretty_ctx);
28
strbuf_trim(&msg);
29
30
ret = !strcmp(msg.buf, validity);
object-name.c
+4
-2
@@ -394,8 +394,10 @@ static int show_ambiguous_object(const struct object_id *oid, void *data)
394
if (commit) {
395
struct pretty_print_context pp = {0};
396
pp.date_mode.type = DATE_SHORT;
397
- format_commit_message(commit, "%ad", &date, &pp);
398
- format_commit_message(commit, "%s", &msg, &pp);
397
+ repo_format_commit_message(the_repository, commit,
398
+ "%ad", &date, &pp);
399
+ repo_format_commit_message(the_repository, commit,
400
+ "%s", &msg, &pp);
401
}
402
403
/*
pretty.c
+2
-1
@@ -2199,7 +2199,8 @@ void pretty_print_commit(struct pretty_print_context *pp,
2199
int need_8bit_cte = pp->need_8bit_cte;
2200
2201
if (pp->fmt == CMIT_FMT_USERFORMAT) {
2202
- format_commit_message(commit, user_format, sb, pp);
2202
+ repo_format_commit_message(the_repository, commit,
2203
+ user_format, sb, pp);
2204
return;
2205
}
2206
pretty.h
-4
@@ -120,10 +120,6 @@ void repo_format_commit_message(struct repository *r,
120
const struct commit *commit,
121
const char *format, struct strbuf *sb,
122
const struct pretty_print_context *context);
123
-#ifndef NO_THE_REPOSITORY_COMPATIBILITY_MACROS
124
-#define format_commit_message(c, f, s, con) \
125
- repo_format_commit_message(the_repository, c, f, s, con)
126
-#endif
123
124
/*
125
* Parse given arguments from "arg", check it for correctness and
sequencer.c
+8
-4
@@ -1343,8 +1343,10 @@ void print_commit_summary(struct repository *r,
1343
1344
strbuf_addstr(&format, "format:%h] %s");
1345
1346
- format_commit_message(commit, "%an <%ae>", &author_ident, &pctx);
1347
- format_commit_message(commit, "%cn <%ce>", &committer_ident, &pctx);
1346
+ repo_format_commit_message(the_repository, commit, "%an <%ae>",
1347
+ &author_ident, &pctx);
1348
+ repo_format_commit_message(the_repository, commit, "%cn <%ce>",
1349
+ &committer_ident, &pctx);
1350
if (strbuf_cmp(&author_ident, &committer_ident)) {
1351
strbuf_addstr(&format, "\n Author: ");
1352
strbuf_addbuf_percentquote(&format, &author_ident);
@@ -1352,7 +1354,8 @@ void print_commit_summary(struct repository *r,
1354
if (flags & SUMMARY_SHOW_AUTHOR_DATE) {
1355
struct strbuf date = STRBUF_INIT;
1356
1355
- format_commit_message(commit, "%ad", &date, &pctx);
1357
+ repo_format_commit_message(the_repository, commit, "%ad",
1358
+ &date, &pctx);
1359
strbuf_addstr(&format, "\n Date: ");
1360
strbuf_addbuf_percentquote(&format, &date);
1361
strbuf_release(&date);
@@ -2125,7 +2128,8 @@ static void refer_to_commit(struct replay_opts *opts,
2128
.abbrev = DEFAULT_ABBREV,
2129
.date_mode.type = DATE_SHORT,
2130
};
2128
- format_commit_message(commit, "%h (%s, %ad)", msgbuf, &ctx);
2131
+ repo_format_commit_message(the_repository, commit,
2132
+ "%h (%s, %ad)", msgbuf, &ctx);
2133
} else {
2134
strbuf_addstr(msgbuf, oid_to_hex(&commit->object.oid));
2135
}
t/helper/test-revision-walking.c
+2
-1
@@ -19,7 +19,8 @@ static void print_commit(struct commit *commit)
19
struct strbuf sb = STRBUF_INIT;
20
struct pretty_print_context ctx = {0};
21
ctx.date_mode.type = DATE_NORMAL;
22
- format_commit_message(commit, " %m %s", &sb, &ctx);
22
+ repo_format_commit_message(the_repository, commit, " %m %s", &sb,
23
+ &ctx);
24
printf("%s\n", sb.buf);
25
strbuf_release(&sb);
26
}