Skip to content

Commit 21e1ee8

Browse files
stefanbellergitster
authored andcommitted
commit: add repository argument to lookup_commit_reference_gently
Add a repository argument to allow callers of lookup_commit_reference_gently to be more specific about which repository to handle. This is a small mechanical change; it doesn't change the implementation to handle repositories other than the_repository yet. As with the previous commits, use a macro to catch callers passing a repository other than the_repository at compile time. Signed-off-by: Stefan Beller <sbeller@google.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
1 parent f86bcc7 commit 21e1ee8

20 files changed

+59
-38
lines changed

archive.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -380,7 +380,7 @@ static void parse_treeish_arg(const char **argv,
380380
if (get_oid(name, &oid))
381381
die("Not a valid object name");
382382

383-
commit = lookup_commit_reference_gently(&oid, 1);
383+
commit = lookup_commit_reference_gently(the_repository, &oid, 1);
384384
if (commit) {
385385
commit_sha1 = commit->object.oid.hash;
386386
archive_time = commit->date;

blame.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1712,7 +1712,8 @@ static struct commit *dwim_reverse_initial(struct rev_info *revs,
17121712
/* Do we have HEAD? */
17131713
if (!resolve_ref_unsafe("HEAD", RESOLVE_REF_READING, &head_oid, NULL))
17141714
return NULL;
1715-
head_commit = lookup_commit_reference_gently(&head_oid, 1);
1715+
head_commit = lookup_commit_reference_gently(the_repository,
1716+
&head_oid, 1);
17161717
if (!head_commit)
17171718
return NULL;
17181719

builtin/checkout.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -379,7 +379,7 @@ static int checkout_paths(const struct checkout_opts *opts,
379379
die(_("unable to write new index file"));
380380

381381
read_ref_full("HEAD", 0, &rev, NULL);
382-
head = lookup_commit_reference_gently(&rev, 1);
382+
head = lookup_commit_reference_gently(the_repository, &rev, 1);
383383

384384
errs |= post_checkout_hook(head, head, 0);
385385
return errs;
@@ -830,7 +830,7 @@ static int switch_branches(const struct checkout_opts *opts,
830830
memset(&old_branch_info, 0, sizeof(old_branch_info));
831831
old_branch_info.path = path_to_free = resolve_refdup("HEAD", 0, &rev, &flag);
832832
if (old_branch_info.path)
833-
old_branch_info.commit = lookup_commit_reference_gently(&rev, 1);
833+
old_branch_info.commit = lookup_commit_reference_gently(the_repository, &rev, 1);
834834
if (!(flag & REF_ISSYMREF))
835835
old_branch_info.path = NULL;
836836

@@ -1004,7 +1004,7 @@ static int parse_branchname_arg(int argc, const char **argv,
10041004
else
10051005
new_branch_info->path = NULL; /* not an existing branch */
10061006

1007-
new_branch_info->commit = lookup_commit_reference_gently(rev, 1);
1007+
new_branch_info->commit = lookup_commit_reference_gently(the_repository, rev, 1);
10081008
if (!new_branch_info->commit) {
10091009
/* not a commit */
10101010
*source_tree = parse_tree_indirect(rev);

builtin/describe.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -331,7 +331,8 @@ static void describe_commit(struct object_id *oid, struct strbuf *dst)
331331
init_commit_names(&commit_names);
332332
n = hashmap_iter_first(&names, &iter);
333333
for (; n; n = hashmap_iter_next(&iter)) {
334-
c = lookup_commit_reference_gently(&n->peeled, 1);
334+
c = lookup_commit_reference_gently(the_repository,
335+
&n->peeled, 1);
335336
if (c)
336337
*commit_names_at(&commit_names, c) = n;
337338
}
@@ -509,7 +510,7 @@ static void describe(const char *arg, int last_one)
509510

510511
if (get_oid(arg, &oid))
511512
die(_("Not a valid object name %s"), arg);
512-
cmit = lookup_commit_reference_gently(&oid, 1);
513+
cmit = lookup_commit_reference_gently(the_repository, &oid, 1);
513514

514515
if (cmit)
515516
describe_commit(&oid, &sb);

builtin/fetch.c

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -684,8 +684,10 @@ static int update_local_ref(struct ref *ref,
684684
return r;
685685
}
686686

687-
current = lookup_commit_reference_gently(&ref->old_oid, 1);
688-
updated = lookup_commit_reference_gently(&ref->new_oid, 1);
687+
current = lookup_commit_reference_gently(the_repository,
688+
&ref->old_oid, 1);
689+
updated = lookup_commit_reference_gently(the_repository,
690+
&ref->new_oid, 1);
689691
if (!current || !updated) {
690692
const char *msg;
691693
const char *what;
@@ -818,7 +820,8 @@ static int store_updated_refs(const char *raw_url, const char *remote_name,
818820
continue;
819821
}
820822

821-
commit = lookup_commit_reference_gently(&rm->old_oid,
823+
commit = lookup_commit_reference_gently(the_repository,
824+
&rm->old_oid,
822825
1);
823826
if (!commit)
824827
rm->fetch_head_status = FETCH_HEAD_NOT_FOR_MERGE;

builtin/reflog.c

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,7 @@ static int keep_entry(struct commit **it, struct object_id *oid)
196196

197197
if (is_null_oid(oid))
198198
return 1;
199-
commit = lookup_commit_reference_gently(oid, 1);
199+
commit = lookup_commit_reference_gently(the_repository, oid, 1);
200200
if (!commit)
201201
return 0;
202202

@@ -265,7 +265,8 @@ static int unreachable(struct expire_reflog_policy_cb *cb, struct commit *commit
265265
if (is_null_oid(oid))
266266
return 0;
267267

268-
commit = lookup_commit_reference_gently(oid, 1);
268+
commit = lookup_commit_reference_gently(the_repository, oid,
269+
1);
269270

270271
/* Not a commit -- keep it */
271272
if (!commit)
@@ -322,7 +323,7 @@ static int push_tip_to_list(const char *refname, const struct object_id *oid,
322323
struct commit *tip_commit;
323324
if (flags & REF_ISSYMREF)
324325
return 0;
325-
tip_commit = lookup_commit_reference_gently(oid, 1);
326+
tip_commit = lookup_commit_reference_gently(the_repository, oid, 1);
326327
if (!tip_commit)
327328
return 0;
328329
commit_list_insert(tip_commit, list);
@@ -339,7 +340,8 @@ static void reflog_expiry_prepare(const char *refname,
339340
cb->tip_commit = NULL;
340341
cb->unreachable_expire_kind = UE_HEAD;
341342
} else {
342-
cb->tip_commit = lookup_commit_reference_gently(oid, 1);
343+
cb->tip_commit = lookup_commit_reference_gently(the_repository,
344+
oid, 1);
343345
if (!cb->tip_commit)
344346
cb->unreachable_expire_kind = UE_ALWAYS;
345347
else

builtin/show-branch.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -378,7 +378,8 @@ static void sort_ref_range(int bottom, int top)
378378
static int append_ref(const char *refname, const struct object_id *oid,
379379
int allow_dups)
380380
{
381-
struct commit *commit = lookup_commit_reference_gently(oid, 1);
381+
struct commit *commit = lookup_commit_reference_gently(the_repository,
382+
oid, 1);
382383
int i;
383384

384385
if (!commit)

bundle.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ int verify_bundle(struct bundle_header *header, int verbose)
180180
/* Clean up objects used, as they will be reused. */
181181
for (i = 0; i < p->nr; i++) {
182182
struct ref_list_entry *e = p->list + i;
183-
commit = lookup_commit_reference_gently(&e->oid, 1);
183+
commit = lookup_commit_reference_gently(the_repository, &e->oid, 1);
184184
if (commit)
185185
clear_commit_marks(commit, ALL_REV_FLAGS);
186186
}

commit-graph.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -701,7 +701,7 @@ void write_commit_graph(const char *obj_dir,
701701
if (commit_hex[i] && parse_oid_hex(commit_hex[i], &oid, &end))
702702
continue;
703703

704-
result = lookup_commit_reference_gently(&oid, 1);
704+
result = lookup_commit_reference_gently(the_repository, &oid, 1);
705705

706706
if (result) {
707707
ALLOC_GROW(oids.list, oids.nr + 1, oids.alloc);

commit.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@ int save_commit_buffer = 1;
2424

2525
const char *commit_type = "commit";
2626

27-
struct commit *lookup_commit_reference_gently(const struct object_id *oid,
28-
int quiet)
27+
struct commit *lookup_commit_reference_gently_the_repository(
28+
const struct object_id *oid, int quiet)
2929
{
3030
struct object *obj = deref_tag(parse_object(the_repository, oid),
3131
NULL, 0);
@@ -37,7 +37,7 @@ struct commit *lookup_commit_reference_gently(const struct object_id *oid,
3737

3838
struct commit *lookup_commit_reference(const struct object_id *oid)
3939
{
40-
return lookup_commit_reference_gently(oid, 0);
40+
return lookup_commit_reference_gently(the_repository, oid, 0);
4141
}
4242

4343
struct commit *lookup_commit_or_die(const struct object_id *oid, const char *ref_name)

0 commit comments

Comments
 (0)