aboutsummaryrefslogtreecommitdiff
path: root/builtin/fsck.c
diff options
context:
space:
mode:
authorPatrick Steinhardt <ps@pks.im>2026-03-23 16:03:01 +0100
committerJunio C Hamano <gitster@pobox.com>2026-03-23 08:33:11 -0700
commit1c5f77b6103adae5d45ae9ff24e9945b8f8b76c8 (patch)
treed51e0fb5fea98904abb72ea508c340d303865ca4 /builtin/fsck.c
parent2b2287c479ced6f794a7c8d305c39eef4ee563f5 (diff)
downloadgit-1c5f77b6103adae5d45ae9ff24e9945b8f8b76c8.tar.xz
builtin/fsck: stop using `the_repository` when checking packed objects
We implicitly rely on `the_repository` when checking objects part of a packfile. These objects are iterated over via `verify_pack()`, which is provided by the packfile subsystem, and a callback function is then invoked for each of the objects in that specific pack. Unfortunately, it is not possible to provide a payload to the callback function. Refactor `verify_pack()` to accept a payload that is passed through to the callback so that we can inject the repository and get rid of the use of `the_repository`. 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 e8bdec7cd0..22ca1200a2 100644
--- a/builtin/fsck.c
+++ b/builtin/fsck.c
@@ -447,15 +447,16 @@ out:
}
static int fsck_obj_buffer(const struct object_id *oid, enum object_type type,
- unsigned long size, void *buffer, int *eaten)
+ unsigned long size, void *buffer, int *eaten, void *cb_data)
{
+ struct repository *repo = cb_data;
+ struct object *obj;
+
/*
* Note, buffer may be NULL if type is OBJ_BLOB. See
* verify_packfile(), data_valid variable for details.
*/
- struct object *obj;
- obj = parse_object_buffer(the_repository, oid, type, size, buffer,
- eaten);
+ obj = parse_object_buffer(repo, oid, type, size, buffer, eaten);
if (!obj) {
errors_found |= ERROR_OBJECT;
return error(_("%s: object corrupt or missing"),
@@ -1089,7 +1090,7 @@ int cmd_fsck(int argc,
repo_for_each_pack(repo, p) {
/* verify gives error messages itself */
if (verify_pack(repo,
- p, fsck_obj_buffer,
+ p, fsck_obj_buffer, repo,
progress, count))
errors_found |= ERROR_PACK;
count += p->num_objects;