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 <avarab@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Ævar Arnfjörð Bjarmason committed Mar 28, 2023 at 15:58 UTC ecb5091fd4301ac647db0bd2504112b38f7ee06d
44 files changed +196 -174
blame.c
+2 -2
@@ -2429,7 +2429,7 @@ static void pass_blame(struct blame_scoreboard *sb, struct blame_origin *origin,
2429
2430 if (sg_origin[i])
2431 continue;
2432 - if (parse_commit(p))
2432 + if (repo_parse_commit(the_repository, p))
2433 continue;
2434 porigin = find(sb->repo, p, origin, sb->bloom_data);
2435 if (!porigin)
@@ -2592,7 +2592,7 @@ void assign_blame(struct blame_scoreboard *sb, int opt)
2592 * so hold onto it in the meantime.
2593 */
2594 blame_origin_incref(suspect);
2595 - parse_commit(commit);
2595 + repo_parse_commit(the_repository, commit);
2596 if (sb->reverse ||
2597 (!(commit->object.flags & UNINTERESTING) &&
2598 !(revs->max_age != -1 && commit->date < revs->max_age)))
builtin/am.c
+4 -3
@@ -1329,7 +1329,8 @@ static void get_commit_info(struct am_state *state, struct commit *commit)
1329 size_t ident_len;
1330 struct ident_split id;
1331
1332 - buffer = logmsg_reencode(commit, NULL, get_commit_output_encoding());
1332 + buffer = repo_logmsg_reencode(the_repository, commit, NULL,
1333 + get_commit_output_encoding());
1334
1335 ident_line = find_commit_header(buffer, "author", &ident_len);
1336 if (!ident_line)
@@ -1361,7 +1362,7 @@ static void get_commit_info(struct am_state *state, struct commit *commit)
1362 die(_("unable to parse commit %s"), oid_to_hex(&commit->object.oid));
1363 state->msg = xstrdup(msg + 2);
1364 state->msg_len = strlen(state->msg);
1364 - unuse_commit_buffer(commit, buffer);
1365 + repo_unuse_commit_buffer(the_repository, commit, buffer);
1366 }
1367
1368 /**
@@ -1404,7 +1405,7 @@ static void write_index_patch(const struct am_state *state)
1405
1406 if (!repo_get_oid(the_repository, "HEAD", &head)) {
1407 struct commit *commit = lookup_commit_or_die(&head, "HEAD");
1407 - tree = get_commit_tree(commit);
1408 + tree = repo_get_commit_tree(the_repository, commit);
1409 } else
1410 tree = lookup_tree(the_repository,
1411 the_repository->hash_algo->empty_tree);
builtin/blame.c
+3 -3
@@ -199,13 +199,13 @@ static void get_commit_info(struct commit *commit,
199 const char *message;
200
201 encoding = get_log_output_encoding();
202 - message = logmsg_reencode(commit, NULL, encoding);
202 + message = repo_logmsg_reencode(the_repository, commit, NULL, encoding);
203 get_ac_line(message, "\nauthor ",
204 &ret->author, &ret->author_mail,
205 &ret->author_time, &ret->author_tz);
206
207 if (!detailed) {
208 - unuse_commit_buffer(commit, message);
208 + repo_unuse_commit_buffer(the_repository, commit, message);
209 return;
210 }
211
@@ -219,7 +219,7 @@ static void get_commit_info(struct commit *commit,
219 else
220 strbuf_addf(&ret->summary, "(%s)", oid_to_hex(&commit->object.oid));
221
222 - unuse_commit_buffer(commit, message);
222 + repo_unuse_commit_buffer(the_repository, commit, message);
223 }
224
225 /*
builtin/checkout.c
+8 -5
@@ -640,7 +640,7 @@ static void describe_detached_head(const char *msg, struct commit *commit)
640 {
641 struct strbuf sb = STRBUF_INIT;
642
643 - if (!parse_commit(commit))
643 + if (!repo_parse_commit(the_repository, commit))
644 pp_commit_easy(CMIT_FMT_ONELINE, commit, &sb);
645 if (print_sha1_ellipsis()) {
646 fprintf(stderr, "%s %s... %s\n", msg,
@@ -755,7 +755,8 @@ static int merge_working_tree(const struct checkout_opts *opts,
755 BUG("'switch --orphan' should never accept a commit as starting point");
756 new_tree = parse_tree_indirect(the_hash_algo->empty_tree);
757 } 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);
760 if (opts->discard_changes) {
761 ret = reset_tree(new_tree, opts, 1, writeout_error, new_branch_info);
762 if (ret)
@@ -817,7 +818,8 @@ static int merge_working_tree(const struct checkout_opts *opts,
818 */
819 if (!old_branch_info->commit)
820 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);
823
824 if (repo_index_has_changes(the_repository, old_tree, &sb))
825 die(_("cannot continue with staged changes in "
@@ -1006,7 +1008,7 @@ static void describe_one_orphan(struct strbuf *sb, struct commit *commit)
1008 strbuf_addstr(sb, " ");
1009 strbuf_add_unique_abbrev(sb, &commit->object.oid, DEFAULT_ABBREV);
1010 strbuf_addch(sb, ' ');
1009 - if (!parse_commit(commit))
1011 + if (!repo_parse_commit(the_repository, commit))
1012 pp_commit_easy(CMIT_FMT_ONELINE, commit, sb);
1013 strbuf_addch(sb, '\n');
1014 }
@@ -1206,7 +1208,8 @@ static void setup_new_branch_info_and_source_tree(
1208 *source_tree = parse_tree_indirect(rev);
1209 } else {
1210 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);
1213 }
1214 }
1215
builtin/commit.c
+4 -4
@@ -712,7 +712,7 @@ static void prepare_amend_commit(struct commit *commit, struct strbuf *sb,
712 {
713 const char *buffer, *subject, *fmt;
714
715 - buffer = get_commit_buffer(commit, NULL);
715 + buffer = repo_get_commit_buffer(the_repository, commit, NULL);
716 find_commit_subject(buffer, &subject);
717 /*
718 * If we amend the 'amend!' commit then we don't want to
@@ -720,7 +720,7 @@ static void prepare_amend_commit(struct commit *commit, struct strbuf *sb,
720 */
721 fmt = starts_with(subject, "amend!") ? "%b" : "%B";
722 format_commit_message(commit, fmt, sb, ctx);
723 - unuse_commit_buffer(commit, buffer);
723 + repo_unuse_commit_buffer(the_repository, commit, buffer);
724 }
725
726 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)
1183 if (!commit)
1184 die(_("could not lookup commit %s"), name);
1185 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);
1187 }
1188
1189 /*
@@ -1718,7 +1718,7 @@ int cmd_commit(int argc, const char **argv, const char *prefix)
1718 current_head = NULL;
1719 else {
1720 current_head = lookup_commit_or_die(&oid, "HEAD");
1721 - if (parse_commit(current_head))
1721 + if (repo_parse_commit(the_repository, current_head))
1722 die(_("could not parse HEAD commit"));
1723 }
1724 verbose = -1; /* unspecified */
builtin/describe.c
+2 -2
@@ -261,7 +261,7 @@ static unsigned long finish_depth_computation(
261 best->depth++;
262 while (parents) {
263 struct commit *p = parents->item;
264 - parse_commit(p);
264 + repo_parse_commit(the_repository, p);
265 if (!(p->object.flags & SEEN))
266 commit_list_insert_by_date(p, list);
267 p->object.flags |= c->object.flags;
@@ -404,7 +404,7 @@ static void describe_commit(struct object_id *oid, struct strbuf *dst)
404 }
405 while (parents) {
406 struct commit *p = parents->item;
407 - parse_commit(p);
407 + repo_parse_commit(the_repository, p);
408 if (!(p->object.flags & SEEN))
409 commit_list_insert_by_date(p, &list);
410 p->object.flags |= c->object.flags;
builtin/diff.c
+2 -1
@@ -548,7 +548,8 @@ int cmd_diff(int argc, const char **argv, const char *prefix)
548 if (!obj)
549 die(_("invalid object '%s' given."), name);
550 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;
553
554 if (obj->type == OBJ_TREE) {
555 if (sdiff.skip && bitmap_get(sdiff.skip, i))
builtin/fast-export.c
+2 -2
@@ -618,7 +618,7 @@ static void handle_commit(struct commit *commit, struct rev_info *rev,
618 rev->diffopt.output_format = DIFF_FORMAT_CALLBACK;
619
620 parse_commit_or_die(commit);
621 - commit_buffer = get_commit_buffer(commit, NULL);
621 + commit_buffer = repo_get_commit_buffer(the_repository, commit, NULL);
622 author = strstr(commit_buffer, "\nauthor ");
623 if (!author)
624 die("could not find author in commit %s",
@@ -699,7 +699,7 @@ static void handle_commit(struct commit *commit, struct rev_info *rev,
699 ? strlen(message) : 0),
700 reencoded ? reencoded : message ? message : "");
701 free(reencoded);
702 - unuse_commit_buffer(commit, commit_buffer);
702 + repo_unuse_commit_buffer(the_repository, commit, commit_buffer);
703
704 for (i = 0, p = commit->parents; p; p = p->next) {
705 struct object *obj = &p->item->object;
builtin/gc.c
+2 -2
@@ -820,7 +820,7 @@ static int dfs_on_ref(const char *refname UNUSED,
820 commit = lookup_commit(the_repository, oid);
821 if (!commit)
822 return 0;
823 - if (parse_commit(commit) ||
823 + if (repo_parse_commit(the_repository, commit) ||
824 commit_graph_position(commit) != COMMIT_NOT_FROM_GRAPH)
825 return 0;
826
@@ -837,7 +837,7 @@ static int dfs_on_ref(const char *refname UNUSED,
837 commit = pop_commit(&stack);
838
839 for (parent = commit->parents; parent; parent = parent->next) {
840 - if (parse_commit(parent->item) ||
840 + if (repo_parse_commit(the_repository, parent->item) ||
841 commit_graph_position(parent->item) != COMMIT_NOT_FROM_GRAPH ||
842 parent->item->object.flags & SEEN)
843 continue;
builtin/log.c
+3 -2
@@ -1314,10 +1314,11 @@ static void make_cover_letter(struct rev_info *rev, int use_separate_file,
1314 log_write_email_headers(rev, head, &pp.after_subject, &need_8bit_cte, 0);
1315
1316 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);
1319 if (has_non_ascii(buf))
1320 need_8bit_cte = 1;
1320 - unuse_commit_buffer(list[i], buf);
1321 + repo_unuse_commit_buffer(the_repository, list[i], buf);
1322 }
1323
1324 if (!branch_name)
builtin/merge-tree.c
+3 -3
@@ -443,9 +443,9 @@ static int real_merge(struct merge_tree_options *o,
443 die(_("could not lookup commit %s"), merge_base);
444
445 opt.ancestor = merge_base;
446 - base_tree = get_commit_tree(base_commit);
447 - parent1_tree = get_commit_tree(parent1);
448 - parent2_tree = get_commit_tree(parent2);
446 + base_tree = repo_get_commit_tree(the_repository, base_commit);
447 + parent1_tree = repo_get_commit_tree(the_repository, parent1);
448 + parent2_tree = repo_get_commit_tree(the_repository, parent2);
449 merge_incore_nonrecursive(&opt, base_tree, parent1_tree, parent2_tree, &result);
450 } else {
451 /*
builtin/merge.c
+2 -1
@@ -1611,7 +1611,8 @@ int cmd_merge(int argc, const char **argv, const char *prefix)
1611 * Must first ensure that index matches HEAD before
1612 * attempting a trivial merge.
1613 */
1614 - struct tree *head_tree = get_commit_tree(head_commit);
1614 + struct tree *head_tree = repo_get_commit_tree(the_repository,
1615 + head_commit);
1616 struct strbuf sb = STRBUF_INIT;
1617
1618 if (repo_index_has_changes(the_repository, head_tree,
builtin/name-rev.c
+2 -2
@@ -181,7 +181,7 @@ static void name_rev(struct commit *start_commit,
181 size_t parents_to_queue_nr, parents_to_queue_alloc = 0;
182 struct rev_name *start_name;
183
184 - parse_commit(start_commit);
184 + repo_parse_commit(the_repository, start_commit);
185 if (commit_is_before_cutoff(start_commit))
186 return;
187
@@ -211,7 +211,7 @@ static void name_rev(struct commit *start_commit,
211 struct rev_name *parent_name;
212 int generation, distance;
213
214 - parse_commit(parent);
214 + repo_parse_commit(the_repository, parent);
215 if (commit_is_before_cutoff(parent))
216 continue;
217
builtin/notes.c
+1 -1
@@ -720,7 +720,7 @@ static int merge_commit(struct notes_merge_options *o)
720 die(_("failed to read ref NOTES_MERGE_PARTIAL"));
721 else if (!(partial = lookup_commit_reference(the_repository, &oid)))
722 die(_("could not find commit from NOTES_MERGE_PARTIAL."));
723 - else if (parse_commit(partial))
723 + else if (repo_parse_commit(the_repository, partial))
724 die(_("could not parse commit from NOTES_MERGE_PARTIAL."));
725
726 if (partial->parents)
builtin/rebase.c
+1 -1
@@ -853,7 +853,7 @@ static int checkout_up_to_date(struct rebase_options *options)
853 static int is_linear_history(struct commit *from, struct commit *to)
854 {
855 while (to && to != from) {
856 - parse_commit(to);
856 + repo_parse_commit(the_repository, to);
857 if (!to->parents)
858 return 1;
859 if (to->parents->next)
builtin/replace.c
+2 -2
@@ -458,9 +458,9 @@ static int create_graft(int argc, const char **argv, int force, int gentle)
458 if (!commit)
459 return error(_("could not parse %s"), old_ref);
460
461 - buffer = get_commit_buffer(commit, &size);
461 + buffer = repo_get_commit_buffer(the_repository, commit, &size);
462 strbuf_add(&buf, buffer, size);
463 - unuse_commit_buffer(commit, buffer);
463 + repo_unuse_commit_buffer(the_repository, commit, buffer);
464
465 if (replace_parents(&buf, argc - 1, &argv[1]) < 0) {
466 strbuf_release(&buf);
builtin/shortlog.c
+3 -2
@@ -179,7 +179,8 @@ static void insert_records_from_trailers(struct shortlog *log,
179 * Using format_commit_message("%B") would be simpler here, but
180 * this saves us copying the message.
181 */
182 - commit_buffer = logmsg_reencode(commit, NULL, ctx->output_encoding);
182 + commit_buffer = repo_logmsg_reencode(the_repository, commit, NULL,
183 + ctx->output_encoding);
184 body = strstr(commit_buffer, "\n\n");
185 if (!body)
186 return;
@@ -202,7 +203,7 @@ static void insert_records_from_trailers(struct shortlog *log,
203 trailer_iterator_release(&iter);
204
205 strbuf_release(&ident);
205 - unuse_commit_buffer(commit, commit_buffer);
206 + repo_unuse_commit_buffer(the_repository, commit, commit_buffer);
207 }
208
209 static int shortlog_needs_dedup(const struct shortlog *log)
builtin/show-branch.c
+2 -2
@@ -240,7 +240,7 @@ static void join_revs(struct commit_list **list_p,
240 parents = parents->next;
241 if ((this_flag & flags) == flags)
242 continue;
243 - parse_commit(p);
243 + repo_parse_commit(the_repository, p);
244 if (mark_seen(p, seen_p) && !still_interesting)
245 extra--;
246 p->object.flags |= flags;
@@ -842,7 +842,7 @@ int cmd_show_branch(int ac, const char **av, const char *prefix)
842 if (!commit)
843 die(_("cannot find commit %s (%s)"),
844 ref_name[num_rev], oid_to_hex(&revkey));
845 - parse_commit(commit);
845 + repo_parse_commit(the_repository, commit);
846 mark_seen(commit, &seen);
847
848 /* rev#0 uses bit REV_SHIFT, rev#1 uses bit REV_SHIFT+1,
commit-graph.c
+1 -1
@@ -2549,7 +2549,7 @@ int verify_commit_graph(struct repository *r, struct commit_graph *g, int flags)
2549
2550 graph_commit = lookup_commit(r, &cur_oid);
2551 odb_commit = (struct commit *)create_object(r, &cur_oid, alloc_commit_node(r));
2552 - if (parse_commit_internal(odb_commit, 0, 0)) {
2552 + if (repo_parse_commit_internal(the_repository, odb_commit, 0, 0)) {
2553 graph_report(_("failed to parse commit %s from object database for commit-graph"),
2554 oid_to_hex(&cur_oid));
2555 continue;
commit-reach.c
+8 -8
@@ -585,7 +585,7 @@ int ref_newer(const struct object_id *new_oid, const struct object_id *old_oid)
585 return 0;
586 new_commit = (struct commit *) o;
587
588 - if (parse_commit(new_commit) < 0)
588 + if (repo_parse_commit(the_repository, new_commit) < 0)
589 return 0;
590
591 commit_list_insert(old_commit, &old_commit_list);
@@ -749,7 +749,7 @@ int can_all_from_reach_with_flag(struct object_array *from,
749 }
750
751 list[nr_commits] = (struct commit *)from_one;
752 - if (parse_commit(list[nr_commits]) ||
752 + if (repo_parse_commit(the_repository, list[nr_commits]) ||
753 commit_graph_generation(list[nr_commits]) < min_generation) {
754 result = 0;
755 goto cleanup;
@@ -784,7 +784,7 @@ int can_all_from_reach_with_flag(struct object_array *from,
784 if (!(parent->item->object.flags & assign_flag)) {
785 parent->item->object.flags |= assign_flag;
786
787 - if (parse_commit(parent->item) ||
787 + if (repo_parse_commit(the_repository, parent->item) ||
788 parent->item->date < min_commit_date ||
789 commit_graph_generation(parent->item) < min_generation)
790 continue;
@@ -826,7 +826,7 @@ int can_all_from_reach(struct commit_list *from, struct commit_list *to,
826 while (from_iter) {
827 add_object_array(&from_iter->item->object, NULL, &from_objs);
828
829 - if (!parse_commit(from_iter->item)) {
829 + if (!repo_parse_commit(the_repository, from_iter->item)) {
830 timestamp_t generation;
831 if (from_iter->item->date < min_commit_date)
832 min_commit_date = from_iter->item->date;
@@ -840,7 +840,7 @@ int can_all_from_reach(struct commit_list *from, struct commit_list *to,
840 }
841
842 while (to_iter) {
843 - if (!parse_commit(to_iter->item)) {
843 + if (!repo_parse_commit(the_repository, to_iter->item)) {
844 timestamp_t generation;
845 if (to_iter->item->date < min_commit_date)
846 min_commit_date = to_iter->item->date;
@@ -890,7 +890,7 @@ struct commit_list *get_reachable_subset(struct commit **from, int nr_from,
890 timestamp_t generation;
891 struct commit *c = *item;
892
893 - parse_commit(c);
893 + repo_parse_commit(the_repository, c);
894 generation = commit_graph_generation(c);
895 if (generation < min_generation)
896 min_generation = generation;
@@ -905,7 +905,7 @@ struct commit_list *get_reachable_subset(struct commit **from, int nr_from,
905 struct commit *c = *item;
906 if (!(c->object.flags & PARENT2)) {
907 c->object.flags |= PARENT2;
908 - parse_commit(c);
908 + repo_parse_commit(the_repository, c);
909
910 prio_queue_put(&queue, *item);
911 }
@@ -924,7 +924,7 @@ struct commit_list *get_reachable_subset(struct commit **from, int nr_from,
924 for (parents = current->parents; parents; parents = parents->next) {
925 struct commit *p = parents->item;
926
927 - parse_commit(p);
927 + repo_parse_commit(the_repository, p);
928
929 if (commit_graph_generation(p) < min_generation)
930 continue;
commit.c
+14 -11
@@ -83,7 +83,7 @@ struct commit *lookup_commit_reference_by_name(const char *name)
83 if (repo_get_oid_committish(the_repository, name, &oid))
84 return NULL;
85 commit = lookup_commit_reference(the_repository, &oid);
86 - if (parse_commit(commit))
86 + if (repo_parse_commit(the_repository, commit))
87 return NULL;
88 return commit;
89 }
@@ -382,7 +382,7 @@ struct tree *repo_get_commit_tree(struct repository *r,
382
383 struct object_id *get_commit_tree_oid(const struct commit *commit)
384 {
385 - struct tree *tree = get_commit_tree(commit);
385 + struct tree *tree = repo_get_commit_tree(the_repository, commit);
386 return tree ? &tree->object.oid : NULL;
387 }
388
@@ -555,7 +555,7 @@ int repo_parse_commit_gently(struct repository *r,
555
556 void parse_commit_or_die(struct commit *item)
557 {
558 - if (parse_commit(item))
558 + if (repo_parse_commit(the_repository, item))
559 die("unable to parse commit %s",
560 item ? oid_to_hex(&item->object.oid) : "(null)");
561 }
@@ -688,7 +688,7 @@ struct commit *pop_most_recent_commit(struct commit_list **list,
688
689 while (parents) {
690 struct commit *commit = parents->item;
691 - if (!parse_commit(commit) && !(commit->object.flags & mark)) {
691 + if (!repo_parse_commit(the_repository, commit) && !(commit->object.flags & mark)) {
692 commit->object.flags |= mark;
693 commit_list_insert_by_date(commit, list);
694 }
@@ -762,7 +762,8 @@ define_commit_slab(author_date_slab, timestamp_t);
762 void record_author_date(struct author_date_slab *author_date,
763 struct commit *commit)
764 {
765 - const char *buffer = get_commit_buffer(commit, NULL);
765 + const char *buffer = repo_get_commit_buffer(the_repository, commit,
766 + NULL);
767 struct ident_split ident;
768 const char *ident_line;
769 size_t ident_len;
@@ -782,7 +783,7 @@ void record_author_date(struct author_date_slab *author_date,
783 *(author_date_slab_at(author_date, commit)) = date;
784
785 fail_exit:
785 - unuse_commit_buffer(commit, buffer);
786 + repo_unuse_commit_buffer(the_repository, commit, buffer);
787 }
788
789 int compare_commits_by_author_date(const void *a_, const void *b_,
@@ -963,7 +964,7 @@ static void add_one_commit(struct object_id *oid, struct rev_collect *revs)
964 commit = lookup_commit(the_repository, oid);
965 if (!commit ||
966 (commit->object.flags & TMP_MARK) ||
966 - parse_commit(commit))
967 + repo_parse_commit(the_repository, commit))
968 return;
969
970 ALLOC_GROW(revs->commit, revs->nr + 1, revs->alloc);
@@ -1096,10 +1097,11 @@ int parse_signed_commit(const struct commit *commit,
1097 const struct git_hash_algo *algop)
1098 {
1099 unsigned long size;
1099 - const char *buffer = get_commit_buffer(commit, &size);
1100 + const char *buffer = repo_get_commit_buffer(the_repository, commit,
1101 + &size);
1102 int ret = parse_buffer_signed_by_header(buffer, size, payload, signature, algop);
1103
1102 - unuse_commit_buffer(commit, buffer);
1104 + repo_unuse_commit_buffer(the_repository, commit, buffer);
1105 return ret;
1106 }
1107
@@ -1318,9 +1320,10 @@ struct commit_extra_header *read_commit_extra_headers(struct commit *commit,
1320 {
1321 struct commit_extra_header *extra = NULL;
1322 unsigned long size;
1321 - const char *buffer = get_commit_buffer(commit, &size);
1323 + const char *buffer = repo_get_commit_buffer(the_repository, commit,
1324 + &size);
1325 extra = read_commit_extra_header_lines(buffer, size, exclude);
1323 - unuse_commit_buffer(commit, buffer);
1326 + repo_unuse_commit_buffer(the_repository, commit, buffer);
1327 return extra;
1328 }
1329
commit.h
-18
@@ -109,11 +109,6 @@ static inline int repo_parse_commit_no_graph(struct repository *r,
109 return repo_parse_commit_internal(r, commit, 0, 0);
110 }
111
112 -#ifndef NO_THE_REPOSITORY_COMPATIBILITY_MACROS
113 -#define parse_commit_internal(item, quiet, use) repo_parse_commit_internal(the_repository, item, quiet, use)
114 -#define parse_commit(item) repo_parse_commit(the_repository, item)
115 -#endif
116 -
112 void parse_commit_or_die(struct commit *item);
113
114 struct buffer_slab;
@@ -140,9 +135,6 @@ const void *get_cached_commit_buffer(struct repository *, const struct commit *,
135 const void *repo_get_commit_buffer(struct repository *r,
136 const struct commit *,
137 unsigned long *size);
143 -#ifndef NO_THE_REPOSITORY_COMPATIBILITY_MACROS
144 -#define get_commit_buffer(c, s) repo_get_commit_buffer(the_repository, c, s)
145 -#endif
138
139 /*
140 * Tell the commit subsystem that we are done with a particular commit buffer.
@@ -153,9 +145,6 @@ const void *repo_get_commit_buffer(struct repository *r,
145 void repo_unuse_commit_buffer(struct repository *r,
146 const struct commit *,
147 const void *buffer);
156 -#ifndef NO_THE_REPOSITORY_COMPATIBILITY_MACROS
157 -#define unuse_commit_buffer(c, b) repo_unuse_commit_buffer(the_repository, c, b)
158 -#endif
148
149 /*
150 * Free any cached object buffer associated with the commit.
@@ -163,7 +152,6 @@ void repo_unuse_commit_buffer(struct repository *r,
152 void free_commit_buffer(struct parsed_object_pool *pool, struct commit *);
153
154 struct tree *repo_get_commit_tree(struct repository *, const struct commit *);
166 -#define get_commit_tree(c) repo_get_commit_tree(the_repository, c)
155 struct object_id *get_commit_tree_oid(const struct commit *);
156
157 /*
@@ -206,16 +194,10 @@ void free_commit_list(struct commit_list *list);
194 struct rev_info; /* in revision.h, it circularly uses enum cmit_fmt */
195
196 int has_non_ascii(const char *text);
209 -const char *logmsg_reencode(const struct commit *commit,
210 - char **commit_encoding,
211 - const char *output_encoding);
197 const char *repo_logmsg_reencode(struct repository *r,
198 const struct commit *commit,
199 char **commit_encoding,
200 const char *output_encoding);
216 -#ifndef NO_THE_REPOSITORY_COMPATIBILITY_MACROS
217 -#define logmsg_reencode(c, enc, out) repo_logmsg_reencode(the_repository, c, enc, out)
218 -#endif
201
202 const char *skip_blank_lines(const char *msg);
203
contrib/coccinelle/the_repository.cocci
+19
@@ -54,6 +54,25 @@
54 |
55 - in_merge_bases_many
56 + repo_in_merge_bases_many
57 +// commit.h
58 +|
59 +- parse_commit_internal
60 ++ repo_parse_commit_internal
61 +|
62 +- parse_commit
63 ++ repo_parse_commit
64 +|
65 +- get_commit_buffer
66 ++ repo_get_commit_buffer
67 +|
68 +- unuse_commit_buffer
69 ++ repo_unuse_commit_buffer
70 +|
71 +- logmsg_reencode
72 ++ repo_logmsg_reencode
73 +|
74 +- get_commit_tree
75 ++ repo_get_commit_tree
76 )
77 (
78 + the_repository,
contrib/coccinelle/the_repository.pending.cocci
-19
@@ -5,26 +5,7 @@
5 @@
6 @@
7 (
8 -// commit.h
9 -- parse_commit_internal
10 -+ repo_parse_commit_internal
11 -|
12 -- parse_commit
13 -+ repo_parse_commit
14 -|
15 -- get_commit_buffer
16 -+ repo_get_commit_buffer
17 -|
18 -- unuse_commit_buffer
19 -+ repo_unuse_commit_buffer
20 -|
21 -- logmsg_reencode
22 -+ repo_logmsg_reencode
23 -|
24 -- get_commit_tree
25 -+ repo_get_commit_tree
8 // diff.h
27 -|
9 - diff_setup
10 + repo_diff_setup
11 // object-store.h
delta-islands.c
+3 -2
@@ -506,8 +506,9 @@ void propagate_island_marks(struct commit *commit)
506 struct commit_list *p;
507 struct island_bitmap *root_marks = kh_value(island_marks, pos);
508
509 - parse_commit(commit);
510 - set_island_marks(&get_commit_tree(commit)->object, root_marks);
509 + repo_parse_commit(the_repository, commit);
510 + set_island_marks(&repo_get_commit_tree(the_repository, commit)->object,
511 + root_marks);
512 for (p = commit->parents; p; p = p->next)
513 set_island_marks(&p->item->object, root_marks);
514 }
fmt-merge-msg.c
+3 -2
@@ -271,9 +271,10 @@ static void record_person_from_buf(int which, struct string_list *people,
271 static void record_person(int which, struct string_list *people,
272 struct commit *commit)
273 {
274 - const char *buffer = get_commit_buffer(commit, NULL);
274 + const char *buffer = repo_get_commit_buffer(the_repository, commit,
275 + NULL);
276 record_person_from_buf(which, people, buffer);
276 - unuse_commit_buffer(commit, buffer);
277 + repo_unuse_commit_buffer(the_repository, commit, buffer);
278 }
279
280 static int cmp_string_list_util_as_integral(const void *a_, const void *b_)
fsck.c
+2 -2
@@ -353,7 +353,7 @@ static int fsck_walk_commit(struct commit *commit, void *data, struct fsck_optio
353 int result;
354 const char *name;
355
356 - if (parse_commit(commit))
356 + if (repo_parse_commit(the_repository, commit))
357 return -1;
358
359 name = fsck_get_object_name(options, &commit->object.oid);
@@ -361,7 +361,7 @@ static int fsck_walk_commit(struct commit *commit, void *data, struct fsck_optio
361 fsck_put_object_name(options, get_commit_tree_oid(commit),
362 "%s:", name);
363
364 - result = options->walk((struct object *)get_commit_tree(commit),
364 + result = options->walk((struct object *) repo_get_commit_tree(the_repository, commit),
365 OBJ_TREE, data, options);
366 if (result < 0)
367 return result;
http-push.c
+2 -1
@@ -1331,7 +1331,8 @@ static int get_delta(struct rev_info *revs, struct remote_lock *lock)
1331 int count = 0;
1332
1333 while ((commit = get_revision(revs)) != NULL) {
1334 - p = process_tree(get_commit_tree(commit), p);
1334 + p = process_tree(repo_get_commit_tree(the_repository, commit),
1335 + p);
1336 commit->object.flags |= LOCAL;
1337 if (!(commit->object.flags & UNINTERESTING))
1338 count += add_send_request(&commit->object, lock);
list-objects.c
+11 -7
@@ -227,7 +227,8 @@ static void mark_edge_parents_uninteresting(struct commit *commit,
227 struct commit *parent = parents->item;
228 if (!(parent->object.flags & UNINTERESTING))
229 continue;
230 - mark_tree_uninteresting(revs->repo, get_commit_tree(parent));
230 + mark_tree_uninteresting(revs->repo,
231 + repo_get_commit_tree(the_repository, parent));
232 if (revs->edge_hint && !(parent->object.flags & SHOWN)) {
233 parent->object.flags |= SHOWN;
234 show_edge(parent);
@@ -244,7 +245,8 @@ static void add_edge_parents(struct commit *commit,
245
246 for (parents = commit->parents; parents; parents = parents->next) {
247 struct commit *parent = parents->item;
247 - struct tree *tree = get_commit_tree(parent);
248 + struct tree *tree = repo_get_commit_tree(the_repository,
249 + parent);
250
251 if (!tree)
252 continue;
@@ -275,7 +277,8 @@ void mark_edges_uninteresting(struct rev_info *revs,
277
278 for (list = revs->commits; list; list = list->next) {
279 struct commit *commit = list->item;
278 - struct tree *tree = get_commit_tree(commit);
280 + struct tree *tree = repo_get_commit_tree(the_repository,
281 + commit);
282
283 if (commit->object.flags & UNINTERESTING)
284 tree->object.flags |= UNINTERESTING;
@@ -291,7 +294,7 @@ void mark_edges_uninteresting(struct rev_info *revs,
294 struct commit *commit = list->item;
295 if (commit->object.flags & UNINTERESTING) {
296 mark_tree_uninteresting(revs->repo,
294 - get_commit_tree(commit));
297 + repo_get_commit_tree(the_repository, commit));
298 if (revs->edge_hint_aggressive && !(commit->object.flags & SHOWN)) {
299 commit->object.flags |= SHOWN;
300 show_edge(commit);
@@ -309,7 +312,7 @@ void mark_edges_uninteresting(struct rev_info *revs,
312 if (obj->type != OBJ_COMMIT || !(obj->flags & UNINTERESTING))
313 continue;
314 mark_tree_uninteresting(revs->repo,
312 - get_commit_tree(commit));
315 + repo_get_commit_tree(the_repository, commit));
316 if (!(obj->flags & SHOWN)) {
317 obj->flags |= SHOWN;
318 show_edge(commit);
@@ -376,8 +379,9 @@ static void do_traverse(struct traversal_context *ctx)
379 */
380 if (!ctx->revs->tree_objects)
381 ; /* do not bother loading tree */
379 - else if (get_commit_tree(commit)) {
380 - struct tree *tree = get_commit_tree(commit);
382 + else if (repo_get_commit_tree(the_repository, commit)) {
383 + struct tree *tree = repo_get_commit_tree(the_repository,
384 + commit);
385 tree->object.flags |= NOT_USER_GIVEN;
386 add_pending_tree(ctx->revs, tree);
387 } else if (commit->object.parsed) {
merge-recursive.c
+1 -1
@@ -3797,7 +3797,7 @@ static struct commit *get_ref(struct repository *repo,
3797 return make_virtual_commit(repo, (struct tree*)object, name);
3798 if (object->type != OBJ_COMMIT)
3799 return NULL;
3800 - if (parse_commit((struct commit *)object))
3800 + if (repo_parse_commit(the_repository, (struct commit *)object))
3801 return NULL;
3802 return (struct commit *)object;
3803 }
negotiator/default.c
+3 -3
@@ -25,7 +25,7 @@ static void rev_list_push(struct negotiation_state *ns,
25 if (!(commit->object.flags & mark)) {
26 commit->object.flags |= mark;
27
28 - if (parse_commit(commit))
28 + if (repo_parse_commit(the_repository, commit))
29 return;
30
31 prio_queue_put(&ns->rev_list, commit);
@@ -69,7 +69,7 @@ static void mark_common(struct negotiation_state *ns, struct commit *commit,
69 if (!ancestors_only && !(o->flags & POPPED))
70 ns->non_common_revs--;
71 if (!o->parsed && !dont_parse)
72 - if (parse_commit(commit))
72 + if (repo_parse_commit(the_repository, commit))
73 return;
74
75 for (parents = commit->parents;
@@ -96,7 +96,7 @@ static const struct object_id *get_rev(struct negotiation_state *ns)
96 return NULL;
97
98 commit = prio_queue_get(&ns->rev_list);
99 - parse_commit(commit);
99 + repo_parse_commit(the_repository, commit);
100 parents = commit->parents;
101
102 commit->object.flags |= POPPED;
negotiator/skipping.c
+1 -1
@@ -183,7 +183,7 @@ static const struct object_id *get_rev(struct data *data)
183 if (!(commit->object.flags & COMMON) && !entry->ttl)
184 to_send = commit;
185
186 - parse_commit(commit);
186 + repo_parse_commit(the_repository, commit);
187 for (p = commit->parents; p; p = p->next)
188 parent_pushed |= push_parent(data, entry, p->item);
189
notes-merge.c
+3 -2
@@ -678,7 +678,8 @@ int notes_merge_commit(struct notes_merge_options *o,
678 DIR *dir;
679 struct dirent *e;
680 struct strbuf path = STRBUF_INIT;
681 - const char *buffer = get_commit_buffer(partial_commit, NULL);
681 + const char *buffer = repo_get_commit_buffer(the_repository,
682 + partial_commit, NULL);
683 const char *msg = strstr(buffer, "\n\n");
684 int baselen;
685
@@ -725,7 +726,7 @@ int notes_merge_commit(struct notes_merge_options *o,
726
727 create_notes_commit(o->repo, partial_tree, partial_commit->parents, msg,
728 strlen(msg), result_oid);
728 - unuse_commit_buffer(partial_commit, buffer);
729 + repo_unuse_commit_buffer(the_repository, partial_commit, buffer);
730 if (o->verbosity >= 4)
731 printf("Finalized notes merge commit: %s\n",
732 oid_to_hex(result_oid));
notes-utils.c
+1 -1
@@ -23,7 +23,7 @@ void create_notes_commit(struct repository *r,
23 struct object_id parent_oid;
24 if (!read_ref(t->ref, &parent_oid)) {
25 struct commit *parent = lookup_commit(r, &parent_oid);
26 - if (parse_commit(parent))
26 + if (repo_parse_commit(the_repository, parent))
27 die("Failed to find/parse commit %s", t->ref);
28 commit_list_insert(parent, &parents);
29 }
object-name.c
+4 -4
@@ -1036,7 +1036,7 @@ static enum get_oid_result get_parent(struct repository *r,
1036 if (ret)
1037 return ret;
1038 commit = lookup_commit_reference(r, &oid);
1039 - if (parse_commit(commit))
1039 + if (repo_parse_commit(the_repository, commit))
1040 return MISSING_OBJECT;
1041 if (!idx) {
1042 oidcpy(result, &commit->object.oid);
@@ -1070,7 +1070,7 @@ static enum get_oid_result get_nth_ancestor(struct repository *r,
1070 return MISSING_OBJECT;
1071
1072 while (generation--) {
1073 - if (parse_commit(commit) || !commit->parents)
1073 + if (repo_parse_commit(the_repository, commit) || !commit->parents)
1074 return MISSING_OBJECT;
1075 commit = commit->parents->item;
1076 }
@@ -1361,10 +1361,10 @@ static int get_oid_oneline(struct repository *r,
1361 commit = pop_most_recent_commit(&list, ONELINE_SEEN);
1362 if (!parse_object(r, &commit->object.oid))
1363 continue;
1364 - buf = get_commit_buffer(commit, NULL);
1364 + buf = repo_get_commit_buffer(the_repository, commit, NULL);
1365 p = strstr(buf, "\n\n");
1366 matches = negative ^ (p && !regexec(&regex, p + 2, 0, NULL, 0));
1367 - unuse_commit_buffer(commit, buf);
1367 + repo_unuse_commit_buffer(the_repository, commit, buf);
1368
1369 if (matches) {
1370 oidcpy(oid, &commit->object.oid);
pack-bitmap-write.c
+2 -1
@@ -425,7 +425,8 @@ static int fill_bitmap_commit(struct bb_commit *ent,
425 if (!found)
426 return -1;
427 bitmap_set(ent->bitmap, pos);
428 - prio_queue_put(tree_queue, get_commit_tree(c));
428 + prio_queue_put(tree_queue,
429 + repo_get_commit_tree(the_repository, c));
430
431 for (p = c->parents; p; p = p->next) {
432 pos = find_object_pos(&p->item->object.oid, &found);
pretty.c
+3 -2
@@ -2204,7 +2204,8 @@ void pretty_print_commit(struct pretty_print_context *pp,
2204 }
2205
2206 encoding = get_log_output_encoding();
2207 - msg = reencoded = logmsg_reencode(commit, NULL, encoding);
2207 + msg = reencoded = repo_logmsg_reencode(the_repository, commit, NULL,
2208 + encoding);
2209
2210 if (pp->fmt == CMIT_FMT_ONELINE || cmit_fmt_is_mail(pp->fmt))
2211 indent = 0;
@@ -2261,7 +2262,7 @@ void pretty_print_commit(struct pretty_print_context *pp,
2262 if (cmit_fmt_is_mail(pp->fmt) && sb->len <= beginning_of_body)
2263 strbuf_addch(sb, '\n');
2264
2264 - unuse_commit_buffer(commit, reencoded);
2265 + repo_unuse_commit_buffer(the_repository, commit, reencoded);
2266 }
2267
2268 void pp_commit_easy(enum cmit_fmt fmt, const struct commit *commit,
reflog.c
+1 -1
@@ -186,7 +186,7 @@ static void mark_reachable(struct expire_reflog_policy_cb *cb)
186 struct commit *commit = pop_commit(&pending);
187 if (commit->object.flags & REACHABLE)
188 continue;
189 - if (parse_commit(commit))
189 + if (repo_parse_commit(the_repository, commit))
190 continue;
191 commit->object.flags |= REACHABLE;
192 if (commit->date < expire_limit) {
revision.c
+6 -6
@@ -778,8 +778,8 @@ static int check_maybe_different_in_bloom_filter(struct rev_info *revs,
778 static int rev_compare_tree(struct rev_info *revs,
779 struct commit *parent, struct commit *commit, int nth_parent)
780 {
781 - struct tree *t1 = get_commit_tree(parent);
782 - struct tree *t2 = get_commit_tree(commit);
781 + struct tree *t1 = repo_get_commit_tree(the_repository, parent);
782 + struct tree *t2 = repo_get_commit_tree(the_repository, commit);
783 int bloom_ret = 1;
784
785 if (!t1)
@@ -825,7 +825,7 @@ static int rev_compare_tree(struct rev_info *revs,
825
826 static int rev_same_tree_as_empty(struct rev_info *revs, struct commit *commit)
827 {
828 - struct tree *t1 = get_commit_tree(commit);
828 + struct tree *t1 = repo_get_commit_tree(the_repository, commit);
829
830 if (!t1)
831 return 0;
@@ -963,7 +963,7 @@ static void try_to_simplify_commit(struct rev_info *revs, struct commit *commit)
963 if (!revs->prune)
964 return;
965
966 - if (!get_commit_tree(commit))
966 + if (!repo_get_commit_tree(the_repository, commit))
967 return;
968
969 if (!commit->parents) {
@@ -3878,7 +3878,7 @@ static int commit_match(struct commit *commit, struct rev_info *opt)
3878 * in it.
3879 */
3880 encoding = get_log_output_encoding();
3881 - message = logmsg_reencode(commit, NULL, encoding);
3881 + message = repo_logmsg_reencode(the_repository, commit, NULL, encoding);
3882
3883 /* Copy the commit to temporary if we are using "fake" headers */
3884 if (buf.len)
@@ -3914,7 +3914,7 @@ static int commit_match(struct commit *commit, struct rev_info *opt)
3914 retval = grep_buffer(&opt->grep_filter,
3915 (char *)message, strlen(message));
3916 strbuf_release(&buf);
3917 - unuse_commit_buffer(commit, message);
3917 + repo_unuse_commit_buffer(the_repository, commit, message);
3918 return retval;
3919 }
3920
sequencer.c
+50 -32
@@ -428,7 +428,8 @@ static int get_message(struct commit *commit, struct commit_message *out)
428 const char *abbrev, *subject;
429 int subject_len;
430
431 - out->message = logmsg_reencode(commit, NULL, get_commit_output_encoding());
431 + out->message = repo_logmsg_reencode(the_repository, commit, NULL,
432 + get_commit_output_encoding());
433 abbrev = short_commit_name(commit);
434
435 subject_len = find_commit_subject(out->message, &subject);
@@ -445,7 +446,7 @@ static void free_message(struct commit *commit, struct commit_message *msg)
446 free(msg->parent_label);
447 free(msg->label);
448 free(msg->subject);
448 - unuse_commit_buffer(commit, msg->message);
449 + repo_unuse_commit_buffer(the_repository, commit, msg->message);
450 }
451
452 static void print_advice(struct repository *r, int show_hint,
@@ -693,8 +694,8 @@ static int do_recursive_merge(struct repository *r,
694 o.show_rename_progress = 1;
695
696 head_tree = parse_tree_indirect(head);
696 - next_tree = next ? get_commit_tree(next) : empty_tree(r);
697 - base_tree = base ? get_commit_tree(base) : empty_tree(r);
697 + next_tree = next ? repo_get_commit_tree(the_repository, next) : empty_tree(r);
698 + base_tree = base ? repo_get_commit_tree(the_repository, base) : empty_tree(r);
699
700 for (i = 0; i < opts->xopts_nr; i++)
701 parse_merge_opt(&o, opts->xopts[i]);
@@ -772,7 +773,7 @@ static int is_index_unchanged(struct repository *r)
773 * the commit is invalid, parse_commit() will complain. So
774 * there is nothing for us to say here. Just return failure.
775 */
775 - if (parse_commit(head_commit))
776 + if (repo_parse_commit(the_repository, head_commit))
777 return -1;
778
779 if (!(cache_tree_oid = get_cache_tree_oid(istate)))
@@ -1337,7 +1338,7 @@ void print_commit_summary(struct repository *r,
1338 commit = lookup_commit(r, oid);
1339 if (!commit)
1340 die(_("couldn't look up newly created commit"));
1340 - if (parse_commit(commit))
1341 + if (repo_parse_commit(the_repository, commit))
1342 die(_("could not parse newly created commit"));
1343
1344 strbuf_addstr(&format, "format:%h] %s");
@@ -1417,7 +1418,7 @@ static int parse_head(struct repository *r, struct commit **head)
1418 warning(_("HEAD %s is not a commit!"),
1419 oid_to_hex(&oid));
1420 }
1420 - if (parse_commit(current_head))
1421 + if (repo_parse_commit(the_repository, current_head))
1422 return error(_("could not parse HEAD commit"));
1423 }
1424 *head = current_head;
@@ -1460,8 +1461,9 @@ static int try_to_commit(struct repository *r,
1461 if (flags & AMEND_MSG) {
1462 const char *exclude_gpgsig[] = { "gpgsig", "gpgsig-sha256", NULL };
1463 const char *out_enc = get_commit_output_encoding();
1463 - const char *message = logmsg_reencode(current_head, NULL,
1464 - out_enc);
1464 + const char *message = repo_logmsg_reencode(the_repository,
1465 + current_head, NULL,
1466 + out_enc);
1467
1468 if (!msg) {
1469 const char *orig_message = NULL;
@@ -1472,7 +1474,8 @@ static int try_to_commit(struct repository *r,
1474 hook_commit = "HEAD";
1475 }
1476 author = amend_author = get_author(message);
1475 - unuse_commit_buffer(current_head, message);
1477 + repo_unuse_commit_buffer(the_repository, current_head,
1478 + message);
1479 if (!author) {
1480 res = error(_("unable to parse commit author"));
1481 goto out;
@@ -1669,12 +1672,12 @@ static int is_original_commit_empty(struct commit *commit)
1672 {
1673 const struct object_id *ptree_oid;
1674
1672 - if (parse_commit(commit))
1675 + if (repo_parse_commit(the_repository, commit))
1676 return error(_("could not parse commit %s"),
1677 oid_to_hex(&commit->object.oid));
1678 if (commit->parents) {
1679 struct commit *parent = commit->parents->item;
1677 - if (parse_commit(parent))
1680 + if (repo_parse_commit(the_repository, parent))
1681 return error(_("could not parse parent commit %s"),
1682 oid_to_hex(&parent->object.oid));
1683 ptree_oid = get_commit_tree_oid(parent);
@@ -2002,13 +2005,14 @@ static int update_squash_messages(struct repository *r,
2005 return error(_("need a HEAD to fixup"));
2006 if (!(head_commit = lookup_commit_reference(r, &head)))
2007 return error(_("could not read HEAD"));
2005 - if (!(head_message = logmsg_reencode(head_commit, NULL, encoding)))
2008 + if (!(head_message = repo_logmsg_reencode(the_repository, head_commit, NULL, encoding)))
2009 return error(_("could not read HEAD's commit message"));
2010
2011 find_commit_subject(head_message, &body);
2012 if (command == TODO_FIXUP && !flag && write_message(body, strlen(body),
2013 rebase_path_fixup_msg(), 0) < 0) {
2011 - unuse_commit_buffer(head_commit, head_message);
2014 + repo_unuse_commit_buffer(the_repository, head_commit,
2015 + head_message);
2016 return error(_("cannot write '%s'"), rebase_path_fixup_msg());
2017 }
2018 strbuf_addf(&buf, "%c ", comment_line_char);
@@ -2023,10 +2027,11 @@ static int update_squash_messages(struct repository *r,
2027 else
2028 strbuf_addstr(&buf, body);
2029
2026 - unuse_commit_buffer(head_commit, head_message);
2030 + repo_unuse_commit_buffer(the_repository, head_commit,
2031 + head_message);
2032 }
2033
2029 - if (!(message = logmsg_reencode(commit, NULL, encoding)))
2034 + if (!(message = repo_logmsg_reencode(the_repository, commit, NULL, encoding)))
2035 return error(_("could not read commit message of %s"),
2036 oid_to_hex(&commit->object.oid));
2037 find_commit_subject(message, &body);
@@ -2041,7 +2046,7 @@ static int update_squash_messages(struct repository *r,
2046 strbuf_add_commented_lines(&buf, body, strlen(body));
2047 } else
2048 return error(_("unknown command: %d"), command);
2044 - unuse_commit_buffer(commit, message);
2049 + repo_unuse_commit_buffer(the_repository, commit, message);
2050
2051 if (!res)
2052 res = write_message(buf.buf, buf.len, rebase_path_squash_msg(),
@@ -2215,7 +2220,7 @@ static int do_pick_commit(struct repository *r,
2220 msg_file = NULL;
2221 goto fast_forward_edit;
2222 }
2218 - if (parent && parse_commit(parent) < 0)
2223 + if (parent && repo_parse_commit(the_repository, parent) < 0)
2224 /* TRANSLATORS: The first %s will be a "todo" command like
2225 "revert" or "pick", the second %s a SHA1. */
2226 return error(_("%s: cannot parse parent commit %s"),
@@ -3123,7 +3128,9 @@ static int walk_revs_populate_todo(struct todo_list *todo_list,
3128
3129 while ((commit = get_revision(opts->revs))) {
3130 struct todo_item *item = append_new_todo(todo_list);
3126 - const char *commit_buffer = logmsg_reencode(commit, NULL, encoding);
3131 + const char *commit_buffer = repo_logmsg_reencode(the_repository,
3132 + commit, NULL,
3133 + encoding);
3134 const char *subject;
3135 int subject_len;
3136
@@ -3135,7 +3142,8 @@ static int walk_revs_populate_todo(struct todo_list *todo_list,
3142 subject_len = find_commit_subject(commit_buffer, &subject);
3143 strbuf_addf(&todo_list->buf, "%s %s %.*s\n", command_string,
3144 short_commit_name(commit), subject_len, subject);
3138 - unuse_commit_buffer(commit, commit_buffer);
3145 + repo_unuse_commit_buffer(the_repository, commit,
3146 + commit_buffer);
3147 }
3148
3149 if (!todo_list->nr)
@@ -3519,10 +3527,13 @@ static int make_patch(struct repository *r,
3527 strbuf_addf(&buf, "%s/message", get_dir(opts));
3528 if (!file_exists(buf.buf)) {
3529 const char *encoding = get_commit_output_encoding();
3522 - const char *commit_buffer = logmsg_reencode(commit, NULL, encoding);
3530 + const char *commit_buffer = repo_logmsg_reencode(the_repository,
3531 + commit, NULL,
3532 + encoding);
3533 find_commit_subject(commit_buffer, &subject);
3534 res |= write_message(subject, strlen(subject), buf.buf, 1);
3525 - unuse_commit_buffer(commit, commit_buffer);
3535 + repo_unuse_commit_buffer(the_repository, commit,
3536 + commit_buffer);
3537 }
3538 strbuf_release(&buf);
3539 release_revisions(&log_tree_opt);
@@ -3989,7 +4000,9 @@ static int do_merge(struct repository *r,
4000
4001 if (commit) {
4002 const char *encoding = get_commit_output_encoding();
3992 - const char *message = logmsg_reencode(commit, NULL, encoding);
4003 + const char *message = repo_logmsg_reencode(the_repository,
4004 + commit, NULL,
4005 + encoding);
4006 const char *body;
4007 int len;
4008
@@ -4002,7 +4015,7 @@ static int do_merge(struct repository *r,
4015 find_commit_subject(message, &body);
4016 len = strlen(body);
4017 ret = write_message(body, len, git_path_merge_msg(r), 0);
4005 - unuse_commit_buffer(commit, message);
4018 + repo_unuse_commit_buffer(the_repository, commit, message);
4019 if (ret) {
4020 error_errno(_("could not write '%s'"),
4021 git_path_merge_msg(r));
@@ -4585,7 +4598,7 @@ static int stopped_at_head(struct repository *r)
4598
4599 if (repo_get_oid(the_repository, "HEAD", &head) ||
4600 !(commit = lookup_commit(r, &head)) ||
4588 - parse_commit(commit) || get_message(commit, &message))
4601 + repo_parse_commit(the_repository, commit) || get_message(commit, &message))
4602 fprintf(stderr, _("Stopped at HEAD\n"));
4603 else {
4604 fprintf(stderr, _("Stopped at %s\n"), message.label);
@@ -5042,13 +5055,15 @@ static int commit_staged_changes(struct repository *r,
5055 const char *encoding = get_commit_output_encoding();
5056
5057 if (parse_head(r, &commit) ||
5045 - !(p = logmsg_reencode(commit, NULL, encoding)) ||
5058 + !(p = repo_logmsg_reencode(the_repository, commit, NULL, encoding)) ||
5059 write_message(p, strlen(p), path, 0)) {
5047 - unuse_commit_buffer(commit, p);
5060 + repo_unuse_commit_buffer(the_repository,
5061 + commit, p);
5062 return error(_("could not write file: "
5063 "'%s'"), path);
5064 }
5051 - unuse_commit_buffer(commit, p);
5065 + repo_unuse_commit_buffer(the_repository,
5066 + commit, p);
5067 }
5068 }
5069
@@ -5925,7 +5940,7 @@ static int skip_unnecessary_picks(struct repository *r,
5940 continue;
5941 if (item->command != TODO_PICK)
5942 break;
5928 - if (parse_commit(item->commit)) {
5943 + if (repo_parse_commit(the_repository, item->commit)) {
5944 return error(_("could not parse commit '%s'"),
5945 oid_to_hex(&item->commit->object.oid));
5946 }
@@ -6258,12 +6273,15 @@ int todo_list_rearrange_squash(struct todo_list *todo_list)
6273 return error(_("the script was already rearranged."));
6274 }
6275
6261 - parse_commit(item->commit);
6262 - commit_buffer = logmsg_reencode(item->commit, NULL, "UTF-8");
6276 + repo_parse_commit(the_repository, item->commit);
6277 + commit_buffer = repo_logmsg_reencode(the_repository,
6278 + item->commit, NULL,
6279 + "UTF-8");
6280 find_commit_subject(commit_buffer, &subject);
6281 format_subject(&buf, subject, " ");
6282 subject = subjects[i] = strbuf_detach(&buf, &subject_len);
6266 - unuse_commit_buffer(item->commit, commit_buffer);
6283 + repo_unuse_commit_buffer(the_repository, item->commit,
6284 + commit_buffer);
6285 if (skip_fixupish(subject, &p)) {
6286 struct commit *commit2;
6287
shallow.c
+2 -2
@@ -247,7 +247,7 @@ struct commit_list *get_shallow_commits_by_rev_list(int ac, const char **av,
247 struct commit *c = p->item;
248 struct commit_list *parent;
249
250 - if (parse_commit(c))
250 + if (repo_parse_commit(the_repository, c))
251 die("unable to parse commit %s",
252 oid_to_hex(&c->object.oid));
253
@@ -583,7 +583,7 @@ static void paint_down(struct paint_info *info, const struct object_id *oid,
583 if (c->object.flags & BOTTOM)
584 continue;
585
586 - if (parse_commit(c))
586 + if (repo_parse_commit(the_repository, c))
587 die("unable to parse commit %s",
588 oid_to_hex(&c->object.oid));
589
t/helper/test-fast-rebase.c
+5 -4
@@ -65,7 +65,8 @@ static struct commit *create_commit(struct tree *tree,
65 struct commit_extra_header *extra;
66 struct strbuf msg = STRBUF_INIT;
67 const char *out_enc = get_commit_output_encoding();
68 - const char *message = logmsg_reencode(based_on, NULL, out_enc);
68 + const char *message = repo_logmsg_reencode(the_repository, based_on,
69 + NULL, out_enc);
70 const char *orig_message = NULL;
71 const char *exclude_gpgsig[] = { "gpgsig", NULL };
72
@@ -156,7 +157,7 @@ int cmd__fast_rebase(int argc, const char **argv)
157 memset(&result, 0, sizeof(result));
158 merge_opt.show_rename_progress = 1;
159 merge_opt.branch1 = "HEAD";
159 - head_tree = get_commit_tree(onto);
160 + head_tree = repo_get_commit_tree(the_repository, onto);
161 result.tree = head_tree;
162 last_commit = onto;
163 while ((commit = get_revision(&revs))) {
@@ -167,8 +168,8 @@ int cmd__fast_rebase(int argc, const char **argv)
168 assert(commit->parents && !commit->parents->next);
169 base = commit->parents->item;
170
170 - next_tree = get_commit_tree(commit);
171 - base_tree = get_commit_tree(base);
171 + next_tree = repo_get_commit_tree(the_repository, commit);
172 + base_tree = repo_get_commit_tree(the_repository, base);
173
174 merge_opt.branch2 = short_commit_name(commit);
175 merge_opt.ancestor = xstrfmt("parent of %s", merge_opt.branch2);
tree.c
+1 -1
@@ -58,7 +58,7 @@ int read_tree_at(struct repository *r,
58 oid_to_hex(&entry.oid),
59 base->buf, entry.path);
60
61 - if (parse_commit(commit))
61 + if (repo_parse_commit(the_repository, commit))
62 die("Invalid commit %s in submodule path %s%s",
63 oid_to_hex(&entry.oid),
64 base->buf, entry.path);
walker.c
+2 -2
@@ -79,7 +79,7 @@ static int process_commit(struct walker *walker, struct commit *commit)
79 {
80 struct commit_list *parents;
81
82 - if (parse_commit(commit))
82 + if (repo_parse_commit(the_repository, commit))
83 return -1;
84
85 while (complete && complete->item->date >= commit->date) {
@@ -93,7 +93,7 @@ static int process_commit(struct walker *walker, struct commit *commit)
93
94 walker_say(walker, "walk %s\n", oid_to_hex(&commit->object.oid));
95
96 - if (process(walker, &get_commit_tree(commit)->object))
96 + if (process(walker, &repo_get_commit_tree(the_repository, commit)->object))
97 return -1;
98
99 for (parents = commit->parents; parents; parents = parents->next) {