Skip to content

Commit ecb5091

Browse files
avargitster
authored andcommitted
cocci: apply the "commit.h" part of "the_repository.pending"
Apply the part of "the_repository.pending.cocci" pertaining to "commit.h". Signed-off-by: Ævar Arnfjörð Bjarmason <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent cb338c2 commit ecb5091

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+196
-174
lines changed

blame.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2429,7 +2429,7 @@ static void pass_blame(struct blame_scoreboard *sb, struct blame_origin *origin,
24292429

24302430
if (sg_origin[i])
24312431
continue;
2432-
if (parse_commit(p))
2432+
if (repo_parse_commit(the_repository, p))
24332433
continue;
24342434
porigin = find(sb->repo, p, origin, sb->bloom_data);
24352435
if (!porigin)
@@ -2592,7 +2592,7 @@ void assign_blame(struct blame_scoreboard *sb, int opt)
25922592
* so hold onto it in the meantime.
25932593
*/
25942594
blame_origin_incref(suspect);
2595-
parse_commit(commit);
2595+
repo_parse_commit(the_repository, commit);
25962596
if (sb->reverse ||
25972597
(!(commit->object.flags & UNINTERESTING) &&
25982598
!(revs->max_age != -1 && commit->date < revs->max_age)))

builtin/am.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1329,7 +1329,8 @@ static void get_commit_info(struct am_state *state, struct commit *commit)
13291329
size_t ident_len;
13301330
struct ident_split id;
13311331

1332-
buffer = logmsg_reencode(commit, NULL, get_commit_output_encoding());
1332+
buffer = repo_logmsg_reencode(the_repository, commit, NULL,
1333+
get_commit_output_encoding());
13331334

13341335
ident_line = find_commit_header(buffer, "author", &ident_len);
13351336
if (!ident_line)
@@ -1361,7 +1362,7 @@ static void get_commit_info(struct am_state *state, struct commit *commit)
13611362
die(_("unable to parse commit %s"), oid_to_hex(&commit->object.oid));
13621363
state->msg = xstrdup(msg + 2);
13631364
state->msg_len = strlen(state->msg);
1364-
unuse_commit_buffer(commit, buffer);
1365+
repo_unuse_commit_buffer(the_repository, commit, buffer);
13651366
}
13661367

13671368
/**
@@ -1404,7 +1405,7 @@ static void write_index_patch(const struct am_state *state)
14041405

14051406
if (!repo_get_oid(the_repository, "HEAD", &head)) {
14061407
struct commit *commit = lookup_commit_or_die(&head, "HEAD");
1407-
tree = get_commit_tree(commit);
1408+
tree = repo_get_commit_tree(the_repository, commit);
14081409
} else
14091410
tree = lookup_tree(the_repository,
14101411
the_repository->hash_algo->empty_tree);

builtin/blame.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -199,13 +199,13 @@ static void get_commit_info(struct commit *commit,
199199
const char *message;
200200

201201
encoding = get_log_output_encoding();
202-
message = logmsg_reencode(commit, NULL, encoding);
202+
message = repo_logmsg_reencode(the_repository, commit, NULL, encoding);
203203
get_ac_line(message, "\nauthor ",
204204
&ret->author, &ret->author_mail,
205205
&ret->author_time, &ret->author_tz);
206206

207207
if (!detailed) {
208-
unuse_commit_buffer(commit, message);
208+
repo_unuse_commit_buffer(the_repository, commit, message);
209209
return;
210210
}
211211

@@ -219,7 +219,7 @@ static void get_commit_info(struct commit *commit,
219219
else
220220
strbuf_addf(&ret->summary, "(%s)", oid_to_hex(&commit->object.oid));
221221

222-
unuse_commit_buffer(commit, message);
222+
repo_unuse_commit_buffer(the_repository, commit, message);
223223
}
224224

225225
/*

builtin/checkout.c

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -640,7 +640,7 @@ static void describe_detached_head(const char *msg, struct commit *commit)
640640
{
641641
struct strbuf sb = STRBUF_INIT;
642642

643-
if (!parse_commit(commit))
643+
if (!repo_parse_commit(the_repository, commit))
644644
pp_commit_easy(CMIT_FMT_ONELINE, commit, &sb);
645645
if (print_sha1_ellipsis()) {
646646
fprintf(stderr, "%s %s... %s\n", msg,
@@ -755,7 +755,8 @@ static int merge_working_tree(const struct checkout_opts *opts,
755755
BUG("'switch --orphan' should never accept a commit as starting point");
756756
new_tree = parse_tree_indirect(the_hash_algo->empty_tree);
757757
} else
758-
new_tree = get_commit_tree(new_branch_info->commit);
758+
new_tree = repo_get_commit_tree(the_repository,
759+
new_branch_info->commit);
759760
if (opts->discard_changes) {
760761
ret = reset_tree(new_tree, opts, 1, writeout_error, new_branch_info);
761762
if (ret)
@@ -817,7 +818,8 @@ static int merge_working_tree(const struct checkout_opts *opts,
817818
*/
818819
if (!old_branch_info->commit)
819820
return 1;
820-
old_tree = get_commit_tree(old_branch_info->commit);
821+
old_tree = repo_get_commit_tree(the_repository,
822+
old_branch_info->commit);
821823

