aboutsummaryrefslogtreecommitdiff
path: root/builtin/fsck.c
diff options
context:
space:
mode:
authorPatrick Steinhardt <ps@pks.im>2026-03-23 16:02:58 +0100
committerJunio C Hamano <gitster@pobox.com>2026-03-23 08:33:10 -0700
commit3ea779432d28b0229ef2a64e6a73a9018ad4c940 (patch)
tree1a016a67abe6aa051550d6d56059ca63557504e0 /builtin/fsck.c
parent4c44db7dc55c1aac0d0414ed22c27ea965cc2c77 (diff)
downloadgit-3ea779432d28b0229ef2a64e6a73a9018ad4c940.tar.xz
builtin/fsck: stop using `the_repository` when checking refs
We implicitly rely on `the_repository` when checking refs. Refactor this to instead inject the repository via the callback payload. Signed-off-by: Patrick Steinhardt <ps@pks.im> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'builtin/fsck.c')
-rw-r--r--builtin/fsck.c11
1 files changed, 6 insertions, 5 deletions
diff --git a/builtin/fsck.c b/builtin/fsck.c
index edbff16add..efc60862ae 100644
--- a/builtin/fsck.c
+++ b/builtin/fsck.c
@@ -574,11 +574,12 @@ static int snapshot_ref(const struct reference *ref, void *cb_data)
return 0;
}
-static int fsck_handle_ref(const struct reference *ref, void *cb_data UNUSED)
+static int fsck_handle_ref(const struct reference *ref, void *cb_data)
{
+ struct repository *repo = cb_data;
struct object *obj;
- obj = parse_object(the_repository, ref->oid);
+ obj = parse_object(repo, ref->oid);
obj->flags |= USED;
fsck_put_object_name(&fsck_walk_options,
ref->oid, "%s", ref->name);
@@ -665,7 +666,7 @@ static void free_snapshot_refs(struct snapshot *snap)
free(snap->ref);
}
-static void process_refs(struct snapshot *snap)
+static void process_refs(struct repository *repo, struct snapshot *snap)
{
struct worktree **worktrees, **p;
@@ -674,7 +675,7 @@ static void process_refs(struct snapshot *snap)
.name = snap->ref[i].refname,
.oid = &snap->ref[i].oid,
};
- fsck_handle_ref(&ref, NULL);
+ fsck_handle_ref(&ref, repo);
}
if (include_reflogs) {
@@ -1095,7 +1096,7 @@ int cmd_fsck(int argc,
}
/* Process the snapshotted refs and the reflogs. */
- process_refs(&snap);
+ process_refs(repo, &snap);
/* If not given any explicit objects, process index files too. */
if (!argc)