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:
committed by
Junio C Hamano
parent
228457c9d9
commit
74d414c9f1
21
object.c
21
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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user