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

Diff for: archive.c

+1-1
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;

Diff for: bisect.c

+1-1
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;

Diff for: blame.c

+7-6
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)

Diff for: blob.c

+5-5
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)

Diff for: blob.h

+1-1
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

Diff for: branch.c

+1-1
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

Diff for: builtin/am.c

+6-3
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"));

Diff for: builtin/branch.c

+4-3
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
}

Diff for: builtin/checkout.c

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

Diff for: builtin/clone.c

+2-1
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);

Diff for: builtin/commit-tree.c

+3-1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
#include "cache.h"
77
#include "config.h"
88
#include "object-store.h"
9+
#include "repository.h"
910
#include "commit.h"
1011
#include "tree.h"
1112
#include "builtin.h"
@@ -60,7 +61,8 @@ int cmd_commit_tree(int argc, const char **argv, const char *prefix)
6061
if (get_oid_commit(argv[i], &oid))
6162
die("Not a valid object name %s", argv[i]);
6263
assert_oid_type(&oid, OBJ_COMMIT);
63-
new_parent(lookup_commit(&oid), &parents);
64+
new_parent(lookup_commit(the_repository, &oid),
65+
&parents);
6466
continue;
6567
}
6668

Diff for: builtin/describe.c

+7-6
Original file line numberDiff line numberDiff line change
@@ -93,13 +93,13 @@ static int replace_name(struct commit_name *e,
9393
struct tag *t;
9494

9595
if (!e->tag) {
96-
t = lookup_tag(&e->oid);
96+
t = lookup_tag(the_repository, &e->oid);
9797
if (!t || parse_tag(t))
9898
return 1;
9999
e->tag = t;
100100
}
101101

102-
t = lookup_tag(oid);
102+
t = lookup_tag(the_repository, oid);
103103
if (!t || parse_tag(t))
104104
return 0;
105105
*tag = t;
@@ -267,7 +267,7 @@ static unsigned long finish_depth_computation(
267267
static void append_name(struct commit_name *n, struct strbuf *dst)
268268
{
269269
if (n->prio == 2 && !n->tag) {
270-
n->tag = lookup_tag(&n->oid);
270+
n->tag = lookup_tag(the_repository, &n->oid);
271271
if (!n->tag || parse_tag(n->tag))
272272
die(_("annotated tag %s not available"), n->path);
273273
}
@@ -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)) {
@@ -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);

Diff for: builtin/diff-tree.c

+5-4
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,13 @@
55
#include "log-tree.h"
66
#include "builtin.h"
77
#include "submodule.h"
8+
#include "repository.h"
89

910
static struct rev_info log_tree_opt;
1011

1112
static int diff_tree_commit_oid(const struct object_id *oid)
1213
{
13-
struct commit *commit = lookup_commit_reference(oid);
14+
struct commit *commit = lookup_commit_reference(the_repository, oid);
1415
if (!commit)
1516
return -1;
1617
return log_tree_commit(&log_tree_opt, commit);
@@ -24,7 +25,7 @@ static int stdin_diff_commit(struct commit *commit, const char *p)
2425

2526
/* Graft the fake parents locally to the commit */
2627
while (isspace(*p++) && !parse_oid_hex(p, &oid, &p)) {
27-
struct commit *parent = lookup_commit(&oid);
28+
struct commit *parent = lookup_commit(the_repository, &oid);
2829
if (!pptr) {
2930
/* Free the real parent list */
3031
free_commit_list(commit->parents);
@@ -45,7 +46,7 @@ static int stdin_diff_trees(struct tree *tree1, const char *p)
4546
struct tree *tree2;
4647
if (!isspace(*p++) || parse_oid_hex(p, &oid, &p) || *p)
4748
return error("Need exactly two trees, separated by a space");
48-
tree2 = lookup_tree(&oid);
49+
tree2 = lookup_tree(the_repository, &oid);
4950
if (!tree2 || parse_tree(tree2))
5051
return -1;
5152
printf("%s %s\n", oid_to_hex(&tree1->object.oid),
@@ -68,7 +69,7 @@ static int diff_tree_stdin(char *line)
6869
line[len-1] = 0;
6970
if (parse_oid_hex(line, &oid, &p))
7071
return -1;
71-
obj = parse_object(&oid);
72+
obj = parse_object(the_repository, &oid);
7273
if (!obj)
7374
return -1;
7475
if (obj->type == OBJ_COMMIT)

Diff for: builtin/diff.c

+4-3
Original file line numberDiff line numberDiff line change
@@ -386,7 +386,8 @@ int cmd_diff(int argc, const char **argv, const char *prefix)
386386
add_head_to_pending(&rev);
387387
if (!rev.pending.nr) {
388388
struct tree *tree;
389-
tree = lookup_tree(the_hash_algo->empty_tree);
389+
tree = lookup_tree(the_repository,
390+
the_repository->hash_algo->empty_tree);
390391
add_pending_object(&rev, &tree->object, "HEAD");
391392
}
392393
break;
@@ -400,8 +401,8 @@ int cmd_diff(int argc, const char **argv, const char *prefix)
400401
const char *name = entry->name;
401402
int flags = (obj->flags & UNINTERESTING);
402403
if (!obj->parsed)
403-
obj = parse_object(&obj->oid);
404-
obj = deref_tag(obj, NULL, 0);
404+
obj = parse_object(the_repository, &obj->oid);
405+
obj = deref_tag(the_repository, obj, NULL, 0);
405406
if (!obj)
406407
die(_("invalid object '%s' given."), name);
407408
if (obj->type == OBJ_COMMIT)

Diff for: builtin/fast-export.c

+8-6
Original file line numberDiff line numberDiff line change
@@ -230,21 +230,22 @@ static void export_blob(const struct object_id *oid)
230230
if (is_null_oid(oid))
231231
return;
232232

233-
object = lookup_object(oid->hash);
233+
object = lookup_object(the_repository, oid->hash);
234234
if (object && object->flags & SHOWN)
235235
return;
236236

237237
if (anonymize) {
238238
buf = anonymize_blob(&size);
239-
object = (struct object *)lookup_blob(oid);
239+
object = (struct object *)lookup_blob(the_repository, oid);
240240
eaten = 0;
241241
} else {
242242
buf = read_object_file(oid, &type, &size);
243243
if (!buf)
244244
die ("Could not read blob %s", oid_to_hex(oid));
245245
if (check_object_signature(oid, buf, size, type_name(type)) < 0)
246246
die("sha1 mismatch in blob %s", oid_to_hex(oid));
247-
object = parse_object_buffer(oid, type, size, buf, &eaten);
247+
object = parse_object_buffer(the_repository, oid, type,
248+
size, buf, &eaten);
248249
}
249250

250251
if (!object)
@@ -402,7 +403,8 @@ static void show_filemodify(struct diff_queue_struct *q,
402403
anonymize_sha1(&spec->oid) :
403404
spec->oid.hash));
404405
else {
405-
struct object *object = lookup_object(spec->oid.hash);
406+
struct object *object = lookup_object(the_repository,
407+
spec->oid.hash);
406408
printf("M %06o :%d ", spec->mode,
407409
get_object_mark(object));
408410
}
@@ -801,7 +803,7 @@ static struct commit *get_commit(struct rev_cmdline_entry *e, char *full_name)
801803

802804
/* handle nested tags */
803805
while (tag && tag->object.type == OBJ_TAG) {
804-
parse_object(&tag->object.oid);
806+
parse_object(the_repository, &tag->object.oid);
805807
string_list_append(&extra_refs, full_name)->util = tag;
806808
tag = (struct tag *)tag->tagged;
807809
}
@@ -961,7 +963,7 @@ static void import_marks(char *input_file)
961963
/* only commits */
962964
continue;
963965

964-
commit = lookup_commit(&oid);
966+
commit = lookup_commit(the_repository, &oid);
965967
if (!commit)
966968
die("not a commit? can't happen: %s", oid_to_hex(&oid));
967969

0 commit comments

Comments
 (0)