Skip to content

Commit 3a2a1dc

Browse files
committed
Merge branch 'sb/object-store-lookup'
lookup_commit_reference() and friends have been updated to find in-core object for a specific in-core repository instance. * sb/object-store-lookup: (32 commits) commit.c: allow lookup_commit_reference to handle arbitrary repositories commit.c: allow lookup_commit_reference_gently to handle arbitrary repositories tag.c: allow deref_tag to handle arbitrary repositories object.c: allow parse_object to handle arbitrary repositories object.c: allow parse_object_buffer to handle arbitrary repositories commit.c: allow get_cached_commit_buffer to handle arbitrary repositories commit.c: allow set_commit_buffer to handle arbitrary repositories commit.c: migrate the commit buffer to the parsed object store commit-slabs: remove realloc counter outside of slab struct commit.c: allow parse_commit_buffer to handle arbitrary repositories tag: allow parse_tag_buffer to handle arbitrary repositories tag: allow lookup_tag to handle arbitrary repositories commit: allow lookup_commit to handle arbitrary repositories tree: allow lookup_tree to handle arbitrary repositories blob: allow lookup_blob to handle arbitrary repositories object: allow lookup_object to handle arbitrary repositories object: allow object_as_type to handle arbitrary repositories tag: add repository argument to deref_tag tag: add repository argument to parse_tag_buffer tag: add repository argument to lookup_tag ...
2 parents 6566a91 + 1f6c72f commit 3a2a1dc

Some content is hidden

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

82 files changed

+487
-361
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;

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: 7 additions & 6 deletions
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;
@@ -158,7 +158,7 @@ static void set_commit_buffer_from_strbuf(struct commit *c, struct strbuf *sb)
158158
{
159159
size_t len;
160160
void *buf = strbuf_detach(sb, &len);
161-
set_commit_buffer(c, buf, len);
161+
set_commit_buffer(the_repository, c, buf, len);
162162
}
163163

164164
/*
@@ -1674,7 +1674,7 @@ static struct commit *find_single_final(struct rev_info *revs,
16741674
struct object *obj = revs->pending.objects[i].item;
16751675
if (obj->flags & UNINTERESTING)
16761676
continue;
1677-
obj = deref_tag(obj, NULL, 0);
1677+
obj = deref_tag(the_repository, obj, NULL, 0);
16781678
if (obj->type != OBJ_COMMIT)
16791679
die("Non commit %s?", revs->pending.objects[i].name);
16801680
if (found)
@@ -1705,14 +1705,15 @@ static struct commit *dwim_reverse_initial(struct rev_info *revs,
17051705

17061706
/* Is that sole rev a committish? */
17071707
obj = revs->pending.objects[0].item;
1708-
obj = deref_tag(obj, NULL, 0);
1708+
obj = deref_tag(the_repository, obj, NULL, 0);
17091709
if (obj->type != OBJ_COMMIT)
17101710
return NULL;
17111711

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

@@ -1740,7 +1741,7 @@ static struct commit *find_single_initial(struct rev_info *revs,
17401741
struct object *obj = revs->pending.objects[i].item;
17411742
if (!(obj->flags & UNINTERESTING))
17421743
continue;
1743-
obj = deref_tag(obj, NULL, 0);
1744+
obj = deref_tag(the_repository, obj, NULL, 0);
17441745
if (obj->type != OBJ_COMMIT)
17451746
die("Non commit %s?", revs->pending.objects[i].name);
17461747
if (found)

blob.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,13 @@
55

66
const char *blob_type = "blob";
77

8-
struct blob *lookup_blob(const struct object_id *oid)
8+
struct blob *lookup_blob(struct repository *r, const struct object_id *oid)
99
{
10-
struct object *obj = lookup_object(oid->hash);
10+
struct object *obj = lookup_object(r, oid->hash);
1111
if (!obj)
12-
return create_object(the_repository, oid->hash,
13-
alloc_blob_node(the_repository));
14-
return object_as_type(obj, OBJ_BLOB, 0);
12+
return create_object(r, oid->hash,
13+
alloc_blob_node(r));
14+
return object_as_type(r, obj, OBJ_BLOB, 0);
1515
}
1616

1717
int parse_blob_buffer(struct blob *item, void *buffer, unsigned long size)

blob.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ struct blob {
99
struct object object;
1010
};
1111

12-
struct blob *lookup_blob(const struct object_id *oid);
12+
struct blob *lookup_blob(struct repository *r, const struct object_id *oid);
1313

1414
int parse_blob_buffer(struct blob *item, void *buffer, unsigned long size);
1515

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/am.c

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
#include "apply.h"
3333
#include "string-list.h"
3434
#include "packfile.h"
35+
#include "repository.h"
3536

3637
/**
3738
* Returns 1 if the file is empty or does not exist, 0 otherwise.
@@ -1400,9 +1401,10 @@ static void write_index_patch(const struct am_state *state)
14001401
FILE *fp;
14011402

14021403
if (!get_oid_tree("HEAD", &head))
1403-
tree = lookup_tree(&head);
1404+
tree = lookup_tree(the_repository, &head);
14041405
else
1405-
tree = lookup_tree(the_hash_algo->empty_tree);
1406+
tree = lookup_tree(the_repository,
1407+
the_repository->hash_algo->empty_tree);
14061408

14071409
fp = xfopen(am_path(state, "patch"), "w");
14081410
init_revisions(&rev_info, NULL);
@@ -1631,7 +1633,8 @@ static void do_commit(const struct am_state *state)
16311633

16321634
if (!get_oid_commit("HEAD", &parent)) {
16331635
old_oid = &parent;
1634-
commit_list_insert(lookup_commit(&parent), &parents);
1636+
commit_list_insert(lookup_commit(the_repository, &parent),
1637+
&parents);
16351638
} else {
16361639
old_oid = NULL;
16371640
say(state, stderr, _("applying to an empty history"));

builtin/branch.c

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

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

builtin/checkout.c

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

382382
read_ref_full("HEAD", 0, &rev, NULL);
383-
head = lookup_commit_reference_gently(&rev, 1);
383+
head = lookup_commit_reference_gently(the_repository, &rev, 1);
384384

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

@@ -1009,7 +1009,7 @@ static int parse_branchname_arg(int argc, const char **argv,
10091009
else
10101010
new_branch_info->path = NULL; /* not an existing branch */
10111011

1012-
new_branch_info->commit = lookup_commit_reference_gently(rev, 1);
1012+
new_branch_info->commit = lookup_commit_reference_gently(the_repository, rev, 1);
10131013
if (!new_branch_info->commit) {
10141014
/* not a commit */
10151015
*source_tree = parse_tree_indirect(rev);

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);

0 commit comments

Comments
 (0)