Skip to content

Commit bab8216

Browse files
avargitster
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent bc726bd commit bab8216

16 files changed

+54
-35
lines changed

archive.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,8 @@ static void format_subst(const struct commit *commit,
5959
strbuf_add(&fmt, b + 8, c - b - 8);
6060

6161
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);
6364
len -= c + 1 - src;
6465
src = c + 1;
6566
}

bisect.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -752,7 +752,8 @@ enum bisect_error bisect_checkout(const struct object_id *bisect_rev,
752752
}
753753

754754
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);
756757
fputs(commit_msg.buf, stdout);
757758
strbuf_release(&commit_msg);
758759

builtin/bisect.c

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -265,7 +265,8 @@ static void log_commit(FILE *fp, char *fmt, const char *state,
265265
struct strbuf commit_msg = STRBUF_INIT;
266266
char *label = xstrfmt(fmt, state);
267267

268-
format_commit_message(commit, "%s", &commit_msg, &pp);
268+
repo_format_commit_message(the_repository, commit, "%s", &commit_msg,
269+
&pp);
269270

270271
fprintf(fp, "# %s: [%s] %s\n", label, oid_to_hex(&commit->object.oid),
271272
commit_msg.buf);
@@ -603,8 +604,8 @@ static int bisect_skipped_commits(struct bisect_terms *terms)
603604

604605
while ((commit = get_revision(&revs)) != NULL) {
605606
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);
608609
fprintf(fp, "# possible first %s commit: [%s] %s\n",
609610
terms->term_bad, oid_to_hex(&commit->object.oid),
610611
commit_name.buf);
@@ -633,7 +634,8 @@ static int bisect_successful(struct bisect_terms *terms)
633634

634635
read_ref(bad_ref, &oid);
635636
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);
637639

638640
res = append_to_file(git_path_bisect_log(), "# first %s commit: [%s] %s\n",
639641
terms->term_bad, oid_to_hex(&commit->object.oid),

builtin/commit.c

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -719,7 +719,7 @@ static void prepare_amend_commit(struct commit *commit, struct strbuf *sb,
719719
* duplicate the subject line.
720720
*/
721721
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);
723723
repo_unuse_commit_buffer(the_repository, commit, buffer);
724724
}
725725

@@ -760,8 +760,9 @@ static int prepare_to_commit(const char *index_file, const char *prefix,
760760
if (!c)
761761
die(_("could not lookup commit %s"), squash_message);
762762
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);
765766
}
766767
}
767768

@@ -795,7 +796,8 @@ static int prepare_to_commit(const char *index_file, const char *prefix,
795796
die(_("could not lookup commit %s"), fixup_commit);
796797
ctx.output_encoding = get_commit_output_encoding();
797798
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);
799801
free(fmt);
800802
hook_arg1 = "message";
801803

@@ -1135,7 +1137,8 @@ static const char *find_author_by_nickname(const char *name)
11351137
struct pretty_print_context ctx = {0};
11361138
ctx.date_mode.type = DATE_NORMAL;
11371139
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);
11391142
release_revisions(&revs);
11401143
return strbuf_detach(&buf, NULL);
11411144
}

builtin/notes.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -742,7 +742,8 @@ static int merge_commit(struct notes_merge_options *o)
742742

743743
/* Reuse existing commit message in reflog message */
744744
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);
746747
strbuf_trim(&msg);
747748
strbuf_insertstr(&msg, 0, "notes: ");
748749
update_ref(msg.buf, o->local_ref, &oid,

builtin/shortlog.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,8 @@ static void insert_records_from_format(struct shortlog *log,
223223
for_each_string_list_item(item, &log->format) {
224224
strbuf_reset(&buf);
225225

226-
format_commit_message(commit, item->string, &buf, ctx);
226+
repo_format_commit_message(the_repository, commit,
227+
item->string, &buf, ctx);
227228

228229
if (!shortlog_needs_dedup(log) || strset_add(dups, buf.buf))
229230
insert_one_record(log, buf.buf, oneline);
@@ -249,7 +250,8 @@ void shortlog_add_commit(struct shortlog *log, struct commit *commit)
249250
if (log->user_format)
250251
pretty_print_commit(&ctx, commit, &oneline);
251252
else
252-
format_commit_message(commit, "%s", &oneline, &ctx);
253+
repo_format_commit_message(the_repository, commit,
254+
"%s", &oneline, &ctx);
253255
}
254256
oneline_str = oneline.len ? oneline.buf : "<none>";
255257

contrib/coccinelle/the_repository.cocci

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,10 @@
8787
|
8888
- has_object_file_with_flags
8989
+ repo_has_object_file_with_flags
90+
// pretty.h
91+
|
92+
- format_commit_message
93+
+ repo_format_commit_message
9094
)
9195
(
9296
+ the_repository,

contrib/coccinelle/the_repository.pending.cocci

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,7 @@
55
@@
66
@@
77
(
8-
// pretty.h
9-
- format_commit_message
10-
+ repo_format_commit_message
118
// packfile.h
12-
|
139
- approximate_object_count
1410
+ repo_approximate_object_count
1511
// promisor-remote.h

fmt-merge-msg.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -385,7 +385,8 @@ static void shortlog(const char *name,
385385
if (subjects.nr > limit)
386386
continue;
387387

388-
format_commit_message(commit, "%s", &sb, &ctx);
388+
repo_format_commit_message(the_repository, commit, "%s", &sb,
389+
&ctx);
389390
strbuf_ltrim(&sb);
390391

391392
if (!sb.len)

log-tree.c

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -407,7 +407,8 @@ void fmt_output_commit(struct strbuf *filename,
407407
struct pretty_print_context ctx = {0};
408408
struct strbuf subject = STRBUF_INIT;
409409

410-
format_commit_message(commit, "%f", &subject, &ctx);
410+
repo_format_commit_message(the_repository, commit, "%f", &subject,
411+
&ctx);
411412
fmt_output_subject(filename, subject.buf, info);
412413
strbuf_release(&subject);
413414
}
@@ -985,8 +986,10 @@ static int do_remerge_diff(struct rev_info *opt,
985986
o.msg_header_prefix = "remerge";
986987

987988
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);
990993
o.branch1 = parent1_desc.buf;
991994
o.branch2 = parent2_desc.buf;
992995

0 commit comments

Comments
 (0)