822824
if (repo_index_has_changes(the_repository, old_tree, &sb))
823825
die(_("cannot continue with staged changes in "
@@ -1006,7 +1008,7 @@ static void describe_one_orphan(struct strbuf *sb, struct commit *commit)
10061008
strbuf_addstr(sb, " ");
10071009
strbuf_add_unique_abbrev(sb, &commit->object.oid, DEFAULT_ABBREV);
10081010
strbuf_addch(sb, ' ');
1009-
if (!parse_commit(commit))
1011+
if (!repo_parse_commit(the_repository, commit))
10101012
pp_commit_easy(CMIT_FMT_ONELINE, commit, sb);
10111013
strbuf_addch(sb, '\n');
10121014
}
@@ -1206,7 +1208,8 @@ static void setup_new_branch_info_and_source_tree(
12061208
*source_tree = parse_tree_indirect(rev);
12071209
} else {
12081210
parse_commit_or_die(new_branch_info->commit);
1209-
*source_tree = get_commit_tree(new_branch_info->commit);
1211+
*source_tree = repo_get_commit_tree(the_repository,
1212+
new_branch_info->commit);
12101213
}
12111214
}
12121215

builtin/commit.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -712,15 +712,15 @@ static void prepare_amend_commit(struct commit *commit, struct strbuf *sb,
712712
{
713713
const char *buffer, *subject, *fmt;
714714

715-
buffer = get_commit_buffer(commit, NULL);
715+
buffer = repo_get_commit_buffer(the_repository, commit, NULL);
716716
find_commit_subject(buffer, &subject);
717717
/*
718718
* If we amend the 'amend!' commit then we don't want to
719719
* duplicate the subject line.
720720
*/
721721
fmt = starts_with(subject, "amend!") ? "%b" : "%B";
722722
format_commit_message(commit, fmt, sb, ctx);
723-
unuse_commit_buffer(commit, buffer);
723+
repo_unuse_commit_buffer(the_repository, commit, buffer);
724724
}
725725

726726
static int prepare_to_commit(const char *index_file, const char *prefix,
@@ -1183,7 +1183,7 @@ static const char *read_commit_message(const char *name)
11831183
if (!commit)
11841184
die(_("could not lookup commit %s"), name);
11851185
out_enc = get_commit_output_encoding();
1186-
return logmsg_reencode(commit, NULL, out_enc);
1186+
return repo_logmsg_reencode(the_repository, commit, NULL, out_enc);
11871187
}
11881188

11891189
/*
@@ -1718,7 +1718,7 @@ int cmd_commit(int argc, const char **argv, const char *prefix)
17181718
current_head = NULL;
17191719
else {
17201720
current_head = lookup_commit_or_die(&oid, "HEAD");
1721-
if (parse_commit(current_head))
1721+
if (repo_parse_commit(the_repository, current_head))
17221722
die(_("could not parse HEAD commit"));
17231723
}
17241724
verbose = -1; /* unspecified */

builtin/describe.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -261,7 +261,7 @@ static unsigned long finish_depth_computation(
261261
best->depth++;
262262
while (parents) {
263263
struct commit *p = parents->item;
264-
parse_commit(p);
264+
repo_parse_commit(the_repository, p);
265265
if (!(p->object.flags & SEEN))
266266
commit_list_insert_by_date(p, list);
267267
p->object.flags |= c->object.flags;
@@ -404,7 +404,7 @@ static void describe_commit(struct object_id *oid, struct strbuf *dst)
404404
}
405405
while (parents) {
406406
struct commit *p = parents->item;
407-
parse_commit(p);
407+
repo_parse_commit(the_repository, p);
408408
if (!(p->object.flags & SEEN))
409409
commit_list_insert_by_date(p, &list);
410410
p->object.flags |= c->object.flags;

builtin/diff.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -548,7 +548,8 @@ int cmd_diff(int argc, const char **argv, const char *prefix)
548548
if (!obj)
549549
die(_("invalid object '%s' given."), name);
550550
if (obj->type == OBJ_COMMIT)
551-
obj = &get_commit_tree(((struct commit *)obj))->object;
551+
obj = &repo_get_commit_tree(the_repository,
552+
((struct commit *)obj))->object;
552553

553554
if (obj->type == OBJ_TREE) {
554555
if (sdiff.skip && bitmap_get(sdiff.skip, i))

builtin/fast-export.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -618,7 +618,7 @@ static void handle_commit(struct commit *commit, struct rev_info *rev,
618618
rev->diffopt.output_format = DIFF_FORMAT_CALLBACK;
619619

620620
parse_commit_or_die(commit);
621-
commit_buffer = get_commit_buffer(commit, NULL);
621+
commit_buffer = repo_get_commit_buffer(the_repository, commit, NULL);
622622
author = strstr(commit_buffer, "\nauthor ");
623623
if (!author)
624624
die("could not find author in commit %s",
@@ -699,7 +699,7 @@ static void handle_commit(struct commit *commit, struct rev_info *rev,
699699
? strlen(message) : 0),
700700
reencoded ? reencoded : message ? message : "");
701701
free(reencoded);
702-
unuse_commit_buffer(commit, commit_buffer);
702+
repo_unuse_commit_buffer(the_repository, commit, commit_buffer);
703703

704704
for (i = 0, p = commit->parents; p; p = p->next) {
705705
struct object *obj = &p->item->object;

builtin/gc.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -820,7 +820,7 @@ static int dfs_on_ref(const char *refname UNUSED,
820820
commit = lookup_commit(the_repository, oid);
821821
if (!commit)
822822
return 0;
823-
if (parse_commit(commit) ||
823+
if (repo_parse_commit(the_repository, commit) ||
824824
commit_graph_position(commit) != COMMIT_NOT_FROM_GRAPH)
825825
return 0;
826826

@@ -837,7 +837,7 @@ static int dfs_on_ref(const char *refname UNUSED,
837837
commit = pop_commit(&stack);
838838

839839
for (parent = commit->parents; parent; parent = parent->next) {
840-
if (parse_commit(parent->item) ||
840+
if (repo_parse_commit(the_repository, parent->item) ||
841841
commit_graph_position(parent->item) != COMMIT_NOT_FROM_GRAPH ||
842842
parent->item->object.flags & SEEN)
843843
continue;

builtin/log.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1314,10 +1314,11 @@ static void make_cover_letter(struct rev_info *rev, int use_separate_file,
13141314
log_write_email_headers(rev, head, &pp.after_subject, &need_8bit_cte, 0);
13151315

13161316
for (i = 0; !need_8bit_cte && i < nr; i++) {
1317-
const char *buf = get_commit_buffer(list[i], NULL);
1317+
const char *buf = repo_get_commit_buffer(the_repository,
1318+
list[i], NULL);
13181319
if (has_non_ascii(buf))
13191320
need_8bit_cte = 1;
1320-
unuse_commit_buffer(list[i], buf);
1321+
repo_unuse_commit_buffer(the_repository, list[i], buf);
13211322
}
13221323

13231324
if (!branch_name)

0 commit comments

Comments
 (0)