fsck: drop USE_THE_REPOSITORY

Stop using `the_repository` in "fsck.c" in favor of the repository that we've already got available via `struct fsck_options`. Signed-off-by: Patrick Steinhardt <ps@pks.im> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Patrick Steinhardt committed Mar 23, 2026 at 16:02 UTC fe5f16ecc39e2879e5b57925648984b78aaf6339
1 file changed +13 -15
fsck.c
+13 -15
@@ -1,5 +1,3 @@
1 -#define USE_THE_REPOSITORY_VARIABLE
2 -
1 #include "git-compat-util.h"
2 #include "date.h"
3 #include "dir.h"
@@ -207,7 +205,7 @@ void fsck_set_msg_types(struct fsck_options *options, const char *values)
205 if (equal == len)
206 die("skiplist requires a path");
207 oidset_parse_file(&options->skip_oids, buf + equal + 1,
210 - the_repository->hash_algo);
208 + options->repo->hash_algo);
209 buf += len + 1;
210 continue;
211 }
@@ -360,7 +358,7 @@ static int fsck_walk_tree(struct tree *tree, void *data, struct fsck_options *op
358 int res = 0;
359 const char *name;
360
363 - if (repo_parse_tree(the_repository, tree))
361 + if (repo_parse_tree(options->repo, tree))
362 return -1;
363
364 name = fsck_get_object_name(options, &tree->object.oid);
@@ -375,14 +373,14 @@ static int fsck_walk_tree(struct tree *tree, void *data, struct fsck_options *op
373 continue;
374
375 if (S_ISDIR(entry.mode)) {
378 - obj = (struct object *)lookup_tree(the_repository, &entry.oid);
376 + obj = (struct object *)lookup_tree(options->repo, &entry.oid);
377 if (name && obj)
378 fsck_put_object_name(options, &entry.oid, "%s%s/",
379 name, entry.path);
380 result = options->walk(obj, OBJ_TREE, data, options);
381 }
382 else if (S_ISREG(entry.mode) || S_ISLNK(entry.mode)) {
385 - obj = (struct object *)lookup_blob(the_repository, &entry.oid);
383 + obj = (struct object *)lookup_blob(options->repo, &entry.oid);
384 if (name && obj)
385 fsck_put_object_name(options, &entry.oid, "%s%s",
386 name, entry.path);
@@ -409,7 +407,7 @@ static int fsck_walk_commit(struct commit *commit, void *data, struct fsck_optio
407 int result;
408 const char *name;
409
412 - if (repo_parse_commit(the_repository, commit))
410 + if (repo_parse_commit(options->repo, commit))
411 return -1;
412
413 name = fsck_get_object_name(options, &commit->object.oid);
@@ -417,7 +415,7 @@ static int fsck_walk_commit(struct commit *commit, void *data, struct fsck_optio
415 fsck_put_object_name(options, get_commit_tree_oid(commit),
416 "%s:", name);
417
420 - result = options->walk((struct object *) repo_get_commit_tree(the_repository, commit),
418 + result = options->walk((struct object *) repo_get_commit_tree(options->repo, commit),
419 OBJ_TREE, data, options);
420 if (result < 0)
421 return result;
@@ -474,7 +472,7 @@ static int fsck_walk_tag(struct tag *tag, void *data, struct fsck_options *optio
472 {
473 const char *name = fsck_get_object_name(options, &tag->object.oid);
474
477 - if (parse_tag(the_repository, tag))
475 + if (parse_tag(options->repo, tag))
476 return -1;
477 if (name)
478 fsck_put_object_name(options, &tag->tagged->oid, "%s", name);
@@ -487,7 +485,7 @@ int fsck_walk(struct object *obj, void *data, struct fsck_options *options)
485 return -1;
486
487 if (obj->type == OBJ_NONE)
490 - parse_object(the_repository, &obj->oid);
488 + parse_object(options->repo, &obj->oid);
489
490 switch (obj->type) {
491 case OBJ_BLOB:
@@ -970,14 +968,14 @@ static int fsck_commit(const struct object_id *oid,
968
969 if (buffer >= buffer_end || !skip_prefix(buffer, "tree ", &buffer))
970 return report(options, oid, OBJ_COMMIT, FSCK_MSG_MISSING_TREE, "invalid format - expected 'tree' line");
973 - if (parse_oid_hex(buffer, &tree_oid, &p) || *p != '\n') {
971 + if (parse_oid_hex_algop(buffer, &tree_oid, &p, options->repo->hash_algo) || *p != '\n') {
972 err = report(options, oid, OBJ_COMMIT, FSCK_MSG_BAD_TREE_SHA1, "invalid 'tree' line format - bad sha1");
973 if (err)
974 return err;
975 }
976 buffer = p + 1;
977 while (buffer < buffer_end && skip_prefix(buffer, "parent ", &buffer)) {
980 - if (parse_oid_hex(buffer, &parent_oid, &p) || *p != '\n') {
978 + if (parse_oid_hex_algop(buffer, &parent_oid, &p, options->repo->hash_algo) || *p != '\n') {
979 err = report(options, oid, OBJ_COMMIT, FSCK_MSG_BAD_PARENT_SHA1, "invalid 'parent' line format - bad sha1");
980 if (err)
981 return err;
@@ -1044,7 +1042,7 @@ int fsck_tag_standalone(const struct object_id *oid, const char *buffer,
1042 ret = report(options, oid, OBJ_TAG, FSCK_MSG_MISSING_OBJECT, "invalid format - expected 'object' line");
1043 goto done;
1044 }
1047 - if (parse_oid_hex(buffer, tagged_oid, &p) || *p != '\n') {
1045 + if (parse_oid_hex_algop(buffer, tagged_oid, &p, options->repo->hash_algo) || *p != '\n') {
1046 ret = report(options, oid, OBJ_TAG, FSCK_MSG_BAD_OBJECT_SHA1, "invalid 'object' line format - bad sha1");
1047 if (ret)
1048 goto done;
@@ -1336,9 +1334,9 @@ static int fsck_blobs(struct oidset *blobs_found, struct oidset *blobs_done,
1334 if (oidset_contains(blobs_done, oid))
1335 continue;
1336
1339 - buf = odb_read_object(the_repository->objects, oid, &type, &size);
1337 + buf = odb_read_object(options->repo->objects, oid, &type, &size);
1338 if (!buf) {
1341 - if (is_promisor_object(the_repository, oid))
1339 + if (is_promisor_object(options->repo, oid))
1340 continue;
1341 ret |= report(options,
1342 oid, OBJ_BLOB, msg_missing,