]> git.ipfire.org Git - thirdparty/git.git/commitdiff
lookup_unknown_object(): take a repository argument
authorJeff King <peff@peff.net>
Tue, 13 Apr 2021 07:16:36 +0000 (03:16 -0400)
committerJunio C Hamano <gitster@pobox.com>
Tue, 13 Apr 2021 20:18:46 +0000 (13:18 -0700)
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>
builtin/fsck.c
builtin/pack-objects.c
http-push.c
object.c
object.h
refs.c
t/helper/test-example-decorate.c
upload-pack.c
walker.c

index 70ff95837aee4f40271a4de596c63dd4fa02b18f..e6a80e540421f63a8fad9a02d2c9f34278e51b43 100644 (file)
@@ -725,7 +725,7 @@ static int fsck_cache_tree(struct cache_tree *it)
 
 static void mark_object_for_connectivity(const struct object_id *oid)
 {
-       struct object *obj = lookup_unknown_object(oid);
+       struct object *obj = lookup_unknown_object(the_repository, oid);
        obj->flags |= HAS_OBJ;
 }
 
index 525c2d85529f41bc56fb3495f9f7e9dec9557c81..c1186f50a3e55984d1014883076324864f2a3b31 100644 (file)
@@ -3386,7 +3386,7 @@ static void add_objects_in_unpacked_packs(void)
 
                for (i = 0; i < p->num_objects; i++) {
                        nth_packed_object_id(&oid, p, i);
-                       o = lookup_unknown_object(&oid);
+                       o = lookup_unknown_object(the_repository, &oid);
                        if (!(o->flags & OBJECT_ADDED))
                                mark_in_pack_object(o, p, &in_pack);
                        o->flags |= OBJECT_ADDED;
index b60d5fcc85dd18f9a6747d662c0c039d0362f982..813123242e8194ac799a026cc79fb1d8e1668cca 100644 (file)
@@ -1436,7 +1436,7 @@ static void one_remote_ref(const char *refname)
         * may be required for updating server info later.
         */
        if (repo->can_update_info_refs && !has_object_file(&ref->old_oid)) {
-               obj = lookup_unknown_object(&ref->old_oid);
+               obj = lookup_unknown_object(the_repository, &ref->old_oid);
                fprintf(stderr, "  fetch %s for %s\n",
                        oid_to_hex(&ref->old_oid), refname);
                add_fetch_request(obj);
index 78343781ae77d6f60be8d7477422f883e2966cca..14188453c56706e0c364c995946bdc16d3d97fea 100644 (file)
--- a/object.c
+++ b/object.c
@@ -177,12 +177,11 @@ void *object_as_type(struct object *obj, enum object_type type, int quiet)
        }
 }
 
-struct object *lookup_unknown_object(const struct object_id *oid)
+struct object *lookup_unknown_object(struct repository *r, const struct object_id *oid)
 {
-       struct object *obj = lookup_object(the_repository, oid);
+       struct object *obj = lookup_object(r, oid);
        if (!obj)
-               obj = create_object(the_repository, oid,
-                                   alloc_object_node(the_repository));
+               obj = create_object(r, oid, alloc_object_node(r));
        return obj;
 }
 
index 59daadce21453c707bb439d047725b40d95f153d..87a6da47c8797993875afe40a283a8c87ad1726e 100644 (file)
--- a/object.h
+++ b/object.h
@@ -145,7 +145,7 @@ struct object *parse_object_or_die(const struct object_id *oid, const char *name
 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);
 
 /** Returns the object, with potentially excess memory allocated. **/
-struct object *lookup_unknown_object(const struct object_id *oid);
+struct object *lookup_unknown_object(struct repository *r, const struct object_id *oid);
 
 struct object_list *object_list_insert(struct object *item,
                                       struct object_list **list_p);
diff --git a/refs.c b/refs.c
index 261fd82beb98fdfcfc641fa7605d37b86aac2184..1616c7554a17053c8c43ab56414eefb23377c1bc 100644 (file)
--- a/refs.c
+++ b/refs.c
@@ -337,7 +337,7 @@ static int filter_refs(const char *refname, const struct object_id *oid,
 
 enum peel_status peel_object(const struct object_id *name, struct object_id *oid)
 {
-       struct object *o = lookup_unknown_object(name);
+       struct object *o = lookup_unknown_object(the_repository, name);
 
        if (o->type == OBJ_NONE) {
                int type = oid_object_info(the_repository, name, NULL);
index c8a1cde7d2de96461f74aabad6a5d664eeb8eefa..b9d1200eb988e19f3f0a2c0aeed941a6eb44b9bb 100644 (file)
@@ -26,8 +26,8 @@ int cmd__example_decorate(int argc, const char **argv)
         * Add 2 objects, one with a non-NULL decoration and one with a NULL
         * decoration.
         */
-       one = lookup_unknown_object(&one_oid);
-       two = lookup_unknown_object(&two_oid);
+       one = lookup_unknown_object(the_repository, &one_oid);
+       two = lookup_unknown_object(the_repository, &two_oid);
        ret = add_decoration(&n, one, &decoration_a);
        if (ret)
                BUG("when adding a brand-new object, NULL should be returned");
@@ -56,7 +56,7 @@ int cmd__example_decorate(int argc, const char **argv)
        ret = lookup_decoration(&n, two);
        if (ret != &decoration_b)
                BUG("lookup should return added declaration");
-       three = lookup_unknown_object(&three_oid);
+       three = lookup_unknown_object(the_repository, &three_oid);
        ret = lookup_decoration(&n, three);
        if (ret)
                BUG("lookup for unknown object should return NULL");
index e19583ae0fbebbdf6f9d6f4c89580332a8a16307..5c1cd196125a1900ee1dbb34c078c34b151bca39 100644 (file)
@@ -1153,7 +1153,7 @@ static void receive_needs(struct upload_pack_data *data,
 static int mark_our_ref(const char *refname, const char *refname_full,
                        const struct object_id *oid)
 {
-       struct object *o = lookup_unknown_object(oid);
+       struct object *o = lookup_unknown_object(the_repository, oid);
 
        if (ref_is_hidden(refname, refname_full)) {
                o->flags |= HIDDEN_REF;
index 4984bf8b3d6658dc2571f66bd5142e67c0fe7d37..c5e292197956487c2a44f84f7839126d3a796cfc 100644 (file)
--- a/walker.c
+++ b/walker.c
@@ -298,7 +298,7 @@ int walker_fetch(struct walker *walker, int targets, char **target,
                        error("Could not interpret response from server '%s' as something to pull", target[i]);
                        goto done;
                }
-               if (process(walker, lookup_unknown_object(&oids[i])))
+               if (process(walker, lookup_unknown_object(the_repository, &oids[i])))
                        goto done;
        }