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

@@ -665,8 +665,8 @@ static int do_reachable_revlist(struct child_process *cmd,
cmd_in = xfdopen(cmd->in, "w");
for (i = get_max_object_index(); 0 < i; ) {
o = get_indexed_object(--i);
for (i = get_max_object_index(the_repository); 0 < i; ) {
o = get_indexed_object(the_repository, --i);
if (!o)
continue;
if (reachable && o->type == OBJ_COMMIT)
@@ -734,8 +734,8 @@ static int get_reachable_list(struct upload_pack_data *data,
o->flags &= ~TMP_MARK;
}
}
for (i = get_max_object_index(); 0 < i; i--) {
o = get_indexed_object(i - 1);
for (i = get_max_object_index(the_repository); 0 < i; i--) {
o = get_indexed_object(the_repository, i - 1);
if (o && o->type == OBJ_COMMIT &&
(o->flags & TMP_MARK)) {
add_object_array(o, NULL, reachable);
@@ -1557,7 +1557,7 @@ static int parse_want_ref(struct packet_writer *writer, const char *line,
}
if (!o)
o = parse_object_or_die(&oid, refname_nons);
o = parse_object_or_die(the_repository, &oid, refname_nons);
if (!(o->flags & WANTED)) {
o->flags |= WANTED;
@@ -1793,7 +1793,7 @@ int upload_pack_v2(struct repository *r, struct packet_reader *request)
enum fetch_state state = FETCH_PROCESS_ARGS;
struct upload_pack_data data;
clear_object_flags(ALL_FLAGS);
clear_object_flags(the_repository, ALL_FLAGS);
upload_pack_data_init(&data);
data.use_sideband = LARGE_PACKET_MAX;