From d850b7a545fcfbd97460a921c7f7c59d933eb0f7 Mon Sep 17 00:00:00 2001 From: Ævar Arnfjörð Bjarmason Date: Tue, 28 Mar 2023 15:58:46 +0200 Subject: cocci: apply the "cache.h" part of "the_repository.pending" MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Apply the part of "the_repository.pending.cocci" pertaining to "cache.h". Signed-off-by: Ævar Arnfjörð Bjarmason Signed-off-by: Junio C Hamano --- commit.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'commit.c') diff --git a/commit.c b/commit.c index e433c33bb0..06a7c728e8 100644 --- a/commit.c +++ b/commit.c @@ -80,7 +80,7 @@ struct commit *lookup_commit_reference_by_name(const char *name) struct object_id oid; struct commit *commit; - if (get_oid_committish(name, &oid)) + if (repo_get_oid_committish(the_repository, name, &oid)) return NULL; commit = lookup_commit_reference(the_repository, &oid); if (parse_commit(commit)) @@ -1271,7 +1271,8 @@ void verify_merge_signature(struct commit *commit, int verbosity, ret = check_commit_signature(commit, &signature_check); - find_unique_abbrev_r(hex, &commit->object.oid, DEFAULT_ABBREV); + repo_find_unique_abbrev_r(the_repository, hex, &commit->object.oid, + DEFAULT_ABBREV); switch (signature_check.result) { case 'G': if (ret || (check_trust && signature_check.trust_level < TRUST_MARGINAL)) @@ -1632,10 +1633,11 @@ struct commit *get_merge_parent(const char *name) struct object *obj; struct commit *commit; struct object_id oid; - if (get_oid(name, &oid)) + if (repo_get_oid(the_repository, name, &oid)) return NULL; obj = parse_object(the_repository, &oid); - commit = (struct commit *)peel_to_type(name, 0, obj, OBJ_COMMIT); + commit = (struct commit *)repo_peel_to_type(the_repository, name, 0, + obj, OBJ_COMMIT); if (commit && !merge_remote_util(commit)) set_merge_remote_desc(commit, name, obj); return commit; -- cgit v1.2.3 From cb338c23d6d518947bf6f7240bf30e2ec232bd3b Mon Sep 17 00:00:00 2001 From: Ævar Arnfjörð Bjarmason Date: Tue, 28 Mar 2023 15:58:47 +0200 Subject: cocci: apply the "commit-reach.h" part of "the_repository.pending" MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Apply the part of "the_repository.pending.cocci" pertaining to "commit-reach.h". Signed-off-by: Ævar Arnfjörð Bjarmason Signed-off-by: Junio C Hamano --- bisect.c | 3 ++- builtin/branch.c | 5 +++-- builtin/fast-import.c | 2 +- builtin/fetch.c | 3 ++- builtin/log.c | 10 +++++++--- builtin/merge-base.c | 5 +++-- builtin/merge-tree.c | 3 ++- builtin/merge.c | 7 +++++-- builtin/rebase.c | 5 +++-- builtin/receive-pack.c | 2 +- builtin/rev-parse.c | 2 +- commit-reach.c | 3 ++- commit-reach.h | 9 --------- commit.c | 3 ++- contrib/coccinelle/the_repository.cocci | 16 ++++++++++++++++ contrib/coccinelle/the_repository.pending.cocci | 16 ---------------- http-push.c | 2 +- log-tree.c | 2 +- merge-ort.c | 2 +- merge-recursive.c | 2 +- notes-merge.c | 2 +- remote.c | 2 +- revision.c | 4 ++-- sequencer.c | 3 ++- shallow.c | 9 +++++---- t/helper/test-reach.c | 10 +++++++--- 26 files changed, 72 insertions(+), 60 deletions(-) (limited to 'commit.c') diff --git a/bisect.c b/bisect.c index ef5ee5a643..3088516e17 100644 --- a/bisect.c +++ b/bisect.c @@ -846,7 +846,8 @@ static enum bisect_error check_merge_bases(int rev_nr, struct commit **rev, int enum bisect_error res = BISECT_OK; struct commit_list *result; - result = get_merge_bases_many(rev[0], rev_nr - 1, rev + 1); + result = repo_get_merge_bases_many(the_repository, rev[0], rev_nr - 1, + rev + 1); for (; result; result = result->next) { const struct object_id *mb = &result->item->object.oid; diff --git a/builtin/branch.c b/builtin/branch.c index 968ea03c05..bbcfb34b3c 100644 --- a/builtin/branch.c +++ b/builtin/branch.c @@ -150,7 +150,8 @@ static int branch_merged(int kind, const char *name, if (!reference_rev) reference_rev = head_rev; - merged = reference_rev ? in_merge_bases(rev, reference_rev) : 0; + merged = reference_rev ? repo_in_merge_bases(the_repository, rev, + reference_rev) : 0; /* * After the safety valve is fully redefined to "check with @@ -160,7 +161,7 @@ static int branch_merged(int kind, const char *name, * a gentle reminder is in order. */ if ((head_rev != reference_rev) && - (head_rev ? in_merge_bases(rev, head_rev) : 0) != merged) { + (head_rev ? repo_in_merge_bases(the_repository, rev, head_rev) : 0) != merged) { if (merged) warning(_("deleting branch '%s' that has been merged to\n" " '%s', but not yet merged to HEAD."), diff --git a/builtin/fast-import.c b/builtin/fast-import.c index f533b768ef..2098c0c5a3 100644 --- a/builtin/fast-import.c +++ b/builtin/fast-import.c @@ -1625,7 +1625,7 @@ static int update_branch(struct branch *b) if (!old_cmit || !new_cmit) return error("Branch %s is missing commits.", b->name); - if (!in_merge_bases(old_cmit, new_cmit)) { + if (!repo_in_merge_bases(the_repository, old_cmit, new_cmit)) { warning("Not updating %s" " (new tip %s does not contain %s)", b->name, oid_to_hex(&b->oid), diff --git a/builtin/fetch.c b/builtin/fetch.c index 80cf1d0158..db8815032f 100644 --- a/builtin/fetch.c +++ b/builtin/fetch.c @@ -965,7 +965,8 @@ static int update_local_ref(struct ref *ref, if (fetch_show_forced_updates) { uint64_t t_before = getnanotime(); - fast_forward = in_merge_bases(current, updated); + fast_forward = repo_in_merge_bases(the_repository, current, + updated); forced_updates_ms += (getnanotime() - t_before) / 1000000; } else { fast_forward = 1; diff --git a/builtin/log.c b/builtin/log.c index b4c38f6ad8..5604b4b5f0 100644 --- a/builtin/log.c +++ b/builtin/log.c @@ -1649,7 +1649,9 @@ static struct commit *get_base_commit(const char *base_commit, return NULL; } commit = lookup_commit_or_die(&oid, "upstream base"); - base_list = get_merge_bases_many(commit, total, list); + base_list = repo_get_merge_bases_many(the_repository, + commit, total, + list); /* There should be one and only one merge base. */ if (!base_list || base_list->next) { if (die_on_failure) { @@ -1683,7 +1685,9 @@ static struct commit *get_base_commit(const char *base_commit, while (rev_nr > 1) { for (i = 0; i < rev_nr / 2; i++) { struct commit_list *merge_base; - merge_base = get_merge_bases(rev[2 * i], rev[2 * i + 1]); + merge_base = repo_get_merge_bases(the_repository, + rev[2 * i], + rev[2 * i + 1]); if (!merge_base || merge_base->next) { if (die_on_failure) { die(_("failed to find exact merge base")); @@ -1701,7 +1705,7 @@ static struct commit *get_base_commit(const char *base_commit, rev_nr = DIV_ROUND_UP(rev_nr, 2); } - if (!in_merge_bases(base, rev[0])) { + if (!repo_in_merge_bases(the_repository, base, rev[0])) { if (die_on_failure) { die(_("base commit should be the ancestor of revision list")); } else { diff --git a/builtin/merge-base.c b/builtin/merge-base.c index 688d5c29b7..64d29136d1 100644 --- a/builtin/merge-base.c +++ b/builtin/merge-base.c @@ -13,7 +13,8 @@ static int show_merge_base(struct commit **rev, int rev_nr, int show_all) { struct commit_list *result, *r; - result = get_merge_bases_many_dirty(rev[0], rev_nr - 1, rev + 1); + result = repo_get_merge_bases_many_dirty(the_repository, rev[0], + rev_nr - 1, rev + 1); if (!result) return 1; @@ -105,7 +106,7 @@ static int handle_is_ancestor(int argc, const char **argv) die("--is-ancestor takes exactly two commits"); one = get_commit_reference(argv[0]); two = get_commit_reference(argv[1]); - if (in_merge_bases(one, two)) + if (repo_in_merge_bases(the_repository, one, two)) return 0; else return 1; diff --git a/builtin/merge-tree.c b/builtin/merge-tree.c index 828dc81c42..4e4a9d6ba1 100644 --- a/builtin/merge-tree.c +++ b/builtin/merge-tree.c @@ -452,7 +452,8 @@ static int real_merge(struct merge_tree_options *o, * Get the merge bases, in reverse order; see comment above * merge_incore_recursive in merge-ort.h */ - merge_bases = get_merge_bases(parent1, parent2); + merge_bases = repo_get_merge_bases(the_repository, parent1, + parent2); if (!merge_bases && !o->allow_unrelated_histories) die(_("refusing to merge unrelated histories")); merge_bases = reverse_commit_list(merge_bases); diff --git a/builtin/merge.c b/builtin/merge.c index 7331a0cd91..c5a9321806 100644 --- a/builtin/merge.c +++ b/builtin/merge.c @@ -1531,7 +1531,8 @@ int cmd_merge(int argc, const char **argv, const char *prefix) if (!remoteheads) ; /* already up-to-date */ else if (!remoteheads->next) - common = get_merge_bases(head_commit, remoteheads->item); + common = repo_get_merge_bases(the_repository, head_commit, + remoteheads->item); else { struct commit_list *list = remoteheads; commit_list_insert(head_commit, &list); @@ -1649,7 +1650,9 @@ int cmd_merge(int argc, const char **argv, const char *prefix) * merge_bases again, otherwise "git merge HEAD^ * HEAD^^" would be missed. */ - common_one = get_merge_bases(head_commit, j->item); + common_one = repo_get_merge_bases(the_repository, + head_commit, + j->item); if (!oideq(&common_one->item->object.oid, &j->item->object.oid)) { up_to_date = 0; break; diff --git a/builtin/rebase.c b/builtin/rebase.c index d5358ca89d..5fd7bfb486 100644 --- a/builtin/rebase.c +++ b/builtin/rebase.c @@ -882,7 +882,7 @@ static int can_fast_forward(struct commit *onto, struct commit *upstream, if (!upstream) goto done; - merge_bases = get_merge_bases(upstream, head); + merge_bases = repo_get_merge_bases(the_repository, upstream, head); if (!merge_bases || merge_bases->next) goto done; @@ -901,7 +901,8 @@ static void fill_branch_base(struct rebase_options *options, { struct commit_list *merge_bases = NULL; - merge_bases = get_merge_bases(options->onto, options->orig_head); + merge_bases = repo_get_merge_bases(the_repository, options->onto, + options->orig_head); if (!merge_bases || merge_bases->next) oidcpy(branch_base, null_oid()); else diff --git a/builtin/receive-pack.c b/builtin/receive-pack.c index b5816624d2..6d4fc1368a 100644 --- a/builtin/receive-pack.c +++ b/builtin/receive-pack.c @@ -1548,7 +1548,7 @@ static const char *update(struct command *cmd, struct shallow_info *si) } old_commit = (struct commit *)old_object; new_commit = (struct commit *)new_object; - if (!in_merge_bases(old_commit, new_commit)) { + if (!repo_in_merge_bases(the_repository, old_commit, new_commit)) { rp_error("denying non-fast-forward %s" " (you should pull first)", name); ret = "non-fast-forward"; diff --git a/builtin/rev-parse.c b/builtin/rev-parse.c index eb53a303de..5685cf0ea7 100644 --- a/builtin/rev-parse.c +++ b/builtin/rev-parse.c @@ -292,7 +292,7 @@ static int try_difference(const char *arg) *dotdot = '.'; return 0; } - exclude = get_merge_bases(a, b); + exclude = repo_get_merge_bases(the_repository, a, b); while (exclude) { struct commit *commit = pop_commit(&exclude); show_rev(REVERSED, &commit->object.oid, NULL); diff --git a/commit-reach.c b/commit-reach.c index 2e33c599a8..a4b9eda723 100644 --- a/commit-reach.c +++ b/commit-reach.c @@ -162,7 +162,8 @@ struct commit_list *get_octopus_merge_bases(struct commit_list *in) for (j = ret; j; j = j->next) { struct commit_list *bases; - bases = get_merge_bases(i->item, j->item); + bases = repo_get_merge_bases(the_repository, i->item, + j->item); if (!new_commits) new_commits = bases; else diff --git a/commit-reach.h b/commit-reach.h index 148b56fea5..94a96e0329 100644 --- a/commit-reach.h +++ b/commit-reach.h @@ -19,11 +19,6 @@ struct commit_list *repo_get_merge_bases_many(struct repository *r, struct commit_list *repo_get_merge_bases_many_dirty(struct repository *r, struct commit *one, int n, struct commit **twos); -#ifndef NO_THE_REPOSITORY_COMPATIBILITY_MACROS -#define get_merge_bases(r1, r2) repo_get_merge_bases(the_repository, r1, r2) -#define get_merge_bases_many(one, n, two) repo_get_merge_bases_many(the_repository, one, n, two) -#define get_merge_bases_many_dirty(one, n, twos) repo_get_merge_bases_many_dirty(the_repository, one, n, twos) -#endif struct commit_list *get_octopus_merge_bases(struct commit_list *in); @@ -36,10 +31,6 @@ int repo_in_merge_bases(struct repository *r, int repo_in_merge_bases_many(struct repository *r, struct commit *commit, int nr_reference, struct commit **reference); -#ifndef NO_THE_REPOSITORY_COMPATIBILITY_MACROS -#define in_merge_bases(c1, c2) repo_in_merge_bases(the_repository, c1, c2) -#define in_merge_bases_many(c1, n, cs) repo_in_merge_bases_many(the_repository, c1, n, cs) -#endif /* * Takes a list of commits and returns a new list where those diff --git a/commit.c b/commit.c index 06a7c728e8..62682f5564 100644 --- a/commit.c +++ b/commit.c @@ -1014,7 +1014,8 @@ struct commit *get_fork_point(const char *refname, struct commit *commit) for (i = 0; i < revs.nr; i++) revs.commit[i]->object.flags &= ~TMP_MARK; - bases = get_merge_bases_many(commit, revs.nr, revs.commit); + bases = repo_get_merge_bases_many(the_repository, commit, revs.nr, + revs.commit); /* * There should be one and only one merge base, when we found diff --git a/contrib/coccinelle/the_repository.cocci b/contrib/coccinelle/the_repository.cocci index dcdba314fc..1ab63f0196 100644 --- a/contrib/coccinelle/the_repository.cocci +++ b/contrib/coccinelle/the_repository.cocci @@ -38,6 +38,22 @@ | - peel_to_type + repo_peel_to_type +// commit-reach.h +| +- get_merge_bases ++ repo_get_merge_bases +| +- get_merge_bases_many ++ repo_get_merge_bases_many +| +- get_merge_bases_many_dirty ++ repo_get_merge_bases_many_dirty +| +- in_merge_bases ++ repo_in_merge_bases +| +- in_merge_bases_many ++ repo_in_merge_bases_many ) ( + the_repository, diff --git a/contrib/coccinelle/the_repository.pending.cocci b/contrib/coccinelle/the_repository.pending.cocci index 2d200ab83e..e9209fc0cc 100644 --- a/contrib/coccinelle/the_repository.pending.cocci +++ b/contrib/coccinelle/the_repository.pending.cocci @@ -5,23 +5,7 @@ @@ @@ ( -// commit-reach.h -- get_merge_bases -+ repo_get_merge_bases -| -- get_merge_bases_many -+ repo_get_merge_bases_many -| -- get_merge_bases_many_dirty -+ repo_get_merge_bases_many_dirty -| -- in_merge_bases -+ repo_in_merge_bases -| -- in_merge_bases_many -+ repo_in_merge_bases_many // commit.h -| - parse_commit_internal + repo_parse_commit_internal | diff --git a/http-push.c b/http-push.c index 7f71316456..ceab00bd90 100644 --- a/http-push.c +++ b/http-push.c @@ -1570,7 +1570,7 @@ static int verify_merge_base(struct object_id *head_oid, struct ref *remote) struct commit *branch = lookup_commit_or_die(&remote->old_oid, remote->name); - return in_merge_bases(branch, head); + return repo_in_merge_bases(the_repository, branch, head); } static int delete_remote_branch(const char *pattern, int force) diff --git a/log-tree.c b/log-tree.c index f36adb947e..4bebb86eca 100644 --- a/log-tree.c +++ b/log-tree.c @@ -993,7 +993,7 @@ static int do_remerge_diff(struct rev_info *opt, /* Parse the relevant commits and get the merge bases */ parse_commit_or_die(parent1); parse_commit_or_die(parent2); - bases = get_merge_bases(parent1, parent2); + bases = repo_get_merge_bases(the_repository, parent1, parent2); /* Re-merge the parents */ merge_incore_recursive(&o, bases, parent1, parent2, &res); diff --git a/merge-ort.c b/merge-ort.c index d1611ca400..e9f8bd1598 100644 --- a/merge-ort.c +++ b/merge-ort.c @@ -5017,7 +5017,7 @@ static void merge_ort_internal(struct merge_options *opt, struct strbuf merge_base_abbrev = STRBUF_INIT; if (!merge_bases) { - merge_bases = get_merge_bases(h1, h2); + merge_bases = repo_get_merge_bases(the_repository, h1, h2); /* See merge-ort.h:merge_incore_recursive() declaration NOTE */ merge_bases = reverse_commit_list(merge_bases); } diff --git a/merge-recursive.c b/merge-recursive.c index ae469f8cc8..9771ef540c 100644 --- a/merge-recursive.c +++ b/merge-recursive.c @@ -3592,7 +3592,7 @@ static int merge_recursive_internal(struct merge_options *opt, } if (!merge_bases) { - merge_bases = get_merge_bases(h1, h2); + merge_bases = repo_get_merge_bases(the_repository, h1, h2); merge_bases = reverse_commit_list(merge_bases); } diff --git a/notes-merge.c b/notes-merge.c index d290c7478e..fca9422a29 100644 --- a/notes-merge.c +++ b/notes-merge.c @@ -600,7 +600,7 @@ int notes_merge(struct notes_merge_options *o, assert(local && remote); /* Find merge bases */ - bases = get_merge_bases(local, remote); + bases = repo_get_merge_bases(the_repository, local, remote); if (!bases) { base_oid = null_oid(); base_tree_oid = the_hash_algo->empty_tree; diff --git a/remote.c b/remote.c index ff9b023831..71b1ae2db0 100644 --- a/remote.c +++ b/remote.c @@ -2662,7 +2662,7 @@ static int is_reachable_in_reflog(const char *local, const struct ref *remote) if (MERGE_BASES_BATCH_SIZE < size) size = MERGE_BASES_BATCH_SIZE; - if ((ret = in_merge_bases_many(commit, size, chunk))) + if ((ret = repo_in_merge_bases_many(the_repository, commit, size, chunk))) break; } diff --git a/revision.c b/revision.c index 0f775ee2e9..c2b7b2f107 100644 --- a/revision.c +++ b/revision.c @@ -1957,7 +1957,7 @@ static void prepare_show_merge(struct rev_info *revs) other = lookup_commit_or_die(&oid, "MERGE_HEAD"); add_pending_object(revs, &head->object, "HEAD"); add_pending_object(revs, &other->object, "MERGE_HEAD"); - bases = get_merge_bases(head, other); + bases = repo_get_merge_bases(the_repository, head, other); add_rev_cmdline_list(revs, bases, REV_CMD_MERGE_BASE, UNINTERESTING | BOTTOM); add_pending_commit_list(revs, bases, UNINTERESTING | BOTTOM); free_commit_list(bases); @@ -2052,7 +2052,7 @@ static int handle_dotdot_1(const char *arg, char *dotdot, if (!a || !b) return dotdot_missing(arg, dotdot, revs, symmetric); - exclude = get_merge_bases(a, b); + exclude = repo_get_merge_bases(the_repository, a, b); add_rev_cmdline_list(revs, exclude, REV_CMD_MERGE_BASE, flags_exclude); add_pending_commit_list(revs, exclude, flags_exclude); diff --git a/sequencer.c b/sequencer.c index 818932a630..d97923883f 100644 --- a/sequencer.c +++ b/sequencer.c @@ -4102,7 +4102,8 @@ static int do_merge(struct repository *r, } merge_commit = to_merge->item; - bases = get_merge_bases(head_commit, merge_commit); + bases = repo_get_merge_bases(the_repository, head_commit, + merge_commit); if (bases && oideq(&merge_commit->object.oid, &bases->item->object.oid)) { ret = 0; diff --git a/shallow.c b/shallow.c index 17f9bcdb5f..0fcdfd7d35 100644 --- a/shallow.c +++ b/shallow.c @@ -791,7 +791,7 @@ static void post_assign_shallow(struct shallow_info *info, for (j = 0; j < bitmap_nr; j++) if (bitmap[0][j] && /* Step 7, reachability test at commit level */ - !in_merge_bases_many(c, ca.nr, ca.commits)) { + !repo_in_merge_bases_many(the_repository, c, ca.nr, ca.commits)) { update_refstatus(ref_status, info->ref->nr, *bitmap); dst++; break; @@ -819,9 +819,10 @@ int delayed_reachability_test(struct shallow_info *si, int c) si->nr_commits = ca.nr; } - si->reachable[c] = in_merge_bases_many(commit, - si->nr_commits, - si->commits); + si->reachable[c] = repo_in_merge_bases_many(the_repository, + commit, + si->nr_commits, + si->commits); si->need_reachability_test[c] = 0; } return si->reachable[c]; diff --git a/t/helper/test-reach.c b/t/helper/test-reach.c index 00f0f29a6a..b6d197722f 100644 --- a/t/helper/test-reach.c +++ b/t/helper/test-reach.c @@ -106,13 +106,17 @@ int cmd__reach(int ac, const char **av) if (!strcmp(av[1], "ref_newer")) printf("%s(A,B):%d\n", av[1], ref_newer(&oid_A, &oid_B)); else if (!strcmp(av[1], "in_merge_bases")) - printf("%s(A,B):%d\n", av[1], in_merge_bases(A, B)); + printf("%s(A,B):%d\n", av[1], + repo_in_merge_bases(the_repository, A, B)); else if (!strcmp(av[1], "in_merge_bases_many")) - printf("%s(A,X):%d\n", av[1], in_merge_bases_many(A, X_nr, X_array)); + printf("%s(A,X):%d\n", av[1], + repo_in_merge_bases_many(the_repository, A, X_nr, X_array)); else if (!strcmp(av[1], "is_descendant_of")) printf("%s(A,X):%d\n", av[1], repo_is_descendant_of(r, A, X)); else if (!strcmp(av[1], "get_merge_bases_many")) { - struct commit_list *list = get_merge_bases_many(A, X_nr, X_array); + struct commit_list *list = repo_get_merge_bases_many(the_repository, + A, X_nr, + X_array); printf("%s(A,X):\n", av[1]); print_sorted_commit_ids(list); } else if (!strcmp(av[1], "reduce_heads")) { -- cgit v1.2.3 From ecb5091fd4301ac647db0bd2504112b38f7ee06d Mon Sep 17 00:00:00 2001 From: Ævar Arnfjörð Bjarmason Date: Tue, 28 Mar 2023 15:58:48 +0200 Subject: cocci: apply the "commit.h" part of "the_repository.pending" MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Apply the part of "the_repository.pending.cocci" pertaining to "commit.h". Signed-off-by: Ævar Arnfjörð Bjarmason Signed-off-by: Junio C Hamano --- blame.c | 4 +- builtin/am.c | 7 ++- builtin/blame.c | 6 +- builtin/checkout.c | 13 ++-- builtin/commit.c | 8 +-- builtin/describe.c | 4 +- builtin/diff.c | 3 +- builtin/fast-export.c | 4 +- builtin/gc.c | 4 +- builtin/log.c | 5 +- builtin/merge-tree.c | 6 +- builtin/merge.c | 3 +- builtin/name-rev.c | 4 +- builtin/notes.c | 2 +- builtin/rebase.c | 2 +- builtin/replace.c | 4 +- builtin/shortlog.c | 5 +- builtin/show-branch.c | 4 +- commit-graph.c | 2 +- commit-reach.c | 16 ++--- commit.c | 25 ++++---- commit.h | 18 ------ contrib/coccinelle/the_repository.cocci | 19 ++++++ contrib/coccinelle/the_repository.pending.cocci | 19 ------ delta-islands.c | 5 +- fmt-merge-msg.c | 5 +- fsck.c | 4 +- http-push.c | 3 +- list-objects.c | 18 +++--- merge-recursive.c | 2 +- negotiator/default.c | 6 +- negotiator/skipping.c | 2 +- notes-merge.c | 5 +- notes-utils.c | 2 +- object-name.c | 8 +-- pack-bitmap-write.c | 3 +- pretty.c | 5 +- reflog.c | 2 +- revision.c | 12 ++-- sequencer.c | 82 +++++++++++++++---------- shallow.c | 4 +- t/helper/test-fast-rebase.c | 9 +-- tree.c | 2 +- walker.c | 4 +- 44 files changed, 196 insertions(+), 174 deletions(-) (limited to 'commit.c') diff --git a/blame.c b/blame.c index 8bfeaa1c63..af2b67c084 100644 --- a/blame.c +++ b/blame.c @@ -2429,7 +2429,7 @@ static void pass_blame(struct blame_scoreboard *sb, struct blame_origin *origin, if (sg_origin[i]) continue; - if (parse_commit(p)) + if (repo_parse_commit(the_repository, p)) continue; porigin = find(sb->repo, p, origin, sb->bloom_data); if (!porigin) @@ -2592,7 +2592,7 @@ void assign_blame(struct blame_scoreboard *sb, int opt) * so hold onto it in the meantime. */ blame_origin_incref(suspect); - parse_commit(commit); + repo_parse_commit(the_repository, commit); if (sb->reverse || (!(commit->object.flags & UNINTERESTING) && !(revs->max_age != -1 && commit->date < revs->max_age))) diff --git a/builtin/am.c b/builtin/am.c index c04038f1f3..456884852e 100644 --- a/builtin/am.c +++ b/builtin/am.c @@ -1329,7 +1329,8 @@ static void get_commit_info(struct am_state *state, struct commit *commit) size_t ident_len; struct ident_split id; - buffer = logmsg_reencode(commit, NULL, get_commit_output_encoding()); + buffer = repo_logmsg_reencode(the_repository, commit, NULL, + get_commit_output_encoding()); ident_line = find_commit_header(buffer, "author", &ident_len); if (!ident_line) @@ -1361,7 +1362,7 @@ static void get_commit_info(struct am_state *state, struct commit *commit) die(_("unable to parse commit %s"), oid_to_hex(&commit->object.oid)); state->msg = xstrdup(msg + 2); state->msg_len = strlen(state->msg); - unuse_commit_buffer(commit, buffer); + repo_unuse_commit_buffer(the_repository, commit, buffer); } /** @@ -1404,7 +1405,7 @@ static void write_index_patch(const struct am_state *state) if (!repo_get_oid(the_repository, "HEAD", &head)) { struct commit *commit = lookup_commit_or_die(&head, "HEAD"); - tree = get_commit_tree(commit); + tree = repo_get_commit_tree(the_repository, commit); } else tree = lookup_tree(the_repository, the_repository->hash_algo->empty_tree); diff --git a/builtin/blame.c b/builtin/blame.c index 0155062de1..91e04f57cc 100644 --- a/builtin/blame.c +++ b/builtin/blame.c @@ -199,13 +199,13 @@ static void get_commit_info(struct commit *commit, const char *message; encoding = get_log_output_encoding(); - message = logmsg_reencode(commit, NULL, encoding); + message = repo_logmsg_reencode(the_repository, commit, NULL, encoding); get_ac_line(message, "\nauthor ", &ret->author, &ret->author_mail, &ret->author_time, &ret->author_tz); if (!detailed) { - unuse_commit_buffer(commit, message); + repo_unuse_commit_buffer(the_repository, commit, message); return; } @@ -219,7 +219,7 @@ static void get_commit_info(struct commit *commit, else strbuf_addf(&ret->summary, "(%s)", oid_to_hex(&commit->object.oid)); - unuse_commit_buffer(commit, message); + repo_unuse_commit_buffer(the_repository, commit, message); } /* diff --git a/builtin/checkout.c b/builtin/checkout.c index 6216bb6bba..1d1f33e33e 100644 --- a/builtin/checkout.c +++ b/builtin/checkout.c @@ -640,7 +640,7 @@ static void describe_detached_head(const char *msg, struct commit *commit) { struct strbuf sb = STRBUF_INIT; - if (!parse_commit(commit)) + if (!repo_parse_commit(the_repository, commit)) pp_commit_easy(CMIT_FMT_ONELINE, commit, &sb); if (print_sha1_ellipsis()) { fprintf(stderr, "%s %s... %s\n", msg, @@ -755,7 +755,8 @@ static int merge_working_tree(const struct checkout_opts *opts, BUG("'switch --orphan' should never accept a commit as starting point"); new_tree = parse_tree_indirect(the_hash_algo->empty_tree); } else - new_tree = get_commit_tree(new_branch_info->commit); + new_tree = repo_get_commit_tree(the_repository, + new_branch_info->commit); if (opts->discard_changes) { ret = reset_tree(new_tree, opts, 1, writeout_error, new_branch_info); if (ret) @@ -817,7 +818,8 @@ static int merge_working_tree(const struct checkout_opts *opts, */ if (!old_branch_info->commit) return 1; - old_tree = get_commit_tree(old_branch_info->commit); + old_tree = repo_get_commit_tree(the_repository, + old_branch_info->commit); if (repo_index_has_changes(the_repository, old_tree, &sb)) die(_("cannot continue with staged changes in " @@ -1006,7 +1008,7 @@ static void describe_one_orphan(struct strbuf *sb, struct commit *commit) strbuf_addstr(sb, " "); strbuf_add_unique_abbrev(sb, &commit->object.oid, DEFAULT_ABBREV); strbuf_addch(sb, ' '); - if (!parse_commit(commit)) + if (!repo_parse_commit(the_repository, commit)) pp_commit_easy(CMIT_FMT_ONELINE, commit, sb); strbuf_addch(sb, '\n'); } @@ -1206,7 +1208,8 @@ static void setup_new_branch_info_and_source_tree( *source_tree = parse_tree_indirect(rev); } else { parse_commit_or_die(new_branch_info->commit); - *source_tree = get_commit_tree(new_branch_info->commit); + *source_tree = repo_get_commit_tree(the_repository, + new_branch_info->commit); } } diff --git a/builtin/commit.c b/builtin/commit.c index 80d1e31f25..bda6afc4bd 100644 --- a/builtin/commit.c +++ b/builtin/commit.c @@ -712,7 +712,7 @@ static void prepare_amend_commit(struct commit *commit, struct strbuf *sb, { const char *buffer, *subject, *fmt; - buffer = get_commit_buffer(commit, NULL); + buffer = repo_get_commit_buffer(the_repository, commit, NULL); find_commit_subject(buffer, &subject); /* * 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, */ fmt = starts_with(subject, "amend!") ? "%b" : "%B"; format_commit_message(commit, fmt, sb, ctx); - unuse_commit_buffer(commit, buffer); + repo_unuse_commit_buffer(the_repository, commit, buffer); } 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) if (!commit) die(_("could not lookup commit %s"), name); out_enc = get_commit_output_encoding(); - return logmsg_reencode(commit, NULL, out_enc); + return repo_logmsg_reencode(the_repository, commit, NULL, out_enc); } /* @@ -1718,7 +1718,7 @@ int cmd_commit(int argc, const char **argv, const char *prefix) current_head = NULL; else { current_head = lookup_commit_or_die(&oid, "HEAD"); - if (parse_commit(current_head)) + if (repo_parse_commit(the_repository, current_head)) die(_("could not parse HEAD commit")); } verbose = -1; /* unspecified */ diff --git a/builtin/describe.c b/builtin/describe.c index c85bf9c418..e880a86f37 100644 --- a/builtin/describe.c +++ b/builtin/describe.c @@ -261,7 +261,7 @@ static unsigned long finish_depth_computation( best->depth++; while (parents) { struct commit *p = parents->item; - parse_commit(p); + repo_parse_commit(the_repository, p); if (!(p->object.flags & SEEN)) commit_list_insert_by_date(p, list); p->object.flags |= c->object.flags; @@ -404,7 +404,7 @@ static void describe_commit(struct object_id *oid, struct strbuf *dst) } while (parents) { struct commit *p = parents->item; - parse_commit(p); + repo_parse_commit(the_repository, p); if (!(p->object.flags & SEEN)) commit_list_insert_by_date(p, &list); p->object.flags |= c->object.flags; diff --git a/builtin/diff.c b/builtin/diff.c index 26f1e532c6..1091c377af 100644 --- a/builtin/diff.c +++ b/builtin/diff.c @@ -548,7 +548,8 @@ int cmd_diff(int argc, const char **argv, const char *prefix) if (!obj) die(_("invalid object '%s' given."), name); if (obj->type == OBJ_COMMIT) - obj = &get_commit_tree(((struct commit *)obj))->object; + obj = &repo_get_commit_tree(the_repository, + ((struct commit *)obj))->object; if (obj->type == OBJ_TREE) { if (sdiff.skip && bitmap_get(sdiff.skip, i)) diff --git a/builtin/fast-export.c b/builtin/fast-export.c index 39a890fc00..5fe7c02970 100644 --- a/builtin/fast-export.c +++ b/builtin/fast-export.c @@ -618,7 +618,7 @@ static void handle_commit(struct commit *commit, struct rev_info *rev, rev->diffopt.output_format = DIFF_FORMAT_CALLBACK; parse_commit_or_die(commit); - commit_buffer = get_commit_buffer(commit, NULL); + commit_buffer = repo_get_commit_buffer(the_repository, commit, NULL); author = strstr(commit_buffer, "\nauthor "); if (!author) die("could not find author in commit %s", @@ -699,7 +699,7 @@ static void handle_commit(struct commit *commit, struct rev_info *rev, ? strlen(message) : 0), reencoded ? reencoded : message ? message : ""); free(reencoded); - unuse_commit_buffer(commit, commit_buffer); + repo_unuse_commit_buffer(the_repository, commit, commit_buffer); for (i = 0, p = commit->parents; p; p = p->next) { struct object *obj = &p->item->object; diff --git a/builtin/gc.c b/builtin/gc.c index 02455fdcd7..e60decbc56 100644 --- a/builtin/gc.c +++ b/builtin/gc.c @@ -820,7 +820,7 @@ static int dfs_on_ref(const char *refname UNUSED, commit = lookup_commit(the_repository, oid); if (!commit) return 0; - if (parse_commit(commit) || + if (repo_parse_commit(the_repository, commit) || commit_graph_position(commit) != COMMIT_NOT_FROM_GRAPH) return 0; @@ -837,7 +837,7 @@ static int dfs_on_ref(const char *refname UNUSED, commit = pop_commit(&stack); for (parent = commit->parents; parent; parent = parent->next) { - if (parse_commit(parent->item) || + if (repo_parse_commit(the_repository, parent->item) || commit_graph_position(parent->item) != COMMIT_NOT_FROM_GRAPH || parent->item->object.flags & SEEN) continue; diff --git a/builtin/log.c b/builtin/log.c index 5604b4b5f0..f249aca049 100644 --- a/builtin/log.c +++ b/builtin/log.c @@ -1314,10 +1314,11 @@ static void make_cover_letter(struct rev_info *rev, int use_separate_file, log_write_email_headers(rev, head, &pp.after_subject, &need_8bit_cte, 0); for (i = 0; !need_8bit_cte && i < nr; i++) { - const char *buf = get_commit_buffer(list[i], NULL); + const char *buf = repo_get_commit_buffer(the_repository, + list[i], NULL); if (has_non_ascii(buf)) need_8bit_cte = 1; - unuse_commit_buffer(list[i], buf); + repo_unuse_commit_buffer(the_repository, list[i], buf); } if (!branch_name) diff --git a/builtin/merge-tree.c b/builtin/merge-tree.c index 4e4a9d6ba1..c0acbc6a54 100644 --- a/builtin/merge-tree.c +++ b/builtin/merge-tree.c @@ -443,9 +443,9 @@ static int real_merge(struct merge_tree_options *o, die(_("could not lookup commit %s"), merge_base); opt.ancestor = merge_base; - base_tree = get_commit_tree(base_commit); - parent1_tree = get_commit_tree(parent1); - parent2_tree = get_commit_tree(parent2); + base_tree = repo_get_commit_tree(the_repository, base_commit); + parent1_tree = repo_get_commit_tree(the_repository, parent1); + parent2_tree = repo_get_commit_tree(the_repository, parent2); merge_incore_nonrecursive(&opt, base_tree, parent1_tree, parent2_tree, &result); } else { /* diff --git a/builtin/merge.c b/builtin/merge.c index c5a9321806..197e152aba 100644 --- a/builtin/merge.c +++ b/builtin/merge.c @@ -1611,7 +1611,8 @@ int cmd_merge(int argc, const char **argv, const char *prefix) * Must first ensure that index matches HEAD before * attempting a trivial merge. */ - struct tree *head_tree = get_commit_tree(head_commit); + struct tree *head_tree = repo_get_commit_tree(the_repository, + head_commit); struct strbuf sb = STRBUF_INIT; if (repo_index_has_changes(the_repository, head_tree, diff --git a/builtin/name-rev.c b/builtin/name-rev.c index 35fd89f794..ad1de02308 100644 --- a/builtin/name-rev.c +++ b/builtin/name-rev.c @@ -181,7 +181,7 @@ static void name_rev(struct commit *start_commit, size_t parents_to_queue_nr, parents_to_queue_alloc = 0; struct rev_name *start_name; - parse_commit(start_commit); + repo_parse_commit(the_repository, start_commit); if (commit_is_before_cutoff(start_commit)) return; @@ -211,7 +211,7 @@ static void name_rev(struct commit *start_commit, struct rev_name *parent_name; int generation, distance; - parse_commit(parent); + repo_parse_commit(the_repository, parent); if (commit_is_before_cutoff(parent)) continue; diff --git a/builtin/notes.c b/builtin/notes.c index d98460e5d6..b497eae520 100644 --- a/builtin/notes.c +++ b/builtin/notes.c @@ -720,7 +720,7 @@ static int merge_commit(struct notes_merge_options *o) die(_("failed to read ref NOTES_MERGE_PARTIAL")); else if (!(partial = lookup_commit_reference(the_repository, &oid))) die(_("could not find commit from NOTES_MERGE_PARTIAL.")); - else if (parse_commit(partial)) + else if (repo_parse_commit(the_repository, partial)) die(_("could not parse commit from NOTES_MERGE_PARTIAL.")); if (partial->parents) diff --git a/builtin/rebase.c b/builtin/rebase.c index 5fd7bfb486..eba48bffaa 100644 --- a/builtin/rebase.c +++ b/builtin/rebase.c @@ -853,7 +853,7 @@ static int checkout_up_to_date(struct rebase_options *options) static int is_linear_history(struct commit *from, struct commit *to) { while (to && to != from) { - parse_commit(to); + repo_parse_commit(the_repository, to); if (!to->parents) return 1; if (to->parents->next) diff --git a/builtin/replace.c b/builtin/replace.c index 33c6cdb79c..85f0b79c92 100644 --- a/builtin/replace.c +++ b/builtin/replace.c @@ -458,9 +458,9 @@ static int create_graft(int argc, const char **argv, int force, int gentle) if (!commit) return error(_("could not parse %s"), old_ref); - buffer = get_commit_buffer(commit, &size); + buffer = repo_get_commit_buffer(the_repository, commit, &size); strbuf_add(&buf, buffer, size); - unuse_commit_buffer(commit, buffer); + repo_unuse_commit_buffer(the_repository, commit, buffer); if (replace_parents(&buf, argc - 1, &argv[1]) < 0) { strbuf_release(&buf); diff --git a/builtin/shortlog.c b/builtin/shortlog.c index 27a87167e1..8afd1ad865 100644 --- a/builtin/shortlog.c +++ b/builtin/shortlog.c @@ -179,7 +179,8 @@ static void insert_records_from_trailers(struct shortlog *log, * Using format_commit_message("%B") would be simpler here, but * this saves us copying the message. */ - commit_buffer = logmsg_reencode(commit, NULL, ctx->output_encoding); + commit_buffer = repo_logmsg_reencode(the_repository, commit, NULL, + ctx->output_encoding); body = strstr(commit_buffer, "\n\n"); if (!body) return; @@ -202,7 +203,7 @@ static void insert_records_from_trailers(struct shortlog *log, trailer_iterator_release(&iter); strbuf_release(&ident); - unuse_commit_buffer(commit, commit_buffer); + repo_unuse_commit_buffer(the_repository, commit, commit_buffer); } static int shortlog_needs_dedup(const struct shortlog *log) diff --git a/builtin/show-branch.c b/builtin/show-branch.c index 9e3b8ed27e..d60e536a53 100644 --- a/builtin/show-branch.c +++ b/builtin/show-branch.c @@ -240,7 +240,7 @@ static void join_revs(struct commit_list **list_p, parents = parents->next; if ((this_flag & flags) == flags) continue; - parse_commit(p); + repo_parse_commit(the_repository, p); if (mark_seen(p, seen_p) && !still_interesting) extra--; p->object.flags |= flags; @@ -842,7 +842,7 @@ int cmd_show_branch(int ac, const char **av, const char *prefix) if (!commit) die(_("cannot find commit %s (%s)"), ref_name[num_rev], oid_to_hex(&revkey)); - parse_commit(commit); + repo_parse_commit(the_repository, commit); mark_seen(commit, &seen); /* rev#0 uses bit REV_SHIFT, rev#1 uses bit REV_SHIFT+1, diff --git a/commit-graph.c b/commit-graph.c index c11b59f28b..8273085aa6 100644 --- a/commit-graph.c +++ b/commit-graph.c @@ -2549,7 +2549,7 @@ int verify_commit_graph(struct repository *r, struct commit_graph *g, int flags) graph_commit = lookup_commit(r, &cur_oid); odb_commit = (struct commit *)create_object(r, &cur_oid, alloc_commit_node(r)); - if (parse_commit_internal(odb_commit, 0, 0)) { + if (repo_parse_commit_internal(the_repository, odb_commit, 0, 0)) { graph_report(_("failed to parse commit %s from object database for commit-graph"), oid_to_hex(&cur_oid)); continue; diff --git a/commit-reach.c b/commit-reach.c index a4b9eda723..c88faf7e7b 100644 --- a/commit-reach.c +++ b/commit-reach.c @@ -585,7 +585,7 @@ int ref_newer(const struct object_id *new_oid, const struct object_id *old_oid) return 0; new_commit = (struct commit *) o; - if (parse_commit(new_commit) < 0) + if (repo_parse_commit(the_repository, new_commit) < 0) return 0; commit_list_insert(old_commit, &old_commit_list); @@ -749,7 +749,7 @@ int can_all_from_reach_with_flag(struct object_array *from, } list[nr_commits] = (struct commit *)from_one; - if (parse_commit(list[nr_commits]) || + if (repo_parse_commit(the_repository, list[nr_commits]) || commit_graph_generation(list[nr_commits]) < min_generation) { result = 0; goto cleanup; @@ -784,7 +784,7 @@ int can_all_from_reach_with_flag(struct object_array *from, if (!(parent->item->object.flags & assign_flag)) { parent->item->object.flags |= assign_flag; - if (parse_commit(parent->item) || + if (repo_parse_commit(the_repository, parent->item) || parent->item->date < min_commit_date || commit_graph_generation(parent->item) < min_generation) continue; @@ -826,7 +826,7 @@ int can_all_from_reach(struct commit_list *from, struct commit_list *to, while (from_iter) { add_object_array(&from_iter->item->object, NULL, &from_objs); - if (!parse_commit(from_iter->item)) { + if (!repo_parse_commit(the_repository, from_iter->item)) { timestamp_t generation; if (from_iter->item->date < min_commit_date) min_commit_date = from_iter->item->date; @@ -840,7 +840,7 @@ int can_all_from_reach(struct commit_list *from, struct commit_list *to, } while (to_iter) { - if (!parse_commit(to_iter->item)) { + if (!repo_parse_commit(the_repository, to_iter->item)) { timestamp_t generation; if (to_iter->item->date < min_commit_date) min_commit_date = to_iter->item->date; @@ -890,7 +890,7 @@ struct commit_list *get_reachable_subset(struct commit **from, int nr_from, timestamp_t generation; struct commit *c = *item; - parse_commit(c); + repo_parse_commit(the_repository, c); generation = commit_graph_generation(c); if (generation < min_generation) min_generation = generation; @@ -905,7 +905,7 @@ struct commit_list *get_reachable_subset(struct commit **from, int nr_from, struct commit *c = *item; if (!(c->object.flags & PARENT2)) { c->object.flags |= PARENT2; - parse_commit(c); + repo_parse_commit(the_repository, c); prio_queue_put(&queue, *item); } @@ -924,7 +924,7 @@ struct commit_list *get_reachable_subset(struct commit **from, int nr_from, for (parents = current->parents; parents; parents = parents->next) { struct commit *p = parents->item; - parse_commit(p); + repo_parse_commit(the_repository, p); if (commit_graph_generation(p) < min_generation) continue; diff --git a/commit.c b/commit.c index 62682f5564..6036376d05 100644 --- a/commit.c +++ b/commit.c @@ -83,7 +83,7 @@ struct commit *lookup_commit_reference_by_name(const char *name) if (repo_get_oid_committish(the_repository, name, &oid)) return NULL; commit = lookup_commit_reference(the_repository, &oid); - if (parse_commit(commit)) + if (repo_parse_commit(the_repository, commit)) return NULL; return commit; } @@ -382,7 +382,7 @@ struct tree *repo_get_commit_tree(struct repository *r, struct object_id *get_commit_tree_oid(const struct commit *commit) { - struct tree *tree = get_commit_tree(commit); + struct tree *tree = repo_get_commit_tree(the_repository, commit); return tree ? &tree->object.oid : NULL; } @@ -555,7 +555,7 @@ int repo_parse_commit_gently(struct repository *r, void parse_commit_or_die(struct commit *item) { - if (parse_commit(item)) + if (repo_parse_commit(the_repository, item)) die("unable to parse commit %s", item ? oid_to_hex(&item->object.oid) : "(null)"); } @@ -688,7 +688,7 @@ struct commit *pop_most_recent_commit(struct commit_list **list, while (parents) { struct commit *commit = parents->item; - if (!parse_commit(commit) && !(commit->object.flags & mark)) { + if (!repo_parse_commit(the_repository, commit) && !(commit->object.flags & mark)) { commit->object.flags |= mark; commit_list_insert_by_date(commit, list); } @@ -762,7 +762,8 @@ define_commit_slab(author_date_slab, timestamp_t); void record_author_date(struct author_date_slab *author_date, struct commit *commit) { - const char *buffer = get_commit_buffer(commit, NULL); + const char *buffer = repo_get_commit_buffer(the_repository, commit, + NULL); struct ident_split ident; const char *ident_line; size_t ident_len; @@ -782,7 +783,7 @@ void record_author_date(struct author_date_slab *author_date, *(author_date_slab_at(author_date, commit)) = date; fail_exit: - unuse_commit_buffer(commit, buffer); + repo_unuse_commit_buffer(the_repository, commit, buffer); } 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) commit = lookup_commit(the_repository, oid); if (!commit || (commit->object.flags & TMP_MARK) || - parse_commit(commit)) + repo_parse_commit(the_repository, commit)) return; ALLOC_GROW(revs->commit, revs->nr + 1, revs->alloc); @@ -1096,10 +1097,11 @@ int parse_signed_commit(const struct commit *commit, const struct git_hash_algo *algop) { unsigned long size; - const char *buffer = get_commit_buffer(commit, &size); + const char *buffer = repo_get_commit_buffer(the_repository, commit, + &size); int ret = parse_buffer_signed_by_header(buffer, size, payload, signature, algop); - unuse_commit_buffer(commit, buffer); + repo_unuse_commit_buffer(the_repository, commit, buffer); return ret; } @@ -1318,9 +1320,10 @@ struct commit_extra_header *read_commit_extra_headers(struct commit *commit, { struct commit_extra_header *extra = NULL; unsigned long size; - const char *buffer = get_commit_buffer(commit, &size); + const char *buffer = repo_get_commit_buffer(the_repository, commit, + &size); extra = read_commit_extra_header_lines(buffer, size, exclude); - unuse_commit_buffer(commit, buffer); + repo_unuse_commit_buffer(the_repository, commit, buffer); return extra; } diff --git a/commit.h b/commit.h index cc2c5da7bd..e98ee6e698 100644 --- a/commit.h +++ b/commit.h @@ -109,11 +109,6 @@ static inline int repo_parse_commit_no_graph(struct repository *r, return repo_parse_commit_internal(r, commit, 0, 0); } -#ifndef NO_THE_REPOSITORY_COMPATIBILITY_MACROS -#define parse_commit_internal(item, quiet, use) repo_parse_commit_internal(the_repository, item, quiet, use) -#define parse_commit(item) repo_parse_commit(the_repository, item) -#endif - void parse_commit_or_die(struct commit *item); struct buffer_slab; @@ -140,9 +135,6 @@ const void *get_cached_commit_buffer(struct repository *, const struct commit *, const void *repo_get_commit_buffer(struct repository *r, const struct commit *, unsigned long *size); -#ifndef NO_THE_REPOSITORY_COMPATIBILITY_MACROS -#define get_commit_buffer(c, s) repo_get_commit_buffer(the_repository, c, s) -#endif /* * 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, void repo_unuse_commit_buffer(struct repository *r, const struct commit *, const void *buffer); -#ifndef NO_THE_REPOSITORY_COMPATIBILITY_MACROS -#define unuse_commit_buffer(c, b) repo_unuse_commit_buffer(the_repository, c, b) -#endif /* * Free any cached object buffer associated with the commit. @@ -163,7 +152,6 @@ void repo_unuse_commit_buffer(struct repository *r, void free_commit_buffer(struct parsed_object_pool *pool, struct commit *); struct tree *repo_get_commit_tree(struct repository *, const struct commit *); -#define get_commit_tree(c) repo_get_commit_tree(the_repository, c) struct object_id *get_commit_tree_oid(const struct commit *); /* @@ -206,16 +194,10 @@ void free_commit_list(struct commit_list *list); struct rev_info; /* in revision.h, it circularly uses enum cmit_fmt */ int has_non_ascii(const char *text); -const char *logmsg_reencode(const struct commit *commit, - char **commit_encoding, - const char *output_encoding); const char *repo_logmsg_reencode(struct repository *r, const struct commit *commit, char **commit_encoding, const char *output_encoding); -#ifndef NO_THE_REPOSITORY_COMPATIBILITY_MACROS -#define logmsg_reencode(c, enc, out) repo_logmsg_reencode(the_repository, c, enc, out) -#endif const char *skip_blank_lines(const char *msg); diff --git a/contrib/coccinelle/the_repository.cocci b/contrib/coccinelle/the_repository.cocci index 1ab63f0196..0cdf3f4630 100644 --- a/contrib/coccinelle/the_repository.cocci +++ b/contrib/coccinelle/the_repository.cocci @@ -54,6 +54,25 @@ | - in_merge_bases_many + repo_in_merge_bases_many +// commit.h +| +- parse_commit_internal ++ repo_parse_commit_internal +| +- parse_commit ++ repo_parse_commit +| +- get_commit_buffer ++ repo_get_commit_buffer +| +- unuse_commit_buffer ++ repo_unuse_commit_buffer +| +- logmsg_reencode ++ repo_logmsg_reencode +| +- get_commit_tree ++ repo_get_commit_tree ) ( + the_repository, diff --git a/contrib/coccinelle/the_repository.pending.cocci b/contrib/coccinelle/the_repository.pending.cocci index e9209fc0cc..bf19e6a248 100644 --- a/contrib/coccinelle/the_repository.pending.cocci +++ b/contrib/coccinelle/the_repository.pending.cocci @@ -5,26 +5,7 @@ @@ @@ ( -// commit.h -- parse_commit_internal -+ repo_parse_commit_internal -| -- parse_commit -+ repo_parse_commit -| -- get_commit_buffer -+ repo_get_commit_buffer -| -- unuse_commit_buffer -+ repo_unuse_commit_buffer -| -- logmsg_reencode -+ repo_logmsg_reencode -| -- get_commit_tree -+ repo_get_commit_tree // diff.h -| - diff_setup + repo_diff_setup // object-store.h diff --git a/delta-islands.c b/delta-islands.c index afdec0a878..05448851ad 100644 --- a/delta-islands.c +++ b/delta-islands.c @@ -506,8 +506,9 @@ void propagate_island_marks(struct commit *commit) struct commit_list *p; struct island_bitmap *root_marks = kh_value(island_marks, pos); - parse_commit(commit); - set_island_marks(&get_commit_tree(commit)->object, root_marks); + repo_parse_commit(the_repository, commit); + set_island_marks(&repo_get_commit_tree(the_repository, commit)->object, + root_marks); for (p = commit->parents; p; p = p->next) set_island_marks(&p->item->object, root_marks); } diff --git a/fmt-merge-msg.c b/fmt-merge-msg.c index e8e2d4ea0d..a5de91ba22 100644 --- a/fmt-merge-msg.c +++ b/fmt-merge-msg.c @@ -271,9 +271,10 @@ static void record_person_from_buf(int which, struct string_list *people, static void record_person(int which, struct string_list *people, struct commit *commit) { - const char *buffer = get_commit_buffer(commit, NULL); + const char *buffer = repo_get_commit_buffer(the_repository, commit, + NULL); record_person_from_buf(which, people, buffer); - unuse_commit_buffer(commit, buffer); + repo_unuse_commit_buffer(the_repository, commit, buffer); } static int cmp_string_list_util_as_integral(const void *a_, const void *b_) diff --git a/fsck.c b/fsck.c index 2b18717ee8..807a84971a 100644 --- a/fsck.c +++ b/fsck.c @@ -353,7 +353,7 @@ static int fsck_walk_commit(struct commit *commit, void *data, struct fsck_optio int result; const char *name; - if (parse_commit(commit)) + if (repo_parse_commit(the_repository, commit)) return -1; 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 fsck_put_object_name(options, get_commit_tree_oid(commit), "%s:", name); - result = options->walk((struct object *)get_commit_tree(commit), + result = options->walk((struct object *) repo_get_commit_tree(the_repository, commit), OBJ_TREE, data, options); if (result < 0) return result; diff --git a/http-push.c b/http-push.c index ceab00bd90..45d5cc0972 100644 --- a/http-push.c +++ b/http-push.c @@ -1331,7 +1331,8 @@ static int get_delta(struct rev_info *revs, struct remote_lock *lock) int count = 0; while ((commit = get_revision(revs)) != NULL) { - p = process_tree(get_commit_tree(commit), p); + p = process_tree(repo_get_commit_tree(the_repository, commit), + p); commit->object.flags |= LOCAL; if (!(commit->object.flags & UNINTERESTING)) count += add_send_request(&commit->object, lock); diff --git a/list-objects.c b/list-objects.c index 7528fe1db2..5550b3aafe 100644 --- a/list-objects.c +++ b/list-objects.c @@ -227,7 +227,8 @@ static void mark_edge_parents_uninteresting(struct commit *commit, struct commit *parent = parents->item; if (!(parent->object.flags & UNINTERESTING)) continue; - mark_tree_uninteresting(revs->repo, get_commit_tree(parent)); + mark_tree_uninteresting(revs->repo, + repo_get_commit_tree(the_repository, parent)); if (revs->edge_hint && !(parent->object.flags & SHOWN)) { parent->object.flags |= SHOWN; show_edge(parent); @@ -244,7 +245,8 @@ static void add_edge_parents(struct commit *commit, for (parents = commit->parents; parents; parents = parents->next) { struct commit *parent = parents->item; - struct tree *tree = get_commit_tree(parent); + struct tree *tree = repo_get_commit_tree(the_repository, + parent); if (!tree) continue; @@ -275,7 +277,8 @@ void mark_edges_uninteresting(struct rev_info *revs, for (list = revs->commits; list; list = list->next) { struct commit *commit = list->item; - struct tree *tree = get_commit_tree(commit); + struct tree *tree = repo_get_commit_tree(the_repository, + commit); if (commit->object.flags & UNINTERESTING) tree->object.flags |= UNINTERESTING; @@ -291,7 +294,7 @@ void mark_edges_uninteresting(struct rev_info *revs, struct commit *commit = list->item; if (commit->object.flags & UNINTERESTING) { mark_tree_uninteresting(revs->repo, - get_commit_tree(commit)); + repo_get_commit_tree(the_repository, commit)); if (revs->edge_hint_aggressive && !(commit->object.flags & SHOWN)) { commit->object.flags |= SHOWN; show_edge(commit); @@ -309,7 +312,7 @@ void mark_edges_uninteresting(struct rev_info *revs, if (obj->type != OBJ_COMMIT || !(obj->flags & UNINTERESTING)) continue; mark_tree_uninteresting(revs->repo, - get_commit_tree(commit)); + repo_get_commit_tree(the_repository, commit)); if (!(obj->flags & SHOWN)) { obj->flags |= SHOWN; show_edge(commit); @@ -376,8 +379,9 @@ static void do_traverse(struct traversal_context *ctx) */ if (!ctx->revs->tree_objects) ; /* do not bother loading tree */ - else if (get_commit_tree(commit)) { - struct tree *tree = get_commit_tree(commit); + else if (repo_get_commit_tree(the_repository, commit)) { + struct tree *tree = repo_get_commit_tree(the_repository, + commit); tree->object.flags |= NOT_USER_GIVEN; add_pending_tree(ctx->revs, tree); } else if (commit->object.parsed) { diff --git a/merge-recursive.c b/merge-recursive.c index 9771ef540c..75fa0ef318 100644 --- a/merge-recursive.c +++ b/merge-recursive.c @@ -3797,7 +3797,7 @@ static struct commit *get_ref(struct repository *repo, return make_virtual_commit(repo, (struct tree*)object, name); if (object->type != OBJ_COMMIT) return NULL; - if (parse_commit((struct commit *)object)) + if (repo_parse_commit(the_repository, (struct commit *)object)) return NULL; return (struct commit *)object; } diff --git a/negotiator/default.c b/negotiator/default.c index b7e79feaf0..658d9dd6b9 100644 --- a/negotiator/default.c +++ b/negotiator/default.c @@ -25,7 +25,7 @@ static void rev_list_push(struct negotiation_state *ns, if (!(commit->object.flags & mark)) { commit->object.flags |= mark; - if (parse_commit(commit)) + if (repo_parse_commit(the_repository, commit)) return; prio_queue_put(&ns->rev_list, commit); @@ -69,7 +69,7 @@ static void mark_common(struct negotiation_state *ns, struct commit *commit, if (!ancestors_only && !(o->flags & POPPED)) ns->non_common_revs--; if (!o->parsed && !dont_parse) - if (parse_commit(commit)) + if (repo_parse_commit(the_repository, commit)) return; for (parents = commit->parents; @@ -96,7 +96,7 @@ static const struct object_id *get_rev(struct negotiation_state *ns) return NULL; commit = prio_queue_get(&ns->rev_list); - parse_commit(commit); + repo_parse_commit(the_repository, commit); parents = commit->parents; commit->object.flags |= POPPED; diff --git a/negotiator/skipping.c b/negotiator/skipping.c index 0f5ac48e87..594639b25a 100644 --- a/negotiator/skipping.c +++ b/negotiator/skipping.c @@ -183,7 +183,7 @@ static const struct object_id *get_rev(struct data *data) if (!(commit->object.flags & COMMON) && !entry->ttl) to_send = commit; - parse_commit(commit); + repo_parse_commit(the_repository, commit); for (p = commit->parents; p; p = p->next) parent_pushed |= push_parent(data, entry, p->item); diff --git a/notes-merge.c b/notes-merge.c index fca9422a29..df1a16ac66 100644 --- a/notes-merge.c +++ b/notes-merge.c @@ -678,7 +678,8 @@ int notes_merge_commit(struct notes_merge_options *o, DIR *dir; struct dirent *e; struct strbuf path = STRBUF_INIT; - const char *buffer = get_commit_buffer(partial_commit, NULL); + const char *buffer = repo_get_commit_buffer(the_repository, + partial_commit, NULL); const char *msg = strstr(buffer, "\n\n"); int baselen; @@ -725,7 +726,7 @@ int notes_merge_commit(struct notes_merge_options *o, create_notes_commit(o->repo, partial_tree, partial_commit->parents, msg, strlen(msg), result_oid); - unuse_commit_buffer(partial_commit, buffer); + repo_unuse_commit_buffer(the_repository, partial_commit, buffer); if (o->verbosity >= 4) printf("Finalized notes merge commit: %s\n", oid_to_hex(result_oid)); diff --git a/notes-utils.c b/notes-utils.c index d7d18e30f5..0550cfded8 100644 --- a/notes-utils.c +++ b/notes-utils.c @@ -23,7 +23,7 @@ void create_notes_commit(struct repository *r, struct object_id parent_oid; if (!read_ref(t->ref, &parent_oid)) { struct commit *parent = lookup_commit(r, &parent_oid); - if (parse_commit(parent)) + if (repo_parse_commit(the_repository, parent)) die("Failed to find/parse commit %s", t->ref); commit_list_insert(parent, &parents); } diff --git a/object-name.c b/object-name.c index 21e8f67489..2926f26251 100644 --- a/object-name.c +++ b/object-name.c @@ -1036,7 +1036,7 @@ static enum get_oid_result get_parent(struct repository *r, if (ret) return ret; commit = lookup_commit_reference(r, &oid); - if (parse_commit(commit)) + if (repo_parse_commit(the_repository, commit)) return MISSING_OBJECT; if (!idx) { oidcpy(result, &commit->object.oid); @@ -1070,7 +1070,7 @@ static enum get_oid_result get_nth_ancestor(struct repository *r, return MISSING_OBJECT; while (generation--) { - if (parse_commit(commit) || !commit->parents) + if (repo_parse_commit(the_repository, commit) || !commit->parents) return MISSING_OBJECT; commit = commit->parents->item; } @@ -1361,10 +1361,10 @@ static int get_oid_oneline(struct repository *r, commit = pop_most_recent_commit(&list, ONELINE_SEEN); if (!parse_object(r, &commit->object.oid)) continue; - buf = get_commit_buffer(commit, NULL); + buf = repo_get_commit_buffer(the_repository, commit, NULL); p = strstr(buf, "\n\n"); matches = negative ^ (p && !regexec(®ex, p + 2, 0, NULL, 0)); - unuse_commit_buffer(commit, buf); + repo_unuse_commit_buffer(the_repository, commit, buf); if (matches) { oidcpy(oid, &commit->object.oid); diff --git a/pack-bitmap-write.c b/pack-bitmap-write.c index cfa67a510f..84b6132893 100644 --- a/pack-bitmap-write.c +++ b/pack-bitmap-write.c @@ -425,7 +425,8 @@ static int fill_bitmap_commit(struct bb_commit *ent, if (!found) return -1; bitmap_set(ent->bitmap, pos); - prio_queue_put(tree_queue, get_commit_tree(c)); + prio_queue_put(tree_queue, + repo_get_commit_tree(the_repository, c)); for (p = c->parents; p; p = p->next) { pos = find_object_pos(&p->item->object.oid, &found); diff --git a/pretty.c b/pretty.c index 1e1e21878c..7e1614f67f 100644 --- a/pretty.c +++ b/pretty.c @@ -2204,7 +2204,8 @@ void pretty_print_commit(struct pretty_print_context *pp, } encoding = get_log_output_encoding(); - msg = reencoded = logmsg_reencode(commit, NULL, encoding); + msg = reencoded = repo_logmsg_reencode(the_repository, commit, NULL, + encoding); if (pp->fmt == CMIT_FMT_ONELINE || cmit_fmt_is_mail(pp->fmt)) indent = 0; @@ -2261,7 +2262,7 @@ void pretty_print_commit(struct pretty_print_context *pp, if (cmit_fmt_is_mail(pp->fmt) && sb->len <= beginning_of_body) strbuf_addch(sb, '\n'); - unuse_commit_buffer(commit, reencoded); + repo_unuse_commit_buffer(the_repository, commit, reencoded); } void pp_commit_easy(enum cmit_fmt fmt, const struct commit *commit, diff --git a/reflog.c b/reflog.c index 04630f56ec..6e8362e7a2 100644 --- a/reflog.c +++ b/reflog.c @@ -186,7 +186,7 @@ static void mark_reachable(struct expire_reflog_policy_cb *cb) struct commit *commit = pop_commit(&pending); if (commit->object.flags & REACHABLE) continue; - if (parse_commit(commit)) + if (repo_parse_commit(the_repository, commit)) continue; commit->object.flags |= REACHABLE; if (commit->date < expire_limit) { diff --git a/revision.c b/revision.c index c2b7b2f107..79e78b6f7e 100644 --- a/revision.c +++ b/revision.c @@ -778,8 +778,8 @@ static int check_maybe_different_in_bloom_filter(struct rev_info *revs, static int rev_compare_tree(struct rev_info *revs, struct commit *parent, struct commit *commit, int nth_parent) { - struct tree *t1 = get_commit_tree(parent); - struct tree *t2 = get_commit_tree(commit); + struct tree *t1 = repo_get_commit_tree(the_repository, parent); + struct tree *t2 = repo_get_commit_tree(the_repository, commit); int bloom_ret = 1; if (!t1) @@ -825,7 +825,7 @@ static int rev_compare_tree(struct rev_info *revs, static int rev_same_tree_as_empty(struct rev_info *revs, struct commit *commit) { - struct tree *t1 = get_commit_tree(commit); + struct tree *t1 = repo_get_commit_tree(the_repository, commit); if (!t1) return 0; @@ -963,7 +963,7 @@ static void try_to_simplify_commit(struct rev_info *revs, struct commit *commit) if (!revs->prune) return; - if (!get_commit_tree(commit)) + if (!repo_get_commit_tree(the_repository, commit)) return; if (!commit->parents) { @@ -3878,7 +3878,7 @@ static int commit_match(struct commit *commit, struct rev_info *opt) * in it. */ encoding = get_log_output_encoding(); - message = logmsg_reencode(commit, NULL, encoding); + message = repo_logmsg_reencode(the_repository, commit, NULL, encoding); /* Copy the commit to temporary if we are using "fake" headers */ if (buf.len) @@ -3914,7 +3914,7 @@ static int commit_match(struct commit *commit, struct rev_info *opt) retval = grep_buffer(&opt->grep_filter, (char *)message, strlen(message)); strbuf_release(&buf); - unuse_commit_buffer(commit, message); + repo_unuse_commit_buffer(the_repository, commit, message); return retval; } diff --git a/sequencer.c b/sequencer.c index d97923883f..592b3d2875 100644 --- a/sequencer.c +++ b/sequencer.c @@ -428,7 +428,8 @@ static int get_message(struct commit *commit, struct commit_message *out) const char *abbrev, *subject; int subject_len; - out->message = logmsg_reencode(commit, NULL, get_commit_output_encoding()); + out->message = repo_logmsg_reencode(the_repository, commit, NULL, + get_commit_output_encoding()); abbrev = short_commit_name(commit); subject_len = find_commit_subject(out->message, &subject); @@ -445,7 +446,7 @@ static void free_message(struct commit *commit, struct commit_message *msg) free(msg->parent_label); free(msg->label); free(msg->subject); - unuse_commit_buffer(commit, msg->message); + repo_unuse_commit_buffer(the_repository, commit, msg->message); } static void print_advice(struct repository *r, int show_hint, @@ -693,8 +694,8 @@ static int do_recursive_merge(struct repository *r, o.show_rename_progress = 1; head_tree = parse_tree_indirect(head); - next_tree = next ? get_commit_tree(next) : empty_tree(r); - base_tree = base ? get_commit_tree(base) : empty_tree(r); + next_tree = next ? repo_get_commit_tree(the_repository, next) : empty_tree(r); + base_tree = base ? repo_get_commit_tree(the_repository, base) : empty_tree(r); for (i = 0; i < opts->xopts_nr; i++) parse_merge_opt(&o, opts->xopts[i]); @@ -772,7 +773,7 @@ static int is_index_unchanged(struct repository *r) * the commit is invalid, parse_commit() will complain. So * there is nothing for us to say here. Just return failure. */ - if (parse_commit(head_commit)) + if (repo_parse_commit(the_repository, head_commit)) return -1; if (!(cache_tree_oid = get_cache_tree_oid(istate))) @@ -1337,7 +1338,7 @@ void print_commit_summary(struct repository *r, commit = lookup_commit(r, oid); if (!commit) die(_("couldn't look up newly created commit")); - if (parse_commit(commit)) + if (repo_parse_commit(the_repository, commit)) die(_("could not parse newly created commit")); strbuf_addstr(&format, "format:%h] %s"); @@ -1417,7 +1418,7 @@ static int parse_head(struct repository *r, struct commit **head) warning(_("HEAD %s is not a commit!"), oid_to_hex(&oid)); } - if (parse_commit(current_head)) + if (repo_parse_commit(the_repository, current_head)) return error(_("could not parse HEAD commit")); } *head = current_head; @@ -1460,8 +1461,9 @@ static int try_to_commit(struct repository *r, if (flags & AMEND_MSG) { const char *exclude_gpgsig[] = { "gpgsig", "gpgsig-sha256", NULL }; const char *out_enc = get_commit_output_encoding(); - const char *message = logmsg_reencode(current_head, NULL, - out_enc); + const char *message = repo_logmsg_reencode(the_repository, + current_head, NULL, + out_enc); if (!msg) { const char *orig_message = NULL; @@ -1472,7 +1474,8 @@ static int try_to_commit(struct repository *r, hook_commit = "HEAD"; } author = amend_author = get_author(message); - unuse_commit_buffer(current_head, message); + repo_unuse_commit_buffer(the_repository, current_head, + message); if (!author) { res = error(_("unable to parse commit author")); goto out; @@ -1669,12 +1672,12 @@ static int is_original_commit_empty(struct commit *commit) { const struct object_id *ptree_oid; - if (parse_commit(commit)) + if (repo_parse_commit(the_repository, commit)) return error(_("could not parse commit %s"), oid_to_hex(&commit->object.oid)); if (commit->parents) { struct commit *parent = commit->parents->item; - if (parse_commit(parent)) + if (repo_parse_commit(the_repository, parent)) return error(_("could not parse parent commit %s"), oid_to_hex(&parent->object.oid)); ptree_oid = get_commit_tree_oid(parent); @@ -2002,13 +2005,14 @@ static int update_squash_messages(struct repository *r, return error(_("need a HEAD to fixup")); if (!(head_commit = lookup_commit_reference(r, &head))) return error(_("could not read HEAD")); - if (!(head_message = logmsg_reencode(head_commit, NULL, encoding))) + if (!(head_message = repo_logmsg_reencode(the_repository, head_commit, NULL, encoding))) return error(_("could not read HEAD's commit message")); find_commit_subject(head_message, &body); if (command == TODO_FIXUP && !flag && write_message(body, strlen(body), rebase_path_fixup_msg(), 0) < 0) { - unuse_commit_buffer(head_commit, head_message); + repo_unuse_commit_buffer(the_repository, head_commit, + head_message); return error(_("cannot write '%s'"), rebase_path_fixup_msg()); } strbuf_addf(&buf, "%c ", comment_line_char); @@ -2023,10 +2027,11 @@ static int update_squash_messages(struct repository *r, else strbuf_addstr(&buf, body); - unuse_commit_buffer(head_commit, head_message); + repo_unuse_commit_buffer(the_repository, head_commit, + head_message); } - if (!(message = logmsg_reencode(commit, NULL, encoding))) + if (!(message = repo_logmsg_reencode(the_repository, commit, NULL, encoding))) return error(_("could not read commit message of %s"), oid_to_hex(&commit->object.oid)); find_commit_subject(message, &body); @@ -2041,7 +2046,7 @@ static int update_squash_messages(struct repository *r, strbuf_add_commented_lines(&buf, body, strlen(body)); } else return error(_("unknown command: %d"), command); - unuse_commit_buffer(commit, message); + repo_unuse_commit_buffer(the_repository, commit, message); if (!res) res = write_message(buf.buf, buf.len, rebase_path_squash_msg(), @@ -2215,7 +2220,7 @@ static int do_pick_commit(struct repository *r, msg_file = NULL; goto fast_forward_edit; } - if (parent && parse_commit(parent) < 0) + if (parent && repo_parse_commit(the_repository, parent) < 0) /* TRANSLATORS: The first %s will be a "todo" command like "revert" or "pick", the second %s a SHA1. */ return error(_("%s: cannot parse parent commit %s"), @@ -3123,7 +3128,9 @@ static int walk_revs_populate_todo(struct todo_list *todo_list, while ((commit = get_revision(opts->revs))) { struct todo_item *item = append_new_todo(todo_list); - const char *commit_buffer = logmsg_reencode(commit, NULL, encoding); + const char *commit_buffer = repo_logmsg_reencode(the_repository, + commit, NULL, + encoding); const char *subject; int subject_len; @@ -3135,7 +3142,8 @@ static int walk_revs_populate_todo(struct todo_list *todo_list, subject_len = find_commit_subject(commit_buffer, &subject); strbuf_addf(&todo_list->buf, "%s %s %.*s\n", command_string, short_commit_name(commit), subject_len, subject); - unuse_commit_buffer(commit, commit_buffer); + repo_unuse_commit_buffer(the_repository, commit, + commit_buffer); } if (!todo_list->nr) @@ -3519,10 +3527,13 @@ static int make_patch(struct repository *r, strbuf_addf(&buf, "%s/message", get_dir(opts)); if (!file_exists(buf.buf)) { const char *encoding = get_commit_output_encoding(); - const char *commit_buffer = logmsg_reencode(commit, NULL, encoding); + const char *commit_buffer = repo_logmsg_reencode(the_repository, + commit, NULL, + encoding); find_commit_subject(commit_buffer, &subject); res |= write_message(subject, strlen(subject), buf.buf, 1); - unuse_commit_buffer(commit, commit_buffer); + repo_unuse_commit_buffer(the_repository, commit, + commit_buffer); } strbuf_release(&buf); release_revisions(&log_tree_opt); @@ -3989,7 +4000,9 @@ static int do_merge(struct repository *r, if (commit) { const char *encoding = get_commit_output_encoding(); - const char *message = logmsg_reencode(commit, NULL, encoding); + const char *message = repo_logmsg_reencode(the_repository, + commit, NULL, + encoding); const char *body; int len; @@ -4002,7 +4015,7 @@ static int do_merge(struct repository *r, find_commit_subject(message, &body); len = strlen(body); ret = write_message(body, len, git_path_merge_msg(r), 0); - unuse_commit_buffer(commit, message); + repo_unuse_commit_buffer(the_repository, commit, message); if (ret) { error_errno(_("could not write '%s'"), git_path_merge_msg(r)); @@ -4585,7 +4598,7 @@ static int stopped_at_head(struct repository *r) if (repo_get_oid(the_repository, "HEAD", &head) || !(commit = lookup_commit(r, &head)) || - parse_commit(commit) || get_message(commit, &message)) + repo_parse_commit(the_repository, commit) || get_message(commit, &message)) fprintf(stderr, _("Stopped at HEAD\n")); else { fprintf(stderr, _("Stopped at %s\n"), message.label); @@ -5042,13 +5055,15 @@ static int commit_staged_changes(struct repository *r, const char *encoding = get_commit_output_encoding(); if (parse_head(r, &commit) || - !(p = logmsg_reencode(commit, NULL, encoding)) || + !(p = repo_logmsg_reencode(the_repository, commit, NULL, encoding)) || write_message(p, strlen(p), path, 0)) { - unuse_commit_buffer(commit, p); + repo_unuse_commit_buffer(the_repository, + commit, p); return error(_("could not write file: " "'%s'"), path); } - unuse_commit_buffer(commit, p); + repo_unuse_commit_buffer(the_repository, + commit, p); } } @@ -5925,7 +5940,7 @@ static int skip_unnecessary_picks(struct repository *r, continue; if (item->command != TODO_PICK) break; - if (parse_commit(item->commit)) { + if (repo_parse_commit(the_repository, item->commit)) { return error(_("could not parse commit '%s'"), oid_to_hex(&item->commit->object.oid)); } @@ -6258,12 +6273,15 @@ int todo_list_rearrange_squash(struct todo_list *todo_list) return error(_("the script was already rearranged.")); } - parse_commit(item->commit); - commit_buffer = logmsg_reencode(item->commit, NULL, "UTF-8"); + repo_parse_commit(the_repository, item->commit); + commit_buffer = repo_logmsg_reencode(the_repository, + item->commit, NULL, + "UTF-8"); find_commit_subject(commit_buffer, &subject); format_subject(&buf, subject, " "); subject = subjects[i] = strbuf_detach(&buf, &subject_len); - unuse_commit_buffer(item->commit, commit_buffer); + repo_unuse_commit_buffer(the_repository, item->commit, + commit_buffer); if (skip_fixupish(subject, &p)) { struct commit *commit2; diff --git a/shallow.c b/shallow.c index 0fcdfd7d35..1a2b159fd4 100644 --- a/shallow.c +++ b/shallow.c @@ -247,7 +247,7 @@ struct commit_list *get_shallow_commits_by_rev_list(int ac, const char **av, struct commit *c = p->item; struct commit_list *parent; - if (parse_commit(c)) + if (repo_parse_commit(the_repository, c)) die("unable to parse commit %s", oid_to_hex(&c->object.oid)); @@ -583,7 +583,7 @@ static void paint_down(struct paint_info *info, const struct object_id *oid, if (c->object.flags & BOTTOM) continue; - if (parse_commit(c)) + if (repo_parse_commit(the_repository, c)) die("unable to parse commit %s", oid_to_hex(&c->object.oid)); diff --git a/t/helper/test-fast-rebase.c b/t/helper/test-fast-rebase.c index 5d1284328d..214612846a 100644 --- a/t/helper/test-fast-rebase.c +++ b/t/helper/test-fast-rebase.c @@ -65,7 +65,8 @@ static struct commit *create_commit(struct tree *tree, struct commit_extra_header *extra; struct strbuf msg = STRBUF_INIT; const char *out_enc = get_commit_output_encoding(); - const char *message = logmsg_reencode(based_on, NULL, out_enc); + const char *message = repo_logmsg_reencode(the_repository, based_on, + NULL, out_enc); const char *orig_message = NULL; const char *exclude_gpgsig[] = { "gpgsig", NULL }; @@ -156,7 +157,7 @@ int cmd__fast_rebase(int argc, const char **argv) memset(&result, 0, sizeof(result)); merge_opt.show_rename_progress = 1; merge_opt.branch1 = "HEAD"; - head_tree = get_commit_tree(onto); + head_tree = repo_get_commit_tree(the_repository, onto); result.tree = head_tree; last_commit = onto; while ((commit = get_revision(&revs))) { @@ -167,8 +168,8 @@ int cmd__fast_rebase(int argc, const char **argv) assert(commit->parents && !commit->parents->next); base = commit->parents->item; - next_tree = get_commit_tree(commit); - base_tree = get_commit_tree(base); + next_tree = repo_get_commit_tree(the_repository, commit); + base_tree = repo_get_commit_tree(the_repository, base); merge_opt.branch2 = short_commit_name(commit); merge_opt.ancestor = xstrfmt("parent of %s", merge_opt.branch2); diff --git a/tree.c b/tree.c index 410e3b477e..f0742f4167 100644 --- a/tree.c +++ b/tree.c @@ -58,7 +58,7 @@ int read_tree_at(struct repository *r, oid_to_hex(&entry.oid), base->buf, entry.path); - if (parse_commit(commit)) + if (repo_parse_commit(the_repository, commit)) die("Invalid commit %s in submodule path %s%s", oid_to_hex(&entry.oid), base->buf, entry.path); diff --git a/walker.c b/walker.c index 99d0e0eae0..98d65a559b 100644 --- a/walker.c +++ b/walker.c @@ -79,7 +79,7 @@ static int process_commit(struct walker *walker, struct commit *commit) { struct commit_list *parents; - if (parse_commit(commit)) + if (repo_parse_commit(the_repository, commit)) return -1; while (complete && complete->item->date >= commit->date) { @@ -93,7 +93,7 @@ static int process_commit(struct walker *walker, struct commit *commit) walker_say(walker, "walk %s\n", oid_to_hex(&commit->object.oid)); - if (process(walker, &get_commit_tree(commit)->object)) + if (process(walker, &repo_get_commit_tree(the_repository, commit)->object)) return -1; for (parents = commit->parents; parents; parents = parents->next) { -- cgit v1.2.3 From bc726bd075929aab6b3e09d4dd5c2b0726fd5350 Mon Sep 17 00:00:00 2001 From: Ævar Arnfjörð Bjarmason Date: Tue, 28 Mar 2023 15:58:50 +0200 Subject: cocci: apply the "object-store.h" part of "the_repository.pending" MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Apply the part of "the_repository.pending.cocci" pertaining to "object-store.h". Signed-off-by: Ævar Arnfjörð Bjarmason Signed-off-by: Junio C Hamano --- apply.c | 9 ++++++--- archive.c | 2 +- bisect.c | 5 +++-- blame.c | 11 +++++++---- builtin/cat-file.c | 23 ++++++++++++++--------- builtin/clone.c | 6 +++--- builtin/difftool.c | 3 ++- builtin/fast-export.c | 5 +++-- builtin/fast-import.c | 7 ++++--- builtin/fetch.c | 12 ++++++------ builtin/grep.c | 6 ++++-- builtin/index-pack.c | 9 ++++++--- builtin/log.c | 2 +- builtin/merge-tree.c | 9 ++++++--- builtin/mktag.c | 3 ++- builtin/notes.c | 7 ++++--- builtin/pack-objects.c | 22 +++++++++++++++------- builtin/receive-pack.c | 2 +- builtin/remote.c | 2 +- builtin/show-ref.c | 2 +- builtin/tag.c | 4 ++-- builtin/unpack-file.c | 2 +- builtin/unpack-objects.c | 5 +++-- bulk-checkin.c | 2 +- bundle.c | 2 +- cache-tree.c | 8 ++++---- combine-diff.c | 2 +- commit.c | 3 ++- contrib/coccinelle/the_repository.cocci | 10 ++++++++++ contrib/coccinelle/the_repository.pending.cocci | 10 ---------- dir.c | 2 +- entry.c | 3 ++- fetch-pack.c | 8 ++++---- fmt-merge-msg.c | 3 ++- fsck.c | 2 +- http-push.c | 11 ++++++----- http-walker.c | 4 ++-- list-objects.c | 2 +- mailmap.c | 2 +- match-trees.c | 4 ++-- merge-blobs.c | 6 ++++-- merge-ort.c | 2 +- merge-recursive.c | 5 +++-- notes-cache.c | 2 +- notes-merge.c | 2 +- notes.c | 12 +++++++----- object-file.c | 2 +- object-store.h | 7 ------- read-cache.c | 5 +++-- reflog.c | 5 +++-- remote.c | 2 +- rerere.c | 5 +++-- send-pack.c | 6 +++--- shallow.c | 6 +++--- submodule-config.c | 3 ++- tag.c | 5 +++-- tree.c | 3 ++- upload-pack.c | 8 ++++---- walker.c | 2 +- xdiff-interface.c | 2 +- 60 files changed, 184 insertions(+), 142 deletions(-) (limited to 'commit.c') diff --git a/apply.c b/apply.c index 57f45cedd2..eb71586a37 100644 --- a/apply.c +++ b/apply.c @@ -3201,7 +3201,8 @@ static int apply_binary(struct apply_state *state, unsigned long size; char *result; - result = read_object_file(&oid, &type, &size); + result = repo_read_object_file(the_repository, &oid, &type, + &size); if (!result) return error(_("the necessary postimage %s for " "'%s' cannot be read"), @@ -3264,7 +3265,8 @@ static int read_blob_object(struct strbuf *buf, const struct object_id *oid, uns unsigned long sz; char *result; - result = read_object_file(oid, &type, &sz); + result = repo_read_object_file(the_repository, oid, &type, + &sz); if (!result) return -1; /* XXX read_sha1_file NUL-terminates */ @@ -3492,7 +3494,8 @@ static int resolve_to(struct image *image, const struct object_id *result_id) clear_image(image); - image->buf = read_object_file(result_id, &type, &size); + image->buf = repo_read_object_file(the_repository, result_id, &type, + &size); if (!image->buf || type != OBJ_BLOB) die("unable to read blob object %s", oid_to_hex(result_id)); image->len = size; diff --git a/archive.c b/archive.c index 732e210054..0b48de0063 100644 --- a/archive.c +++ b/archive.c @@ -84,7 +84,7 @@ static void *object_file_to_archive(const struct archiver_args *args, (args->tree ? &args->tree->object.oid : NULL), oid); path += args->baselen; - buffer = read_object_file(oid, type, sizep); + buffer = repo_read_object_file(the_repository, oid, type, sizep); if (buffer && S_ISREG(mode)) { struct strbuf buf = STRBUF_INIT; size_t size = 0; diff --git a/bisect.c b/bisect.c index 3088516e17..db7aa2032e 100644 --- a/bisect.c +++ b/bisect.c @@ -148,8 +148,9 @@ static void show_list(const char *debug, int counted, int nr, unsigned commit_flags = commit->object.flags; enum object_type type; unsigned long size; - char *buf = read_object_file(&commit->object.oid, &type, - &size); + char *buf = repo_read_object_file(the_repository, + &commit->object.oid, &type, + &size); const char *subject_start; int subject_len; diff --git a/blame.c b/blame.c index af2b67c084..7009a3379c 100644 --- a/blame.c +++ b/blame.c @@ -1028,8 +1028,9 @@ static void fill_origin_blob(struct diff_options *opt, &o->blob_oid, 1, &file->ptr, &file_size)) ; else - file->ptr = read_object_file(&o->blob_oid, &type, - &file_size); + file->ptr = repo_read_object_file(the_repository, + &o->blob_oid, &type, + &file_size); file->size = file_size; if (!file->ptr) @@ -2838,8 +2839,10 @@ void setup_scoreboard(struct blame_scoreboard *sb, &sb->final_buf_size)) ; else - sb->final_buf = read_object_file(&o->blob_oid, &type, - &sb->final_buf_size); + sb->final_buf = repo_read_object_file(the_repository, + &o->blob_oid, + &type, + &sb->final_buf_size); if (!sb->final_buf) die(_("cannot read blob %s for path %s"), diff --git a/builtin/cat-file.c b/builtin/cat-file.c index cc17635e76..caf2d25861 100644 --- a/builtin/cat-file.c +++ b/builtin/cat-file.c @@ -60,7 +60,7 @@ static int filter_object(const char *path, unsigned mode, { enum object_type type; - *buf = read_object_file(oid, &type, size); + *buf = repo_read_object_file(the_repository, oid, &type, size); if (!*buf) return error(_("cannot read object %s '%s'"), oid_to_hex(oid), path); @@ -152,7 +152,7 @@ static int cat_one_file(int opt, const char *exp_type, const char *obj_name, goto cleanup; case 'e': - return !has_object_file(&oid); + return !repo_has_object_file(the_repository, &oid); case 'w': @@ -187,7 +187,8 @@ static int cat_one_file(int opt, const char *exp_type, const char *obj_name, ret = stream_blob(&oid); goto cleanup; } - buf = read_object_file(&oid, &type, &size); + buf = repo_read_object_file(the_repository, &oid, &type, + &size); if (!buf) die("Cannot read object %s", obj_name); @@ -207,8 +208,10 @@ static int cat_one_file(int opt, const char *exp_type, const char *obj_name, if (exp_type_id == OBJ_BLOB) { struct object_id blob_oid; if (oid_object_info(the_repository, &oid, NULL) == OBJ_TAG) { - char *buffer = read_object_file(&oid, &type, - &size); + char *buffer = repo_read_object_file(the_repository, + &oid, + &type, + &size); const char *target; if (!skip_prefix(buffer, "object ", &target) || get_oid_hex(target, &blob_oid)) @@ -383,9 +386,10 @@ static void print_object_or_die(struct batch_options *opt, struct expand_data *d if (!textconv_object(the_repository, data->rest, 0100644, oid, 1, &contents, &size)) - contents = read_object_file(oid, - &type, - &size); + contents = repo_read_object_file(the_repository, + oid, + &type, + &size); if (!contents) die("could not convert '%s' %s", oid_to_hex(oid), data->rest); @@ -402,7 +406,8 @@ static void print_object_or_die(struct batch_options *opt, struct expand_data *d unsigned long size; void *contents; - contents = read_object_file(oid, &type, &size); + contents = repo_read_object_file(the_repository, oid, &type, + &size); if (use_mailmap) { size_t s = size; diff --git a/builtin/clone.c b/builtin/clone.c index 65b5b7db6d..4de4640ed4 100644 --- a/builtin/clone.c +++ b/builtin/clone.c @@ -547,9 +547,9 @@ static void write_followtags(const struct ref *refs, const char *msg) continue; if (ends_with(ref->name, "^{}")) continue; - if (!has_object_file_with_flags(&ref->old_oid, - OBJECT_INFO_QUICK | - OBJECT_INFO_SKIP_FETCH_OBJECT)) + if (!repo_has_object_file_with_flags(the_repository, &ref->old_oid, + OBJECT_INFO_QUICK | + OBJECT_INFO_SKIP_FETCH_OBJECT)) continue; update_ref(msg, ref->name, &ref->old_oid, NULL, 0, UPDATE_REFS_DIE_ON_ERR); diff --git a/builtin/difftool.c b/builtin/difftool.c index dbbfb19f19..30daa83bc6 100644 --- a/builtin/difftool.c +++ b/builtin/difftool.c @@ -295,7 +295,8 @@ static char *get_symlink(const struct object_id *oid, const char *path) } else { enum object_type type; unsigned long size; - data = read_object_file(oid, &type, &size); + data = repo_read_object_file(the_repository, oid, &type, + &size); if (!data) die(_("could not read object %s for symlink %s"), oid_to_hex(oid), path); diff --git a/builtin/fast-export.c b/builtin/fast-export.c index 5fe7c02970..6515bd2ad8 100644 --- a/builtin/fast-export.c +++ b/builtin/fast-export.c @@ -296,7 +296,7 @@ static void export_blob(const struct object_id *oid) object = (struct object *)lookup_blob(the_repository, oid); eaten = 0; } else { - buf = read_object_file(oid, &type, &size); + buf = repo_read_object_file(the_repository, oid, &type, &size); if (!buf) die("could not read blob %s", oid_to_hex(oid)); if (check_object_signature(the_repository, oid, buf, size, @@ -766,7 +766,8 @@ static void handle_tag(const char *name, struct tag *tag) return; } - buf = read_object_file(&tag->object.oid, &type, &size); + buf = repo_read_object_file(the_repository, &tag->object.oid, &type, + &size); if (!buf) die("could not read tag %s", oid_to_hex(&tag->object.oid)); message = memmem(buf, size, "\n\n", 2); diff --git a/builtin/fast-import.c b/builtin/fast-import.c index 2098c0c5a3..2065434178 100644 --- a/builtin/fast-import.c +++ b/builtin/fast-import.c @@ -1265,7 +1265,7 @@ static void load_tree(struct tree_entry *root) die("Can't load tree %s", oid_to_hex(oid)); } else { enum object_type type; - buf = read_object_file(oid, &type, &size); + buf = repo_read_object_file(the_repository, oid, &type, &size); if (!buf || type != OBJ_TREE) die("Can't load tree %s", oid_to_hex(oid)); } @@ -2936,7 +2936,7 @@ static void cat_blob(struct object_entry *oe, struct object_id *oid) char *buf; if (!oe || oe->pack_id == MAX_PACK_ID) { - buf = read_object_file(oid, &type, &size); + buf = repo_read_object_file(the_repository, oid, &type, &size); } else { type = oe->type; buf = gfi_unpack_entry(oe, &size); @@ -3044,7 +3044,8 @@ static struct object_entry *dereference(struct object_entry *oe, buf = gfi_unpack_entry(oe, &size); } else { enum object_type unused; - buf = read_object_file(oid, &unused, &size); + buf = repo_read_object_file(the_repository, oid, &unused, + &size); } if (!buf) die("Can't load object %s", oid_to_hex(oid)); diff --git a/builtin/fetch.c b/builtin/fetch.c index db8815032f..784e344d2b 100644 --- a/builtin/fetch.c +++ b/builtin/fetch.c @@ -407,9 +407,9 @@ static void find_non_local_tags(const struct ref *refs, */ if (ends_with(ref->name, "^{}")) { if (item && - !has_object_file_with_flags(&ref->old_oid, quick_flags) && + !repo_has_object_file_with_flags(the_repository, &ref->old_oid, quick_flags) && !oidset_contains(&fetch_oids, &ref->old_oid) && - !has_object_file_with_flags(&item->oid, quick_flags) && + !repo_has_object_file_with_flags(the_repository, &item->oid, quick_flags) && !oidset_contains(&fetch_oids, &item->oid)) clear_item(item); item = NULL; @@ -423,7 +423,7 @@ static void find_non_local_tags(const struct ref *refs, * fetch. */ if (item && - !has_object_file_with_flags(&item->oid, quick_flags) && + !repo_has_object_file_with_flags(the_repository, &item->oid, quick_flags) && !oidset_contains(&fetch_oids, &item->oid)) clear_item(item); @@ -444,7 +444,7 @@ static void find_non_local_tags(const struct ref *refs, * checked to see if it needs fetching. */ if (item && - !has_object_file_with_flags(&item->oid, quick_flags) && + !repo_has_object_file_with_flags(the_repository, &item->oid, quick_flags) && !oidset_contains(&fetch_oids, &item->oid)) clear_item(item); @@ -1320,8 +1320,8 @@ static int check_exist_and_connected(struct ref *ref_map) * we need all direct targets to exist. */ for (r = rm; r; r = r->next) { - if (!has_object_file_with_flags(&r->old_oid, - OBJECT_INFO_SKIP_FETCH_OBJECT)) + if (!repo_has_object_file_with_flags(the_repository, &r->old_oid, + OBJECT_INFO_SKIP_FETCH_OBJECT)) return -1; } diff --git a/builtin/grep.c b/builtin/grep.c index f7821c5fbb..18561b1002 100644 --- a/builtin/grep.c +++ b/builtin/grep.c @@ -560,7 +560,8 @@ static int grep_cache(struct grep_opt *opt, void *data; unsigned long size; - data = read_object_file(&ce->oid, &type, &size); + data = repo_read_object_file(the_repository, &ce->oid, + &type, &size); init_tree_desc(&tree, data, size); hit |= grep_tree(opt, pathspec, &tree, &name, 0, 0); @@ -650,7 +651,8 @@ static int grep_tree(struct grep_opt *opt, const struct pathspec *pathspec, void *data; unsigned long size; - data = read_object_file(&entry.oid, &type, &size); + data = repo_read_object_file(the_repository, + &entry.oid, &type, &size); if (!data) die(_("unable to read tree (%s)"), oid_to_hex(&entry.oid)); diff --git a/builtin/index-pack.c b/builtin/index-pack.c index 6648f2daef..4cf69ee1d9 100644 --- a/builtin/index-pack.c +++ b/builtin/index-pack.c @@ -801,7 +801,8 @@ static void sha1_object(const void *data, struct object_entry *obj_entry, if (startup_info->have_repository) { read_lock(); collision_test_needed = - has_object_file_with_flags(oid, OBJECT_INFO_QUICK); + repo_has_object_file_with_flags(the_repository, oid, + OBJECT_INFO_QUICK); read_unlock(); } @@ -821,7 +822,8 @@ static void sha1_object(const void *data, struct object_entry *obj_entry, die(_("cannot read existing object info %s"), oid_to_hex(oid)); if (has_type != type || has_size != size) die(_("SHA1 COLLISION FOUND WITH %s !"), oid_to_hex(oid)); - has_data = read_object_file(oid, &has_type, &has_size); + has_data = repo_read_object_file(the_repository, oid, + &has_type, &has_size); read_unlock(); if (!data) data = new_data = get_data_from_pack(obj_entry); @@ -1414,7 +1416,8 @@ static void fix_unresolved_deltas(struct hashfile *f) if (objects[d->obj_no].real_type != OBJ_REF_DELTA) continue; - data = read_object_file(&d->oid, &type, &size); + data = repo_read_object_file(the_repository, &d->oid, &type, + &size); if (!data) continue; diff --git a/builtin/log.c b/builtin/log.c index b76a1c82d8..3dde77bde2 100644 --- a/builtin/log.c +++ b/builtin/log.c @@ -675,7 +675,7 @@ static int show_tag_object(const struct object_id *oid, struct rev_info *rev) { unsigned long size; enum object_type type; - char *buf = read_object_file(oid, &type, &size); + char *buf = repo_read_object_file(the_repository, oid, &type, &size); int offset = 0; if (!buf) diff --git a/builtin/merge-tree.c b/builtin/merge-tree.c index c0acbc6a54..d628ad1da9 100644 --- a/builtin/merge-tree.c +++ b/builtin/merge-tree.c @@ -69,7 +69,9 @@ static void *result(struct merge_list *entry, unsigned long *size) const char *path = entry->path; if (!entry->stage) - return read_object_file(&entry->blob->object.oid, &type, size); + return repo_read_object_file(the_repository, + &entry->blob->object.oid, &type, + size); base = NULL; if (entry->stage == 1) { base = entry->blob; @@ -92,8 +94,9 @@ static void *origin(struct merge_list *entry, unsigned long *size) enum object_type type; while (entry) { if (entry->stage == 2) - return read_object_file(&entry->blob->object.oid, - &type, size); + return repo_read_object_file(the_repository, + &entry->blob->object.oid, + &type, size); entry = entry->link; } return NULL; diff --git a/builtin/mktag.c b/builtin/mktag.c index 5d22909122..141a2d4569 100644 --- a/builtin/mktag.c +++ b/builtin/mktag.c @@ -51,7 +51,8 @@ static int verify_object_in_tag(struct object_id *tagged_oid, int *tagged_type) void *buffer; const struct object_id *repl; - buffer = read_object_file(tagged_oid, &type, &size); + buffer = repo_read_object_file(the_repository, tagged_oid, &type, + &size); if (!buffer) die(_("could not read tagged object '%s'"), oid_to_hex(tagged_oid)); diff --git a/builtin/notes.c b/builtin/notes.c index b497eae520..ba1daa4ff0 100644 --- a/builtin/notes.c +++ b/builtin/notes.c @@ -124,7 +124,7 @@ static void copy_obj_to_fd(int fd, const struct object_id *oid) { unsigned long size; enum object_type type; - char *buf = read_object_file(oid, &type, &size); + char *buf = repo_read_object_file(the_repository, oid, &type, &size); if (buf) { if (size) write_or_die(fd, buf, size); @@ -259,7 +259,7 @@ static int parse_reuse_arg(const struct option *opt, const char *arg, int unset) if (repo_get_oid(the_repository, arg, &object)) die(_("failed to resolve '%s' as a valid ref."), arg); - if (!(buf = read_object_file(&object, &type, &len))) + if (!(buf = repo_read_object_file(the_repository, &object, &type, &len))) die(_("failed to read object '%s'."), arg); if (type != OBJ_BLOB) { free(buf); @@ -616,7 +616,8 @@ static int append_edit(int argc, const char **argv, const char *prefix) /* Append buf to previous note contents */ unsigned long size; enum object_type type; - char *prev_buf = read_object_file(note, &type, &size); + char *prev_buf = repo_read_object_file(the_repository, note, + &type, &size); strbuf_grow(&d.buf, size + 1); if (d.buf.len && prev_buf && size) diff --git a/builtin/pack-objects.c b/builtin/pack-objects.c index 74a167a180..3c9b35642c 100644 --- a/builtin/pack-objects.c +++ b/builtin/pack-objects.c @@ -288,11 +288,13 @@ static void *get_delta(struct object_entry *entry) void *buf, *base_buf, *delta_buf; enum object_type type; - buf = read_object_file(&entry->idx.oid, &type, &size); + buf = repo_read_object_file(the_repository, &entry->idx.oid, &type, + &size); if (!buf) die(_("unable to read %s"), oid_to_hex(&entry->idx.oid)); - base_buf = read_object_file(&DELTA(entry)->idx.oid, &type, - &base_size); + base_buf = repo_read_object_file(the_repository, + &DELTA(entry)->idx.oid, &type, + &base_size); if (!base_buf) die("unable to read %s", oid_to_hex(&DELTA(entry)->idx.oid)); @@ -454,7 +456,9 @@ static unsigned long write_no_reuse_object(struct hashfile *f, struct object_ent &size, NULL)) != NULL) buf = NULL; else { - buf = read_object_file(&entry->idx.oid, &type, &size); + buf = repo_read_object_file(the_repository, + &entry->idx.oid, &type, + &size); if (!buf) die(_("unable to read %s"), oid_to_hex(&entry->idx.oid)); @@ -1665,7 +1669,7 @@ static struct pbase_tree_cache *pbase_tree_get(const struct object_id *oid) /* Did not find one. Either we got a bogus request or * we need to read and perhaps cache. */ - data = read_object_file(oid, &type, &size); + data = repo_read_object_file(the_repository, oid, &type, &size); if (!data) return NULL; if (type != OBJ_TREE) { @@ -2525,7 +2529,9 @@ static int try_delta(struct unpacked *trg, struct unpacked *src, /* Load data if not already done */ if (!trg->data) { packing_data_lock(&to_pack); - trg->data = read_object_file(&trg_entry->idx.oid, &type, &sz); + trg->data = repo_read_object_file(the_repository, + &trg_entry->idx.oid, &type, + &sz); packing_data_unlock(&to_pack); if (!trg->data) die(_("object %s cannot be read"), @@ -2538,7 +2544,9 @@ static int try_delta(struct unpacked *trg, struct unpacked *src, } if (!src->data) { packing_data_lock(&to_pack); - src->data = read_object_file(&src_entry->idx.oid, &type, &sz); + src->data = repo_read_object_file(the_repository, + &src_entry->idx.oid, &type, + &sz); packing_data_unlock(&to_pack); if (!src->data) { if (src_entry->preferred_base) { diff --git a/builtin/receive-pack.c b/builtin/receive-pack.c index 6d4fc1368a..5609206499 100644 --- a/builtin/receive-pack.c +++ b/builtin/receive-pack.c @@ -1494,7 +1494,7 @@ static const char *update(struct command *cmd, struct shallow_info *si) } } - if (!is_null_oid(new_oid) && !has_object_file(new_oid)) { + if (!is_null_oid(new_oid) && !repo_has_object_file(the_repository, new_oid)) { error("unpack should have generated %s, " "but I can't find it!", oid_to_hex(new_oid)); ret = "bad pack"; diff --git a/builtin/remote.c b/builtin/remote.c index 729f6f3643..a6b100dce7 100644 --- a/builtin/remote.c +++ b/builtin/remote.c @@ -443,7 +443,7 @@ static int get_push_ref_states(const struct ref *remote_refs, info->status = PUSH_STATUS_UPTODATE; else if (is_null_oid(&ref->old_oid)) info->status = PUSH_STATUS_CREATE; - else if (has_object_file(&ref->old_oid) && + else if (repo_has_object_file(the_repository, &ref->old_oid) && ref_newer(&ref->new_oid, &ref->old_oid)) info->status = PUSH_STATUS_FASTFORWARD; else diff --git a/builtin/show-ref.c b/builtin/show-ref.c index eb3ad1688b..b294ae4164 100644 --- a/builtin/show-ref.c +++ b/builtin/show-ref.c @@ -26,7 +26,7 @@ static void show_one(const char *refname, const struct object_id *oid) const char *hex; struct object_id peeled; - if (!has_object_file(oid)) + if (!repo_has_object_file(the_repository, oid)) die("git show-ref: bad ref %s (%s)", refname, oid_to_hex(oid)); diff --git a/builtin/tag.c b/builtin/tag.c index e6cbf6e5a8..cd97a141fa 100644 --- a/builtin/tag.c +++ b/builtin/tag.c @@ -215,7 +215,7 @@ static void write_tag_body(int fd, const struct object_id *oid) struct strbuf payload = STRBUF_INIT; struct strbuf signature = STRBUF_INIT; - orig = buf = read_object_file(oid, &type, &size); + orig = buf = repo_read_object_file(the_repository, oid, &type, &size); if (!buf) return; if (parse_signature(buf, size, &payload, &signature)) { @@ -366,7 +366,7 @@ static void create_reflog_msg(const struct object_id *oid, struct strbuf *sb) strbuf_addstr(sb, "object of unknown type"); break; case OBJ_COMMIT: - if ((buf = read_object_file(oid, &type, &size))) { + if ((buf = repo_read_object_file(the_repository, oid, &type, &size))) { subject_len = find_commit_subject(buf, &subject_start); strbuf_insert(sb, sb->len, subject_start, subject_len); } else { diff --git a/builtin/unpack-file.c b/builtin/unpack-file.c index e0d5178acc..9d5c152419 100644 --- a/builtin/unpack-file.c +++ b/builtin/unpack-file.c @@ -10,7 +10,7 @@ static char *create_temp_file(struct object_id *oid) unsigned long size; int fd; - buf = read_object_file(oid, &type, &size); + buf = repo_read_object_file(the_repository, oid, &type, &size); if (!buf || type != OBJ_BLOB) die("unable to read blob object %s", oid_to_hex(oid)); diff --git a/builtin/unpack-objects.c b/builtin/unpack-objects.c index 43789b8ef2..c072096174 100644 --- a/builtin/unpack-objects.c +++ b/builtin/unpack-objects.c @@ -442,7 +442,7 @@ static void unpack_delta_entry(enum object_type type, unsigned long delta_size, delta_data = get_data(delta_size); if (!delta_data) return; - if (has_object_file(&base_oid)) + if (repo_has_object_file(the_repository, &base_oid)) ; /* Ok we have this one */ else if (resolve_against_held(nr, &base_oid, delta_data, delta_size)) @@ -508,7 +508,8 @@ static void unpack_delta_entry(enum object_type type, unsigned long delta_size, if (resolve_against_held(nr, &base_oid, delta_data, delta_size)) return; - base = read_object_file(&base_oid, &type, &base_size); + base = repo_read_object_file(the_repository, &base_oid, &type, + &base_size); if (!base) { error("failed to read delta-pack base object %s", oid_to_hex(&base_oid)); diff --git a/bulk-checkin.c b/bulk-checkin.c index 855b68ec23..b44b94e866 100644 --- a/bulk-checkin.c +++ b/bulk-checkin.c @@ -124,7 +124,7 @@ static int already_written(struct bulk_checkin_packfile *state, struct object_id int i; /* The object may already exist in the repository */ - if (has_object_file(oid)) + if (repo_has_object_file(the_repository, oid)) return 1; /* Might want to keep the list sorted */ diff --git a/bundle.c b/bundle.c index 6ab6cd7378..9b57bade7a 100644 --- a/bundle.c +++ b/bundle.c @@ -293,7 +293,7 @@ static int is_tag_in_date_range(struct object *tag, struct rev_info *revs) if (revs->max_age == -1 && revs->min_age == -1) goto out; - buf = read_object_file(&tag->oid, &type, &size); + buf = repo_read_object_file(the_repository, &tag->oid, &type, &size); if (!buf) goto out; line = memmem(buf, size, "\ntagger ", 8); diff --git a/cache-tree.c b/cache-tree.c index 88c2c04f87..59610117d0 100644 --- a/cache-tree.c +++ b/cache-tree.c @@ -229,7 +229,7 @@ int cache_tree_fully_valid(struct cache_tree *it) int i; if (!it) return 0; - if (it->entry_count < 0 || !has_object_file(&it->oid)) + if (it->entry_count < 0 || !repo_has_object_file(the_repository, &it->oid)) return 0; for (i = 0; i < it->subtree_nr; i++) { if (!cache_tree_fully_valid(it->down[i]->cache_tree)) @@ -280,7 +280,7 @@ static int update_one(struct cache_tree *it, } } - if (0 <= it->entry_count && has_object_file(&it->oid)) + if (0 <= it->entry_count && repo_has_object_file(the_repository, &it->oid)) return it->entry_count; /* @@ -386,7 +386,7 @@ static int update_one(struct cache_tree *it, ce_missing_ok = mode == S_IFGITLINK || missing_ok || !must_check_existence(ce); if (is_null_oid(oid) || - (!ce_missing_ok && !has_object_file(oid))) { + (!ce_missing_ok && !repo_has_object_file(the_repository, oid))) { strbuf_release(&buffer); if (expected_missing) return -1; @@ -434,7 +434,7 @@ static int update_one(struct cache_tree *it, struct object_id oid; hash_object_file(the_hash_algo, buffer.buf, buffer.len, OBJ_TREE, &oid); - if (has_object_file_with_flags(&oid, OBJECT_INFO_SKIP_FETCH_OBJECT)) + if (repo_has_object_file_with_flags(the_repository, &oid, OBJECT_INFO_SKIP_FETCH_OBJECT)) oidcpy(&it->oid, &oid); else to_invalidate = 1; diff --git a/combine-diff.c b/combine-diff.c index d84ab878b7..20f8a03924 100644 --- a/combine-diff.c +++ b/combine-diff.c @@ -332,7 +332,7 @@ static char *grab_blob(struct repository *r, *size = fill_textconv(r, textconv, df, &blob); free_filespec(df); } else { - blob = read_object_file(oid, &type, size); + blob = repo_read_object_file(the_repository, oid, &type, size); if (type != OBJ_BLOB) die("object '%s' is not a blob!", oid_to_hex(oid)); } diff --git a/commit.c b/commit.c index 6036376d05..dd22e76c3e 100644 --- a/commit.c +++ b/commit.c @@ -1212,7 +1212,8 @@ static void handle_signed_tag(struct commit *parent, struct commit_extra_header desc = merge_remote_util(parent); if (!desc || !desc->obj) return; - buf = read_object_file(&desc->obj->oid, &type, &size); + buf = repo_read_object_file(the_repository, &desc->obj->oid, &type, + &size); if (!buf || type != OBJ_TAG) goto free_return; if (!parse_signature(buf, size, &payload, &signature)) diff --git a/contrib/coccinelle/the_repository.cocci b/contrib/coccinelle/the_repository.cocci index 3c0bd8781e..fa159aba5b 100644 --- a/contrib/coccinelle/the_repository.cocci +++ b/contrib/coccinelle/the_repository.cocci @@ -77,6 +77,16 @@ | - diff_setup + repo_diff_setup +// object-store.h +| +- read_object_file ++ repo_read_object_file +| +- has_object_file ++ repo_has_object_file +| +- has_object_file_with_flags ++ repo_has_object_file_with_flags ) ( + the_repository, diff --git a/contrib/coccinelle/the_repository.pending.cocci b/contrib/coccinelle/the_repository.pending.cocci index 00461ee86b..69e9694111 100644 --- a/contrib/coccinelle/the_repository.pending.cocci +++ b/contrib/coccinelle/the_repository.pending.cocci @@ -5,17 +5,7 @@ @@ @@ ( -// object-store.h -- read_object_file -+ repo_read_object_file -| -- has_object_file -+ repo_has_object_file -| -- has_object_file_with_flags -+ repo_has_object_file_with_flags // pretty.h -| - format_commit_message + repo_format_commit_message // packfile.h diff --git a/dir.c b/dir.c index 4e99f0c868..6615afe8f1 100644 --- a/dir.c +++ b/dir.c @@ -267,7 +267,7 @@ static int do_read_blob(const struct object_id *oid, struct oid_stat *oid_stat, *size_out = 0; *data_out = NULL; - data = read_object_file(oid, &type, &sz); + data = repo_read_object_file(the_repository, oid, &type, &sz); if (!data || type != OBJ_BLOB) { free(data); return -1; diff --git a/entry.c b/entry.c index 971ab26871..7c50220a78 100644 --- a/entry.c +++ b/entry.c @@ -86,7 +86,8 @@ void *read_blob_entry(const struct cache_entry *ce, size_t *size) { enum object_type type; unsigned long ul; - void *blob_data = read_object_file(&ce->oid, &type, &ul); + void *blob_data = repo_read_object_file(the_repository, &ce->oid, + &type, &ul); *size = ul; if (blob_data) { diff --git a/fetch-pack.c b/fetch-pack.c index 04016d1e32..8c497b4821 100644 --- a/fetch-pack.c +++ b/fetch-pack.c @@ -762,9 +762,9 @@ static void mark_complete_and_common_ref(struct fetch_negotiator *negotiator, if (!commit) { struct object *o; - if (!has_object_file_with_flags(&ref->old_oid, - OBJECT_INFO_QUICK | - OBJECT_INFO_SKIP_FETCH_OBJECT)) + if (!repo_has_object_file_with_flags(the_repository, &ref->old_oid, + OBJECT_INFO_QUICK | + OBJECT_INFO_SKIP_FETCH_OBJECT)) continue; o = parse_object(the_repository, &ref->old_oid); if (!o || o->type != OBJ_COMMIT) @@ -1963,7 +1963,7 @@ static void update_shallow(struct fetch_pack_args *args, struct oid_array extra = OID_ARRAY_INIT; struct object_id *oid = si->shallow->oid; for (i = 0; i < si->shallow->nr; i++) - if (has_object_file(&oid[i])) + if (repo_has_object_file(the_repository, &oid[i])) oid_array_append(&extra, &oid[i]); if (extra.nr) { setup_alternate_shallow(&shallow_lock, diff --git a/fmt-merge-msg.c b/fmt-merge-msg.c index a5de91ba22..e9c6623647 100644 --- a/fmt-merge-msg.c +++ b/fmt-merge-msg.c @@ -520,7 +520,8 @@ static void fmt_merge_msg_sigs(struct strbuf *out) struct object_id *oid = origins.items[i].util; enum object_type type; unsigned long size; - char *buf = read_object_file(oid, &type, &size); + char *buf = repo_read_object_file(the_repository, oid, &type, + &size); char *origbuf = buf; unsigned long len = size; struct signature_check sigc = { NULL }; diff --git a/fsck.c b/fsck.c index 807a84971a..0343fb7a88 100644 --- a/fsck.c +++ b/fsck.c @@ -1332,7 +1332,7 @@ static int fsck_blobs(struct oidset *blobs_found, struct oidset *blobs_done, if (oidset_contains(blobs_done, oid)) continue; - buf = read_object_file(oid, &type, &size); + buf = repo_read_object_file(the_repository, oid, &type, &size); if (!buf) { if (is_promisor_object(oid)) continue; diff --git a/http-push.c b/http-push.c index 45d5cc0972..6776f3f275 100644 --- a/http-push.c +++ b/http-push.c @@ -362,7 +362,8 @@ static void start_put(struct transfer_request *request) ssize_t size; git_zstream stream; - unpacked = read_object_file(&request->obj->oid, &type, &len); + unpacked = repo_read_object_file(the_repository, &request->obj->oid, + &type, &len); hdrlen = format_object_header(hdr, sizeof(hdr), type, len); /* Set it up */ @@ -1427,7 +1428,7 @@ static void one_remote_ref(const char *refname) * Fetch a copy of the object if it doesn't exist locally - it * may be required for updating server info later. */ - if (repo->can_update_info_refs && !has_object_file(&ref->old_oid)) { + if (repo->can_update_info_refs && !repo_has_object_file(the_repository, &ref->old_oid)) { obj = lookup_unknown_object(the_repository, &ref->old_oid); fprintf(stderr, " fetch %s for %s\n", oid_to_hex(&ref->old_oid), refname); @@ -1628,14 +1629,14 @@ static int delete_remote_branch(const char *pattern, int force) return error("Remote HEAD symrefs too deep"); if (is_null_oid(&head_oid)) return error("Unable to resolve remote HEAD"); - if (!has_object_file(&head_oid)) + if (!repo_has_object_file(the_repository, &head_oid)) return error("Remote HEAD resolves to object %s\nwhich does not exist locally, perhaps you need to fetch?", oid_to_hex(&head_oid)); /* Remote branch must resolve to a known object */ if (is_null_oid(&remote_ref->old_oid)) return error("Unable to resolve remote branch %s", remote_ref->name); - if (!has_object_file(&remote_ref->old_oid)) + if (!repo_has_object_file(the_repository, &remote_ref->old_oid)) return error("Remote branch %s resolves to object %s\nwhich does not exist locally, perhaps you need to fetch?", remote_ref->name, oid_to_hex(&remote_ref->old_oid)); /* Remote branch must be an ancestor of remote HEAD */ @@ -1855,7 +1856,7 @@ int cmd_main(int argc, const char **argv) if (!force_all && !is_null_oid(&ref->old_oid) && !ref->force) { - if (!has_object_file(&ref->old_oid) || + if (!repo_has_object_file(the_repository, &ref->old_oid) || !ref_newer(&ref->peer_ref->new_oid, &ref->old_oid)) { /* diff --git a/http-walker.c b/http-walker.c index b8f0f98ae1..da1b6b6421 100644 --- a/http-walker.c +++ b/http-walker.c @@ -135,7 +135,7 @@ static int fill_active_slot(struct walker *walker) list_for_each_safe(pos, tmp, head) { obj_req = list_entry(pos, struct object_request, node); if (obj_req->state == WAITING) { - if (has_object_file(&obj_req->oid)) + if (repo_has_object_file(the_repository, &obj_req->oid)) obj_req->state = COMPLETE; else { start_object_request(walker, obj_req); @@ -492,7 +492,7 @@ static int fetch_object(struct walker *walker, unsigned char *hash) if (!obj_req) return error("Couldn't find request for %s in the queue", hex); - if (has_object_file(&obj_req->oid)) { + if (repo_has_object_file(the_repository, &obj_req->oid)) { if (obj_req->req) abort_http_object_request(obj_req->req); abort_object_request(obj_req); diff --git a/list-objects.c b/list-objects.c index 5550b3aafe..ccad7304df 100644 --- a/list-objects.c +++ b/list-objects.c @@ -64,7 +64,7 @@ static void process_blob(struct traversal_context *ctx, * of missing objects. */ if (ctx->revs->exclude_promisor_objects && - !has_object_file(&obj->oid) && + !repo_has_object_file(the_repository, &obj->oid) && is_promisor_object(&obj->oid)) return; diff --git a/mailmap.c b/mailmap.c index ed8289aea5..f68f664bb1 100644 --- a/mailmap.c +++ b/mailmap.c @@ -216,7 +216,7 @@ static int read_mailmap_blob(struct string_list *map, const char *name) if (repo_get_oid(the_repository, name, &oid) < 0) return 0; - buf = read_object_file(&oid, &type, &size); + buf = repo_read_object_file(the_repository, &oid, &type, &size); if (!buf) return error("unable to read mailmap object at %s", name); if (type != OBJ_BLOB) diff --git a/match-trees.c b/match-trees.c index 49398e599f..dfc4093425 100644 --- a/match-trees.c +++ b/match-trees.c @@ -55,7 +55,7 @@ static void *fill_tree_desc_strict(struct tree_desc *desc, enum object_type type; unsigned long size; - buffer = read_object_file(hash, &type, &size); + buffer = repo_read_object_file(the_repository, hash, &type, &size); if (!buffer) die("unable to read tree (%s)", oid_to_hex(hash)); if (type != OBJ_TREE) @@ -188,7 +188,7 @@ static int splice_tree(const struct object_id *oid1, const char *prefix, if (*subpath) subpath++; - buf = read_object_file(oid1, &type, &sz); + buf = repo_read_object_file(the_repository, oid1, &type, &sz); if (!buf) die("cannot read tree %s", oid_to_hex(oid1)); init_tree_desc(&desc, buf, sz); diff --git a/merge-blobs.c b/merge-blobs.c index 8138090f81..f13246406c 100644 --- a/merge-blobs.c +++ b/merge-blobs.c @@ -12,7 +12,8 @@ static int fill_mmfile_blob(mmfile_t *f, struct blob *obj) unsigned long size; enum object_type type; - buf = read_object_file(&obj->object.oid, &type, &size); + buf = repo_read_object_file(the_repository, &obj->object.oid, &type, + &size); if (!buf) return -1; if (type != OBJ_BLOB) { @@ -78,7 +79,8 @@ void *merge_blobs(struct index_state *istate, const char *path, return NULL; if (!our) our = their; - return read_object_file(&our->object.oid, &type, size); + return repo_read_object_file(the_repository, &our->object.oid, + &type, size); } if (fill_mmfile_blob(&f1, our) < 0) diff --git a/merge-ort.c b/merge-ort.c index e9f8bd1598..979e8b057b 100644 --- a/merge-ort.c +++ b/merge-ort.c @@ -3505,7 +3505,7 @@ static int read_oid_strbuf(struct merge_options *opt, void *buf; enum object_type type; unsigned long size; - buf = read_object_file(oid, &type, &size); + buf = repo_read_object_file(the_repository, oid, &type, &size); if (!buf) return err(opt, _("cannot read object %s"), oid_to_hex(oid)); if (type != OBJ_BLOB) { diff --git a/merge-recursive.c b/merge-recursive.c index 75fa0ef318..d83ce19bb1 100644 --- a/merge-recursive.c +++ b/merge-recursive.c @@ -951,7 +951,8 @@ static int update_file_flags(struct merge_options *opt, goto update_index; } - buf = read_object_file(&contents->oid, &type, &size); + buf = repo_read_object_file(the_repository, &contents->oid, + &type, &size); if (!buf) { ret = err(opt, _("cannot read object %s '%s'"), oid_to_hex(&contents->oid), path); @@ -3021,7 +3022,7 @@ static int read_oid_strbuf(struct merge_options *opt, void *buf; enum object_type type; unsigned long size; - buf = read_object_file(oid, &type, &size); + buf = repo_read_object_file(the_repository, oid, &type, &size); if (!buf) return err(opt, _("cannot read object %s"), oid_to_hex(oid)); if (type != OBJ_BLOB) { diff --git a/notes-cache.c b/notes-cache.c index 9dfd251a81..3846609136 100644 --- a/notes-cache.c +++ b/notes-cache.c @@ -81,7 +81,7 @@ char *notes_cache_get(struct notes_cache *c, struct object_id *key_oid, value_oid = get_note(&c->tree, key_oid); if (!value_oid) return NULL; - value = read_object_file(value_oid, &type, &size); + value = repo_read_object_file(the_repository, value_oid, &type, &size); *outsize = size; return value; diff --git a/notes-merge.c b/notes-merge.c index df1a16ac66..8a09cd9f77 100644 --- a/notes-merge.c +++ b/notes-merge.c @@ -326,7 +326,7 @@ static void write_note_to_worktree(const struct object_id *obj, { enum object_type type; unsigned long size; - void *buf = read_object_file(note, &type, &size); + void *buf = repo_read_object_file(the_repository, note, &type, &size); if (!buf) die("cannot read note %s for object %s", diff --git a/notes.c b/notes.c index 750e18c400..e4dab62cad 100644 --- a/notes.c +++ b/notes.c @@ -786,7 +786,7 @@ static int prune_notes_helper(const struct object_id *object_oid, struct note_delete_list **l = (struct note_delete_list **) cb_data; struct note_delete_list *n; - if (has_object_file(object_oid)) + if (repo_has_object_file(the_repository, object_oid)) return 0; /* nothing to do for this note */ /* failed to find object => prune this note */ @@ -807,13 +807,15 @@ int combine_notes_concatenate(struct object_id *cur_oid, /* read in both note blob objects */ if (!is_null_oid(new_oid)) - new_msg = read_object_file(new_oid, &new_type, &new_len); + new_msg = repo_read_object_file(the_repository, new_oid, + &new_type, &new_len); if (!new_msg || !new_len || new_type != OBJ_BLOB) { free(new_msg); return 0; } if (!is_null_oid(cur_oid)) - cur_msg = read_object_file(cur_oid, &cur_type, &cur_len); + cur_msg = repo_read_object_file(the_repository, cur_oid, + &cur_type, &cur_len); if (!cur_msg || !cur_len || cur_type != OBJ_BLOB) { free(cur_msg); free(new_msg); @@ -869,7 +871,7 @@ static int string_list_add_note_lines(struct string_list *list, return 0; /* read_sha1_file NUL-terminates */ - data = read_object_file(oid, &t, &len); + data = repo_read_object_file(the_repository, oid, &t, &len); if (t != OBJ_BLOB || !data || !len) { free(data); return t != OBJ_BLOB || !data; @@ -1264,7 +1266,7 @@ static void format_note(struct notes_tree *t, const struct object_id *object_oid if (!oid) return; - if (!(msg = read_object_file(oid, &type, &msglen)) || type != OBJ_BLOB) { + if (!(msg = repo_read_object_file(the_repository, oid, &type, &msglen)) || type != OBJ_BLOB) { free(msg); return; } diff --git a/object-file.c b/object-file.c index 939865c1ae..141cf85f25 100644 --- a/object-file.c +++ b/object-file.c @@ -1678,7 +1678,7 @@ int pretend_object_file(void *buf, unsigned long len, enum object_type type, struct cached_object *co; hash_object_file(the_hash_algo, buf, len, type, oid); - if (has_object_file_with_flags(oid, OBJECT_INFO_QUICK | OBJECT_INFO_SKIP_FETCH_OBJECT) || + if (repo_has_object_file_with_flags(the_repository, oid, OBJECT_INFO_QUICK | OBJECT_INFO_SKIP_FETCH_OBJECT) || find_cached_object(oid)) return 0; ALLOC_GROW(cached_objects, cached_object_nr + 1, cached_object_alloc); diff --git a/object-store.h b/object-store.h index 1a713d89d7..b47849d4e7 100644 --- a/object-store.h +++ b/object-store.h @@ -245,9 +245,6 @@ void *repo_read_object_file(struct repository *r, const struct object_id *oid, enum object_type *type, unsigned long *size); -#ifndef NO_THE_REPOSITORY_COMPATIBILITY_MACROS -#define read_object_file(oid, type, size) repo_read_object_file(the_repository, oid, type, size) -#endif /* Read and unpack an object file into memory, write memory to an object file */ int oid_object_info(struct repository *r, const struct object_id *, unsigned long *); @@ -324,10 +321,6 @@ int has_object(struct repository *r, const struct object_id *oid, int repo_has_object_file(struct repository *r, const struct object_id *oid); int repo_has_object_file_with_flags(struct repository *r, const struct object_id *oid, int flags); -#ifndef NO_THE_REPOSITORY_COMPATIBILITY_MACROS -#define has_object_file(oid) repo_has_object_file(the_repository, oid) -#define has_object_file_with_flags(oid, flags) repo_has_object_file_with_flags(the_repository, oid, flags) -#endif /* * Return true iff an alternate object database has a loose object diff --git a/read-cache.c b/read-cache.c index d6c69164d0..1548e88668 100644 --- a/read-cache.c +++ b/read-cache.c @@ -263,7 +263,7 @@ static int ce_compare_link(const struct cache_entry *ce, size_t expected_size) if (strbuf_readlink(&sb, ce->name, expected_size)) return -1; - buffer = read_object_file(&ce->oid, &type, &size); + buffer = repo_read_object_file(the_repository, &ce->oid, &type, &size); if (buffer) { if (size == sb.len) match = memcmp(buffer, sb.buf, size); @@ -3553,7 +3553,8 @@ void *read_blob_data_from_index(struct index_state *istate, } if (pos < 0) return NULL; - data = read_object_file(&istate->cache[pos]->oid, &type, &sz); + data = repo_read_object_file(the_repository, &istate->cache[pos]->oid, + &type, &sz); if (!data || type != OBJ_BLOB) { free(data); return NULL; diff --git a/reflog.c b/reflog.c index 6e8362e7a2..510663e1e5 100644 --- a/reflog.c +++ b/reflog.c @@ -28,7 +28,8 @@ static int tree_is_complete(const struct object_id *oid) if (!tree->buffer) { enum object_type type; unsigned long size; - void *data = read_object_file(oid, &type, &size); + void *data = repo_read_object_file(the_repository, oid, &type, + &size); if (!data) { tree->object.flags |= INCOMPLETE; return 0; @@ -39,7 +40,7 @@ static int tree_is_complete(const struct object_id *oid) init_tree_desc(&desc, tree->buffer, tree->size); complete = 1; while (tree_entry(&desc, &entry)) { - if (!has_object_file(&entry.oid) || + if (!repo_has_object_file(the_repository, &entry.oid) || (S_ISDIR(entry.mode) && !tree_is_complete(&entry.oid))) { tree->object.flags |= INCOMPLETE; complete = 0; diff --git a/remote.c b/remote.c index 71b1ae2db0..12f6bea625 100644 --- a/remote.c +++ b/remote.c @@ -1759,7 +1759,7 @@ void set_ref_status_for_push(struct ref *remote_refs, int send_mirror, if (!reject_reason && !ref->deletion && !is_null_oid(&ref->old_oid)) { if (starts_with(ref->name, "refs/tags/")) reject_reason = REF_STATUS_REJECT_ALREADY_EXISTS; - else if (!has_object_file(&ref->old_oid)) + else if (!repo_has_object_file(the_repository, &ref->old_oid)) reject_reason = REF_STATUS_REJECT_FETCH_FIRST; else if (!lookup_commit_reference_gently(the_repository, &ref->old_oid, 1) || !lookup_commit_reference_gently(the_repository, &ref->new_oid, 1)) diff --git a/rerere.c b/rerere.c index 876ab435da..dfbc1d555e 100644 --- a/rerere.c +++ b/rerere.c @@ -965,8 +965,9 @@ static int handle_cache(struct index_state *istate, break; i = ce_stage(ce) - 1; if (!mmfile[i].ptr) { - mmfile[i].ptr = read_object_file(&ce->oid, &type, - &size); + mmfile[i].ptr = repo_read_object_file(the_repository, + &ce->oid, &type, + &size); mmfile[i].size = size; } } diff --git a/send-pack.c b/send-pack.c index f2e19838c9..8f8b3d986c 100644 --- a/send-pack.c +++ b/send-pack.c @@ -42,9 +42,9 @@ int option_parse_push_signed(const struct option *opt, static void feed_object(const struct object_id *oid, FILE *fh, int negative) { if (negative && - !has_object_file_with_flags(oid, - OBJECT_INFO_SKIP_FETCH_OBJECT | - OBJECT_INFO_QUICK)) + !repo_has_object_file_with_flags(the_repository, oid, + OBJECT_INFO_SKIP_FETCH_OBJECT | + OBJECT_INFO_QUICK)) return; if (negative) diff --git a/shallow.c b/shallow.c index 1a2b159fd4..07278467e4 100644 --- a/shallow.c +++ b/shallow.c @@ -301,7 +301,7 @@ static int write_one_shallow(const struct commit_graft *graft, void *cb_data) if (graft->nr_parent != -1) return 0; if (data->flags & QUICK) { - if (!has_object_file(&graft->oid)) + if (!repo_has_object_file(the_repository, &graft->oid)) return 0; } else if (data->flags & SEEN_ONLY) { struct commit *c = lookup_commit(the_repository, &graft->oid); @@ -466,7 +466,7 @@ void prepare_shallow_info(struct shallow_info *info, struct oid_array *sa) ALLOC_ARRAY(info->ours, sa->nr); ALLOC_ARRAY(info->theirs, sa->nr); for (i = 0; i < sa->nr; i++) { - if (has_object_file(sa->oid + i)) { + if (repo_has_object_file(the_repository, sa->oid + i)) { struct commit_graft *graft; graft = lookup_commit_graft(the_repository, &sa->oid[i]); @@ -494,7 +494,7 @@ void remove_nonexistent_theirs_shallow(struct shallow_info *info) for (i = dst = 0; i < info->nr_theirs; i++) { if (i != dst) info->theirs[dst] = info->theirs[i]; - if (has_object_file(oid + info->theirs[i])) + if (repo_has_object_file(the_repository, oid + info->theirs[i])) dst++; } info->nr_theirs = dst; diff --git a/submodule-config.c b/submodule-config.c index 336732ed78..4245bc5975 100644 --- a/submodule-config.c +++ b/submodule-config.c @@ -588,7 +588,8 @@ static const struct submodule *config_from(struct submodule_cache *cache, if (submodule) goto out; - config = read_object_file(&oid, &type, &config_size); + config = repo_read_object_file(the_repository, &oid, &type, + &config_size); if (!config || type != OBJ_BLOB) goto out; diff --git a/tag.c b/tag.c index dfc900e62e..d62084842f 100644 --- a/tag.c +++ b/tag.c @@ -54,7 +54,7 @@ int gpg_verify_tag(const struct object_id *oid, const char *name_to_report, repo_find_unique_abbrev(the_repository, oid, DEFAULT_ABBREV), type_name(type)); - buf = read_object_file(oid, &type, &size); + buf = repo_read_object_file(the_repository, oid, &type, &size); if (!buf) return error("%s: unable to read file.", name_to_report ? @@ -216,7 +216,8 @@ int parse_tag(struct tag *item) if (item->object.parsed) return 0; - data = read_object_file(&item->object.oid, &type, &size); + data = repo_read_object_file(the_repository, &item->object.oid, &type, + &size); if (!data) return error("Could not read %s", oid_to_hex(&item->object.oid)); diff --git a/tree.c b/tree.c index f0742f4167..1b403c4b5c 100644 --- a/tree.c +++ b/tree.c @@ -129,7 +129,8 @@ int parse_tree_gently(struct tree *item, int quiet_on_missing) if (item->object.parsed) return 0; - buffer = read_object_file(&item->object.oid, &type, &size); + buffer = repo_read_object_file(the_repository, &item->object.oid, + &type, &size); if (!buffer) return quiet_on_missing ? -1 : error("Could not read %s", diff --git a/upload-pack.c b/upload-pack.c index 551f22ffa5..4ef27ed47f 100644 --- a/upload-pack.c +++ b/upload-pack.c @@ -499,8 +499,8 @@ static int got_oid(struct upload_pack_data *data, { if (get_oid_hex(hex, oid)) die("git upload-pack: expected SHA1 object, got '%s'", hex); - if (!has_object_file_with_flags(oid, - OBJECT_INFO_QUICK | OBJECT_INFO_SKIP_FETCH_OBJECT)) + if (!repo_has_object_file_with_flags(the_repository, oid, + OBJECT_INFO_QUICK | OBJECT_INFO_SKIP_FETCH_OBJECT)) return -1; return do_got_oid(data, oid); } @@ -1600,8 +1600,8 @@ static int process_haves(struct upload_pack_data *data, struct oid_array *common for (i = 0; i < data->haves.nr; i++) { const struct object_id *oid = &data->haves.oid[i]; - if (!has_object_file_with_flags(oid, - OBJECT_INFO_QUICK | OBJECT_INFO_SKIP_FETCH_OBJECT)) + if (!repo_has_object_file_with_flags(the_repository, oid, + OBJECT_INFO_QUICK | OBJECT_INFO_SKIP_FETCH_OBJECT)) continue; oid_array_append(common, oid); diff --git a/walker.c b/walker.c index 98d65a559b..8418066e50 100644 --- a/walker.c +++ b/walker.c @@ -145,7 +145,7 @@ static int process(struct walker *walker, struct object *obj) return 0; obj->flags |= SEEN; - if (has_object_file(&obj->oid)) { + if (repo_has_object_file(the_repository, &obj->oid)) { /* We already have it, so we should scan it now. */ obj->flags |= TO_SCAN; } diff --git a/xdiff-interface.c b/xdiff-interface.c index e87950de32..c6f244116c 100644 --- a/xdiff-interface.c +++ b/xdiff-interface.c @@ -183,7 +183,7 @@ void read_mmblob(mmfile_t *ptr, const struct object_id *oid) return; } - ptr->ptr = read_object_file(oid, &type, &size); + ptr->ptr = repo_read_object_file(the_repository, oid, &type, &size); if (!ptr->ptr || type != OBJ_BLOB) die("unable to read blob object %s", oid_to_hex(oid)); ptr->size = size; -- cgit v1.2.3 From 12cb1c10a64170a5d600dd1c6c8abfeec105fb6b Mon Sep 17 00:00:00 2001 From: Ævar Arnfjörð Bjarmason Date: Tue, 28 Mar 2023 15:58:54 +0200 Subject: cocci: apply the "refs.h" part of "the_repository.pending" MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Apply the part of "the_repository.pending.cocci" pertaining to "refs.h". Signed-off-by: Ævar Arnfjörð Bjarmason Signed-off-by: Junio C Hamano --- archive.c | 5 +++-- branch.c | 3 ++- builtin/checkout.c | 6 ++++-- builtin/fast-export.c | 3 ++- builtin/log.c | 3 ++- builtin/merge.c | 3 ++- builtin/reset.c | 3 ++- builtin/rev-parse.c | 4 +++- builtin/show-branch.c | 3 ++- builtin/stash.c | 3 ++- bundle.c | 3 ++- commit.c | 3 ++- contrib/coccinelle/the_repository.cocci | 4 ++++ contrib/coccinelle/the_repository.pending.cocci | 4 ---- refs.h | 6 ------ remote.c | 5 +++-- wt-status.c | 3 ++- 17 files changed, 37 insertions(+), 27 deletions(-) (limited to 'commit.c') diff --git a/archive.c b/archive.c index d43687a5c4..716a18567b 100644 --- a/archive.c +++ b/archive.c @@ -456,10 +456,11 @@ static void parse_treeish_arg(const char **argv, const char *colon = strchrnul(name, ':'); int refnamelen = colon - name; - if (!dwim_ref(name, refnamelen, &oid, &ref, 0)) + if (!repo_dwim_ref(the_repository, name, refnamelen, &oid, &ref, 0)) die(_("no such ref: %.*s"), refnamelen, name); } else { - dwim_ref(name, strlen(name), &oid, &ref, 0); + repo_dwim_ref(the_repository, name, strlen(name), &oid, &ref, + 0); } if (repo_get_oid(the_repository, name, &oid)) diff --git a/branch.c b/branch.c index 2efb5fbaa5..a01e465b11 100644 --- a/branch.c +++ b/branch.c @@ -541,7 +541,8 @@ static void dwim_branch_start(struct repository *r, const char *start_name, die(_("not a valid object name: '%s'"), start_name); } - switch (dwim_ref(start_name, strlen(start_name), &oid, &real_ref, 0)) { + switch (repo_dwim_ref(the_repository, start_name, strlen(start_name), + &oid, &real_ref, 0)) { case 0: /* Not branching from any existing branch */ if (explicit_tracking) diff --git a/builtin/checkout.c b/builtin/checkout.c index 1d1f33e33e..cb7cd315b3 100644 --- a/builtin/checkout.c +++ b/builtin/checkout.c @@ -703,7 +703,8 @@ static void setup_branch_path(struct branch_info *branch) * If this is a ref, resolve it; otherwise, look up the OID for our * expression. Failure here is okay. */ - if (!dwim_ref(branch->name, strlen(branch->name), &branch->oid, &branch->refname, 0)) + if (!repo_dwim_ref(the_repository, branch->name, strlen(branch->name), + &branch->oid, &branch->refname, 0)) repo_get_oid_committish(the_repository, branch->name, &branch->oid); strbuf_branchname(&buf, branch->name, INTERPRET_BRANCH_LOCAL); @@ -1424,7 +1425,8 @@ static void die_expecting_a_branch(const struct branch_info *branch_info) char *to_free; int code; - if (dwim_ref(branch_info->name, strlen(branch_info->name), &oid, &to_free, 0) == 1) { + if (repo_dwim_ref(the_repository, branch_info->name, + strlen(branch_info->name), &oid, &to_free, 0) == 1) { const char *ref = to_free; if (skip_prefix(ref, "refs/tags/", &ref)) diff --git a/builtin/fast-export.c b/builtin/fast-export.c index 6515bd2ad8..550f078a8e 100644 --- a/builtin/fast-export.c +++ b/builtin/fast-export.c @@ -918,7 +918,8 @@ static void get_tags_and_duplicates(struct rev_cmdline_info *info) if (e->flags & UNINTERESTING) continue; - if (dwim_ref(e->name, strlen(e->name), &oid, &full_name, 0) != 1) + if (repo_dwim_ref(the_repository, e->name, strlen(e->name), + &oid, &full_name, 0) != 1) continue; if (refspecs.nr) { diff --git a/builtin/log.c b/builtin/log.c index 3dde77bde2..acf3faecd8 100644 --- a/builtin/log.c +++ b/builtin/log.c @@ -1204,7 +1204,8 @@ static char *find_branch_name(struct rev_info *rev) return NULL; ref = rev->cmdline.rev[positive].name; tip_oid = &rev->cmdline.rev[positive].item->oid; - if (dwim_ref(ref, strlen(ref), &branch_oid, &full_ref, 0) && + if (repo_dwim_ref(the_repository, ref, strlen(ref), &branch_oid, + &full_ref, 0) && skip_prefix(full_ref, "refs/heads/", &v) && oideq(tip_oid, &branch_oid)) branch = xstrdup(v); diff --git a/builtin/merge.c b/builtin/merge.c index 197e152aba..69666546ca 100644 --- a/builtin/merge.c +++ b/builtin/merge.c @@ -517,7 +517,8 @@ static void merge_name(const char *remote, struct strbuf *msg) if (!remote_head) die(_("'%s' does not point to a commit"), remote); - if (dwim_ref(remote, strlen(remote), &branch_head, &found_ref, 0) > 0) { + if (repo_dwim_ref(the_repository, remote, strlen(remote), &branch_head, + &found_ref, 0) > 0) { if (starts_with(found_ref, "refs/heads/")) { strbuf_addf(msg, "%s\t\tbranch '%s' of .\n", oid_to_hex(&branch_head), remote); diff --git a/builtin/reset.c b/builtin/reset.c index 75b447ffdc..b65f379440 100644 --- a/builtin/reset.c +++ b/builtin/reset.c @@ -465,7 +465,8 @@ int cmd_reset(int argc, const char **argv, const char *prefix) char *ref = NULL; int err; - dwim_ref(rev, strlen(rev), &dummy, &ref, 0); + repo_dwim_ref(the_repository, rev, strlen(rev), + &dummy, &ref, 0); if (ref && !starts_with(ref, "refs/")) FREE_AND_NULL(ref); diff --git a/builtin/rev-parse.c b/builtin/rev-parse.c index 5685cf0ea7..663f282c5f 100644 --- a/builtin/rev-parse.c +++ b/builtin/rev-parse.c @@ -136,7 +136,9 @@ static void show_rev(int type, const struct object_id *oid, const char *name) struct object_id discard; char *full; - switch (dwim_ref(name, strlen(name), &discard, &full, 0)) { + switch (repo_dwim_ref(the_repository, name, + strlen(name), &discard, &full, + 0)) { case 0: /* * Not found -- not a ref. We could diff --git a/builtin/show-branch.c b/builtin/show-branch.c index d60e536a53..af680485d5 100644 --- a/builtin/show-branch.c +++ b/builtin/show-branch.c @@ -746,7 +746,8 @@ int cmd_show_branch(int ac, const char **av, const char *prefix) die(Q_("only %d entry can be shown at one time.", "only %d entries can be shown at one time.", MAX_REVS), MAX_REVS); - if (!dwim_ref(*av, strlen(*av), &oid, &ref, 0)) + if (!repo_dwim_ref(the_repository, *av, strlen(*av), &oid, + &ref, 0)) die(_("no such ref %s"), *av); /* Has the base been specified? */ diff --git a/builtin/stash.c b/builtin/stash.c index 6c062e5204..364273f101 100644 --- a/builtin/stash.c +++ b/builtin/stash.c @@ -211,7 +211,8 @@ static int get_stash_info(struct stash_info *info, int argc, const char **argv) end_of_rev = strchrnul(revision, '@'); strbuf_add(&symbolic, revision, end_of_rev - revision); - ret = dwim_ref(symbolic.buf, symbolic.len, &dummy, &expanded_ref, 0); + ret = repo_dwim_ref(the_repository, symbolic.buf, symbolic.len, + &dummy, &expanded_ref, 0); strbuf_release(&symbolic); switch (ret) { case 0: /* Not found, but valid ref */ diff --git a/bundle.c b/bundle.c index 9b57bade7a..dca96e51ee 100644 --- a/bundle.c +++ b/bundle.c @@ -382,7 +382,8 @@ static int write_bundle_refs(int bundle_fd, struct rev_info *revs) if (e->item->flags & UNINTERESTING) continue; - if (dwim_ref(e->name, strlen(e->name), &oid, &ref, 0) != 1) + if (repo_dwim_ref(the_repository, e->name, strlen(e->name), + &oid, &ref, 0) != 1) goto skip_write_ref; if (read_ref_full(e->name, RESOLVE_REF_READING, &oid, &flag)) flag = 0; diff --git a/commit.c b/commit.c index dd22e76c3e..0e2fc7dbab 100644 --- a/commit.c +++ b/commit.c @@ -996,7 +996,8 @@ struct commit *get_fork_point(const char *refname, struct commit *commit) struct commit *ret = NULL; char *full_refname; - switch (dwim_ref(refname, strlen(refname), &oid, &full_refname, 0)) { + switch (repo_dwim_ref(the_repository, refname, strlen(refname), &oid, + &full_refname, 0)) { case 0: die("No such ref: '%s'", refname); case 1: diff --git a/contrib/coccinelle/the_repository.cocci b/contrib/coccinelle/the_repository.cocci index d5b644a868..b20a3e7084 100644 --- a/contrib/coccinelle/the_repository.cocci +++ b/contrib/coccinelle/the_repository.cocci @@ -105,6 +105,10 @@ | - has_promisor_remote + repo_has_promisor_remote +// refs.h +| +- dwim_ref ++ repo_dwim_ref ) ( + the_repository, diff --git a/contrib/coccinelle/the_repository.pending.cocci b/contrib/coccinelle/the_repository.pending.cocci index e17a60198c..8bf30798a0 100644 --- a/contrib/coccinelle/the_repository.pending.cocci +++ b/contrib/coccinelle/the_repository.pending.cocci @@ -5,11 +5,7 @@ @@ @@ ( -// refs.h -- dwim_ref -+ repo_dwim_ref // rerere.h -| - rerere + repo_rerere // revision.h diff --git a/refs.h b/refs.h index 935cdd1ece..2998244b61 100644 --- a/refs.h +++ b/refs.h @@ -159,12 +159,6 @@ int expand_ref(struct repository *r, const char *str, int len, struct object_id int repo_dwim_ref(struct repository *r, const char *str, int len, struct object_id *oid, char **ref, int nonfatal_dangling_mark); int repo_dwim_log(struct repository *r, const char *str, int len, struct object_id *oid, char **ref); -static inline int dwim_ref(const char *str, int len, struct object_id *oid, - char **ref, int nonfatal_dangling_mark) -{ - return repo_dwim_ref(the_repository, str, len, oid, ref, - nonfatal_dangling_mark); -} int dwim_log(const char *str, int len, struct object_id *oid, char **ref); /* diff --git a/remote.c b/remote.c index 12f6bea625..a03b03e467 100644 --- a/remote.c +++ b/remote.c @@ -1808,8 +1808,9 @@ static void set_merge(struct remote_state *remote_state, struct branch *ret) if (!remote_find_tracking(remote, ret->merge[i]) || strcmp(ret->remote_name, ".")) continue; - if (dwim_ref(ret->merge_name[i], strlen(ret->merge_name[i]), - &oid, &ref, 0) == 1) + if (repo_dwim_ref(the_repository, ret->merge_name[i], + strlen(ret->merge_name[i]), &oid, &ref, + 0) == 1) ret->merge[i]->dst = ref; else ret->merge[i]->dst = xstrdup(ret->merge_name[i]); diff --git a/wt-status.c b/wt-status.c index c55c51b192..dcd1d0cee4 100644 --- a/wt-status.c +++ b/wt-status.c @@ -1664,7 +1664,8 @@ static void wt_status_get_detached_from(struct repository *r, return; } - if (dwim_ref(cb.buf.buf, cb.buf.len, &oid, &ref, 1) == 1 && + if (repo_dwim_ref(the_repository, cb.buf.buf, cb.buf.len, &oid, &ref, + 1) == 1 && /* oid is a commit? match without further lookup */ (oideq(&cb.noid, &oid) || /* perhaps oid is a tag, try to dereference to a commit */ -- cgit v1.2.3