aboutsummaryrefslogtreecommitdiffstats
path: root/object.c
diff options
context:
space:
mode:
authorPatrick Steinhardt <ps@pks.im>2025-03-10 08:13:21 +0100
committerJunio C Hamano <gitster@pobox.com>2025-03-10 13:16:18 -0700
commit74d414c9f14a91a3b7bd04972bf3eb9bbe6fd81b (patch)
tree7a267ede2a7630503346248db75be00cfd828f00 /object.c
parentcsum-file: stop depending on `the_repository` (diff)
downloadgit-74d414c9f14a91a3b7bd04972bf3eb9bbe6fd81b.tar.gz
git-74d414c9f14a91a3b7bd04972bf3eb9bbe6fd81b.zip
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>
Diffstat (limited to 'object.c')
-rw-r--r--object.c21
1 files changed, 11 insertions, 10 deletions
diff --git a/object.c b/object.c
index 100bf9b8d1..154525a497 100644
--- a/object.c
+++ b/object.c
@@ -1,4 +1,3 @@
-#define USE_THE_REPOSITORY_VARIABLE
#define DISABLE_SIGN_COMPARE_WARNINGS
#include "git-compat-util.h"
@@ -18,14 +17,15 @@
#include "commit-graph.h"
#include "loose.h"
-unsigned int get_max_object_index(void)
+unsigned int get_max_object_index(const struct repository *repo)
{
- return the_repository->parsed_objects->obj_hash_size;
+ return repo->parsed_objects->obj_hash_size;
}
-struct object *get_indexed_object(unsigned int idx)
+struct object *get_indexed_object(const struct repository *repo,
+ unsigned int idx)
{
- return the_repository->parsed_objects->obj_hash[idx];
+ return repo->parsed_objects->obj_hash[idx];
}
static const char *object_type_strings[] = {
@@ -283,10 +283,11 @@ struct object *parse_object_buffer(struct repository *r, const struct object_id
return obj;
}
-struct object *parse_object_or_die(const struct object_id *oid,
+struct object *parse_object_or_die(struct repository *repo,
+ const struct object_id *oid,
const char *name)
{
- struct object *o = parse_object(the_repository, oid);
+ struct object *o = parse_object(repo, oid);
if (o)
return o;
@@ -524,12 +525,12 @@ void object_array_remove_duplicates(struct object_array *array)
}
}
-void clear_object_flags(unsigned flags)
+void clear_object_flags(struct repository *repo, unsigned flags)
{
int i;
- for (i=0; i < the_repository->parsed_objects->obj_hash_size; i++) {
- struct object *obj = the_repository->parsed_objects->obj_hash[i];
+ for (i=0; i < repo->parsed_objects->obj_hash_size; i++) {
+ struct object *obj = repo->parsed_objects->obj_hash[i];
if (obj)
obj->flags &= ~flags;
}