Skip to content

Commit 2122f67

Browse files
stefanbellergitster
authored andcommitted
commit: add repository argument to lookup_commit_reference
Add a repository argument to allow callers of lookup_commit_reference 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 21e1ee8 commit 2122f67

27 files changed

+65
-51
lines changed

bisect.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -724,7 +724,7 @@ static int bisect_checkout(const struct object_id *bisect_rev, int no_checkout)
724724

725725
static struct commit *get_commit_reference(const struct object_id *oid)
726726
{
727-
struct commit *r = lookup_commit_reference(oid);
727+
struct commit *r = lookup_commit_reference(the_repository, oid);
728728
if (!r)
729729
die(_("Not a valid commit name %s"), oid_to_hex(oid));
730730
return r;

blame.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ static struct commit_list **append_parent(struct commit_list **tail, const struc
119119
{
120120
struct commit *parent;
121121

122-
parent = lookup_commit_reference(oid);
122+
parent = lookup_commit_reference(the_repository, oid);
123123
if (!parent)
124124
die("no such commit %s", oid_to_hex(oid));
125125
return &commit_list_insert(parent, tail)->next;

branch.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -302,7 +302,7 @@ void create_branch(const char *name, const char *start_name,
302302
break;
303303
}
304304

305-
if ((commit = lookup_commit_reference(&oid)) == NULL)
305+
if ((commit = lookup_commit_reference(the_repository, &oid)) == NULL)
306306
die(_("Not a valid branch point: '%s'."), start_name);
307307
oidcpy(&oid, &commit->object.oid);
308308

builtin/branch.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,8 @@ static int branch_merged(int kind, const char *name,
121121
(reference_name = reference_name_to_free =
122122
resolve_refdup(upstream, RESOLVE_REF_READING,
123123
&oid, NULL)) != NULL)
124-
reference_rev = lookup_commit_reference(&oid);
124+
reference_rev = lookup_commit_reference(the_repository,
125+
&oid);
125126
}
126127
if (!reference_rev)
127128
reference_rev = head_rev;
@@ -154,7 +155,7 @@ static int check_branch_commit(const char *branchname, const char *refname,
154155
const struct object_id *oid, struct commit *head_rev,
155156
int kinds, int force)
156157
{
157-
struct commit *rev = lookup_commit_reference(oid);
158+
struct commit *rev = lookup_commit_reference(the_repository, oid);
158159
if (!rev) {
159160
error(_("Couldn't look up commit object for '%s'"), refname);
160161
return -1;
@@ -208,7 +209,7 @@ static int delete_branches(int argc, const char **argv, int force, int kinds,
208209
}
209210

210211
if (!force) {
211-
head_rev = lookup_commit_reference(&head_oid);
212+
head_rev = lookup_commit_reference(the_repository, &head_oid);
212213
if (!head_rev)
213214
die(_("Couldn't look up commit object for HEAD"));
214215
}

builtin/clone.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -696,7 +696,8 @@ static void update_head(const struct ref *our, const struct ref *remote,
696696
install_branch_config(0, head, option_origin, our->name);
697697
}
698698
} else if (our) {
699-
struct commit *c = lookup_commit_reference(&our->old_oid);
699+
struct commit *c = lookup_commit_reference(the_repository,
700+
&our->old_oid);
700701
/* --branch specifies a non-branch (i.e. tags), detach HEAD */
701702
update_ref(msg, "HEAD", &c->object.oid, NULL, REF_NO_DEREF,
702703
UPDATE_REFS_DIE_ON_ERR);

builtin/describe.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -303,7 +303,7 @@ static void describe_commit(struct object_id *oid, struct strbuf *dst)
303303
unsigned long seen_commits = 0;
304304
unsigned int unannotated_cnt = 0;
305305

306-
cmit = lookup_commit_reference(oid);
306+
cmit = lookup_commit_reference(the_repository, oid);
307307

308308
n = find_commit_name(&cmit->object.oid);
309309
if (n && (tags || all || n->prio == 2)) {

builtin/diff-tree.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ static struct rev_info log_tree_opt;
1111

1212
static int diff_tree_commit_oid(const struct object_id *oid)
1313
{
14-
struct commit *commit = lookup_commit_reference(oid);
14+
struct commit *commit = lookup_commit_reference(the_repository, oid);
1515
if (!commit)
1616
return -1;
1717
return log_tree_commit(&log_tree_opt, commit);

builtin/log.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -907,8 +907,8 @@ static void get_patch_ids(struct rev_info *rev, struct patch_ids *ids)
907907
o2 = rev->pending.objects[1].item;
908908
flags1 = o1->flags;
909909
flags2 = o2->flags;
910-
c1 = lookup_commit_reference(&o1->oid);
911-
c2 = lookup_commit_reference(&o2->oid);
910+
c1 = lookup_commit_reference(the_repository, &o1->oid);
911+
c2 = lookup_commit_reference(the_repository, &o2->oid);
912912

913913
if ((flags1 & UNINTERESTING) == (flags2 & UNINTERESTING))
914914
die(_("Not a range."));
@@ -1864,7 +1864,8 @@ static int add_pending_commit(const char *arg, struct rev_info *revs, int flags)
18641864
{
18651865
struct object_id oid;
18661866
if (get_oid(arg, &oid) == 0) {
1867-
struct commit *commit = lookup_commit_reference(&oid);
1867+
struct commit *commit = lookup_commit_reference(the_repository,
1868+
&oid);
18681869
if (commit) {
18691870
commit->object.flags |= flags;
18701871
add_pending_object(revs, &commit->object, arg);

builtin/merge-base.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
#include "diff.h"
77
#include "revision.h"
88
#include "parse-options.h"
9+
#include "repository.h"
910

1011
static int show_merge_base(struct commit **rev, int rev_nr, int show_all)
1112
{
@@ -42,7 +43,7 @@ static struct commit *get_commit_reference(const char *arg)
4243

4344
if (get_oid(arg, &revkey))
4445
die("Not a valid object name %s", arg);
45-
r = lookup_commit_reference(&revkey);
46+
r = lookup_commit_reference(the_repository, &revkey);
4647
if (!r)
4748
die("Not a valid commit name %s", arg);
4849

@@ -171,7 +172,7 @@ static int handle_fork_point(int argc, const char **argv)
171172
if (get_oid(commitname, &oid))
172173
die("Not a valid object name: '%s'", commitname);
173174

174-
derived = lookup_commit_reference(&oid);
175+
derived = lookup_commit_reference(the_repository, &oid);
175176
memset(&revs, 0, sizeof(revs));
176177
revs.initial = 1;
177178
for_each_reflog_ent(refname, collect_one_reflog_ent, &revs);

builtin/notes.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
#include "builtin.h"
1313
#include "notes.h"
1414
#include "object-store.h"
15+
#include "repository.h"
1516
#include "blob.h"
1617
#include "pretty.h"
1718
#include "refs.h"
@@ -711,7 +712,7 @@ static int merge_commit(struct notes_merge_options *o)
711712

712713
if (get_oid("NOTES_MERGE_PARTIAL", &oid))
713714
die(_("failed to read ref NOTES_MERGE_PARTIAL"));
714-
else if (!(partial = lookup_commit_reference(&oid)))
715+
else if (!(partial = lookup_commit_reference(the_repository, &oid)))
715716
die(_("could not find commit from NOTES_MERGE_PARTIAL."));
716717
else if (parse_commit(partial))
717718
die(_("could not parse commit from NOTES_MERGE_PARTIAL."));

0 commit comments

Comments
 (0)