object: stop depending on the_repository

There are a couple of functions exposed by "object.c" that implicitly
depend on `the_repository`. Remove this dependency by injecting the
repository via a parameter. Adapt callers accordingly by simply using
`the_repository`, except in cases where the subsystem is already free of
the repository. In that case, we instead pass the repository provided by
the caller's context.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
Patrick Steinhardt
2025-03-10 08:13:21 +01:00
committed by Junio C Hamano
parent 228457c9d9
commit 74d414c9f1
15 changed files with 48 additions and 44 deletions

View File

@@ -169,12 +169,13 @@ int type_from_string_gently(const char *str, ssize_t, int gentle);
/*
* Return the current number of buckets in the object hashmap.
*/
unsigned int get_max_object_index(void);
unsigned int get_max_object_index(const struct repository *repo);
/*
* Return the object from the specified bucket in the object hashmap.
*/
struct object *get_indexed_object(unsigned int);
struct object *get_indexed_object(const struct repository *repo,
unsigned int);
/*
* This can be used to see if we have heard of the object before, but
@@ -231,7 +232,8 @@ struct object *parse_object_with_flags(struct repository *r,
* "name" parameter is not NULL, it is included in the error message
* (otherwise, the hex object ID is given).
*/
struct object *parse_object_or_die(const struct object_id *oid, const char *name);
struct object *parse_object_or_die(struct repository *repo, const struct object_id *oid,
const char *name);
/* Given the result of read_sha1_file(), returns the object after
* parsing it. eaten_p indicates if the object has a borrowed copy
@@ -336,7 +338,7 @@ void object_array_remove_duplicates(struct object_array *array);
*/
void object_array_clear(struct object_array *array);
void clear_object_flags(unsigned flags);
void clear_object_flags(struct repository *repo, unsigned flags);
/*
* Clear the specified object flags from all in-core commit objects from