Skip to content

Commit 45a187c

Browse files
peffgitster
authored andcommitted
lookup_unknown_object(): take a repository argument
All of the other lookup_foo() functions take a repository argument, but lookup_unknown_object() was never converted, and it uses the_repository internally. Let's fix that. We could leave a wrapper that uses the_repository, but there aren't that many calls, so we'll just convert them all. I looked briefly at each site to see if we had a repository struct (besides the_repository) we could pass, but none of them do (so this conversion to pass the_repository is a pure noop in each case, though it does take us one step closer to eventually getting rid of the_repository). Signed-off-by: Jeff King <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent fcc07e9 commit 45a187c

File tree

9 files changed

+13
-14
lines changed

9 files changed

+13
-14
lines changed

builtin/fsck.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -725,7 +725,7 @@ static int fsck_cache_tree(struct cache_tree *it)
725725

726726
static void mark_object_for_connectivity(const struct object_id *oid)
727727
{
728-
struct object *obj = lookup_unknown_object(oid);
728+
struct object *obj = lookup_unknown_object(the_repository, oid);
729729
obj->flags |= HAS_OBJ;
730730
}
731731

builtin/pack-objects.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3386,7 +3386,7 @@ static void add_objects_in_unpacked_packs(void)
33863386

33873387
for (i = 0; i < p->num_objects; i++) {
33883388
nth_packed_object_id(&oid, p, i);
3389-
o = lookup_unknown_object(&oid);
3389+
o = lookup_unknown_object(the_repository, &oid);
33903390
if (!(o->flags & OBJECT_ADDED))
33913391
mark_in_pack_object(o, p, &in_pack);
33923392
o->flags |= OBJECT_ADDED;

http-push.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1436,7 +1436,7 @@ static void one_remote_ref(const char *refname)
14361436
* may be required for updating server info later.
14371437
*/
14381438
if (repo->can_update_info_refs && !has_object_file(&ref->old_oid)) {
1439-
obj = lookup_unknown_object(&ref->old_oid);
1439+
obj = lookup_unknown_object(the_repository, &ref->old_oid);
14401440
fprintf(stderr, " fetch %s for %s\n",
14411441
oid_to_hex(&ref->old_oid), refname);
14421442
add_fetch_request(obj);

object.c

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -177,12 +177,11 @@ void *object_as_type(struct object *obj, enum object_type type, int quiet)
177177
}
178178
}
179179

180-
struct object *lookup_unknown_object(const struct object_id *oid)
180+
struct object *lookup_unknown_object(struct repository *r, const struct object_id *oid)
181181
{
182-
struct object *obj = lookup_object(the_repository, oid);
182+
struct object *obj = lookup_object(r, oid);
183183
if (!obj)
184-
obj = create_object(the_repository, oid,
185-
alloc_object_node(the_repository));
184+
obj = create_object(r, oid, alloc_object_node(r));
186185
return obj;
187186
}
188187

object.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ struct object *parse_object_or_die(const struct object_id *oid, const char *name
145145
struct object *parse_object_buffer(struct repository *r, const struct object_id *oid, enum object_type type, unsigned long size, void *buffer, int *eaten_p);
146146

147147
/** Returns the object, with potentially excess memory allocated. **/
148-
struct object *lookup_unknown_object(const struct object_id *oid);
148+
struct object *lookup_unknown_object(struct repository *r, const struct object_id *oid);
149149

150150
struct object_list *object_list_insert(struct object *item,
151151
struct object_list **list_p);

refs.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -337,7 +337,7 @@ static int filter_refs(const char *refname, const struct object_id *oid,
337337

338338
enum peel_status peel_object(const struct object_id *name, struct object_id *oid)
339339
{
340-
struct object *o = lookup_unknown_object(name);
340+
struct object *o = lookup_unknown_object(the_repository, name);
341341

342342
if (o->type == OBJ_NONE) {
343343
int type = oid_object_info(the_repository, name, NULL);

t/helper/test-example-decorate.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@ int cmd__example_decorate(int argc, const char **argv)
2626
* Add 2 objects, one with a non-NULL decoration and one with a NULL
2727
* decoration.
2828
*/
29-
one = lookup_unknown_object(&one_oid);
30-
two = lookup_unknown_object(&two_oid);
29+
one = lookup_unknown_object(the_repository, &one_oid);
30+
two = lookup_unknown_object(the_repository, &two_oid);
3131
ret = add_decoration(&n, one, &decoration_a);
3232
if (ret)
3333
BUG("when adding a brand-new object, NULL should be returned");
@@ -56,7 +56,7 @@ int cmd__example_decorate(int argc, const char **argv)
5656
ret = lookup_decoration(&n, two);
5757
if (ret != &decoration_b)
5858
BUG("lookup should return added declaration");
59-
three = lookup_unknown_object(&three_oid);
59+
three = lookup_unknown_object(the_repository, &three_oid);
6060
ret = lookup_decoration(&n, three);
6161
if (ret)
6262
BUG("lookup for unknown object should return NULL");

upload-pack.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1153,7 +1153,7 @@ static void receive_needs(struct upload_pack_data *data,
11531153
static int mark_our_ref(const char *refname, const char *refname_full,
11541154
const struct object_id *oid)
11551155
{
1156-
struct object *o = lookup_unknown_object(oid);
1156+
struct object *o = lookup_unknown_object(the_repository, oid);
11571157

11581158
if (ref_is_hidden(refname, refname_full)) {
11591159
o->flags |= HIDDEN_REF;

walker.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -298,7 +298,7 @@ int walker_fetch(struct walker *walker, int targets, char **target,
298298
error("Could not interpret response from server '%s' as something to pull", target[i]);
299299
goto done;
300300
}
301-
if (process(walker, lookup_unknown_object(&oids[i])))
301+
if (process(walker, lookup_unknown_object(the_repository, &oids[i])))
302302
goto done;
303303
}
304304

0 commit comments

Comments
 (0)