Skip to content

Commit 3ea7794

Browse files
pks-tgitster
authored andcommitted
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>
1 parent 4c44db7 commit 3ea7794

1 file changed

Lines changed: 6 additions & 5 deletions

File tree

builtin/fsck.c

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -574,11 +574,12 @@ static int snapshot_ref(const struct reference *ref, void *cb_data)
574574
return 0;
575575
}
576576

577-
static int fsck_handle_ref(const struct reference *ref, void *cb_data UNUSED)
577+
static int fsck_handle_ref(const struct reference *ref, void *cb_data)
578578
{
579+
struct repository *repo = cb_data;
579580
struct object *obj;
580581

581-
obj = parse_object(the_repository, ref->oid);
582+
obj = parse_object(repo, ref->oid);
582583
obj->flags |= USED;
583584
fsck_put_object_name(&fsck_walk_options,
584585
ref->oid, "%s", ref->name);
@@ -665,7 +666,7 @@ static void free_snapshot_refs(struct snapshot *snap)
665666
free(snap->ref);
666667
}
667668

668-
static void process_refs(struct snapshot *snap)
669+
static void process_refs(struct repository *repo, struct snapshot *snap)
669670
{
670671
struct worktree **worktrees, **p;
671672

@@ -674,7 +675,7 @@ static void process_refs(struct snapshot *snap)
674675
.name = snap->ref[i].refname,
675676
.oid = &snap->ref[i].oid,
676677
};
677-
fsck_handle_ref(&ref, NULL);
678+
fsck_handle_ref(&ref, repo);
678679
}
679680

680681
if (include_reflogs) {
@@ -1095,7 +1096,7 @@ int cmd_fsck(int argc,
10951096
}
10961097

10971098
/* Process the snapshotted refs and the reflogs. */
1098-
process_refs(&snap);
1099+
process_refs(repo, &snap);
10991100

11001101
/* If not given any explicit objects, process index files too. */
11011102
if (!argc)

0 commit comments

Comments
 (0)