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 <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Jeff King committed
Apr 13, 2021 at 03:16 UTC
45a187cc34b5016842b91ef14b59e40505afff46
9 files changed
+13
-14
builtin/fsck.c
+1
-1
@@ -725,7 +725,7 @@ static int fsck_cache_tree(struct cache_tree *it)
725
726
static void mark_object_for_connectivity(const struct object_id *oid)
727
{
728
- struct object *obj = lookup_unknown_object(oid);
728
+ struct object *obj = lookup_unknown_object(the_repository, oid);
729
obj->flags |= HAS_OBJ;
730
}
731
builtin/pack-objects.c
+1
-1
@@ -3386,7 +3386,7 @@ static void add_objects_in_unpacked_packs(void)
3386
3387
for (i = 0; i < p->num_objects; i++) {
3388
nth_packed_object_id(&oid, p, i);
3389
- o = lookup_unknown_object(&oid);
3389
+ o = lookup_unknown_object(the_repository, &oid);
3390
if (!(o->flags & OBJECT_ADDED))
3391
mark_in_pack_object(o, p, &in_pack);
3392
o->flags |= OBJECT_ADDED;
http-push.c
+1
-1
@@ -1436,7 +1436,7 @@ static void one_remote_ref(const char *refname)
1436
* may be required for updating server info later.
1437
*/
1438
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);
1440
fprintf(stderr, " fetch %s for %s\n",
1441
oid_to_hex(&ref->old_oid), refname);
1442
add_fetch_request(obj);
object.c
+3
-4
@@ -177,12 +177,11 @@ void *object_as_type(struct object *obj, enum object_type type, int quiet)
177
}
178
}
179
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)
181
{
182
- struct object *obj = lookup_object(the_repository, oid);
182
+ struct object *obj = lookup_object(r, oid);
183
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));
185
return obj;
186
}
187
object.h
+1
-1
@@ -145,7 +145,7 @@ struct object *parse_object_or_die(const struct object_id *oid, const char *name
145
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);
146
147
/** 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);
149
150
struct object_list *object_list_insert(struct object *item,
151
struct object_list **list_p);
refs.c
+1
-1
@@ -337,7 +337,7 @@ static int filter_refs(const char *refname, const struct object_id *oid,
337
338
enum peel_status peel_object(const struct object_id *name, struct object_id *oid)
339
{
340
- struct object *o = lookup_unknown_object(name);
340
+ struct object *o = lookup_unknown_object(the_repository, name);
341
342
if (o->type == OBJ_NONE) {
343
int type = oid_object_info(the_repository, name, NULL);
t/helper/test-example-decorate.c
+3
-3
@@ -26,8 +26,8 @@ int cmd__example_decorate(int argc, const char **argv)
26
* Add 2 objects, one with a non-NULL decoration and one with a NULL
27
* decoration.
28
*/
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);
31
ret = add_decoration(&n, one, &decoration_a);
32
if (ret)
33
BUG("when adding a brand-new object, NULL should be returned");
@@ -56,7 +56,7 @@ int cmd__example_decorate(int argc, const char **argv)
56
ret = lookup_decoration(&n, two);
57
if (ret != &decoration_b)
58
BUG("lookup should return added declaration");
59
- three = lookup_unknown_object(&three_oid);
59
+ three = lookup_unknown_object(the_repository, &three_oid);
60
ret = lookup_decoration(&n, three);
61
if (ret)
62
BUG("lookup for unknown object should return NULL");
upload-pack.c
+1
-1
@@ -1153,7 +1153,7 @@ static void receive_needs(struct upload_pack_data *data,
1153
static int mark_our_ref(const char *refname, const char *refname_full,
1154
const struct object_id *oid)
1155
{
1156
- struct object *o = lookup_unknown_object(oid);
1156
+ struct object *o = lookup_unknown_object(the_repository, oid);
1157
1158
if (ref_is_hidden(refname, refname_full)) {
1159
o->flags |= HIDDEN_REF;
walker.c
+1
-1
@@ -298,7 +298,7 @@ int walker_fetch(struct walker *walker, int targets, char **target,
298
error("Could not interpret response from server '%s' as something to pull", target[i]);
299
goto done;
300
}
301
- if (process(walker, lookup_unknown_object(&oids[i])))
301
+ if (process(walker, lookup_unknown_object(the_repository, &oids[i])))
302
goto done;
303
}
304