Skip to content

Commit fe5f16e

Browse files
pks-tgitster
authored andcommitted
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>
1 parent 3749853 commit fe5f16e

1 file changed

Lines changed: 13 additions & 15 deletions

File tree

fsck.c

Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
#define USE_THE_REPOSITORY_VARIABLE
2-
31
#include "git-compat-util.h"
42
#include "date.h"
53
#include "dir.h"
@@ -207,7 +205,7 @@ void fsck_set_msg_types(struct fsck_options *options, const char *values)
207205
if (equal == len)
208206
die("skiplist requires a path");
209207
oidset_parse_file(&options->skip_oids, buf + equal + 1,
210-
the_repository->hash_algo);
208+
options->repo->hash_algo);
211209
buf += len + 1;
212210
continue;
213211
}
@@ -360,7 +358,7 @@ static int fsck_walk_tree(struct tree *tree, void *data, struct fsck_options *op
360358
int res = 0;
361359
const char *name;
362360

363-
if (repo_parse_tree(the_repository, tree))
361+
if (repo_parse_tree(options->repo, tree))
364362
return -1;
365363

366364
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
375373
continue;
376374

377375
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);
379377
if (name && obj)
380378
fsck_put_object_name(options, &entry.oid, "%s%s/",
381379
name, entry.path);
382380
result = options->walk(obj, OBJ_TREE, data, options);
383381
}
384382
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);
386384
if (name && obj)
387385
fsck_put_object_name(options, &entry.oid, "%s%s",
388386
name, entry.path);
@@ -409,15 +407,15 @@ static int fsck_walk_commit(struct commit *commit, void *data, struct fsck_optio
409407
int result;
410408
const char *name;
411409

412-
if (repo_parse_commit(the_repository, commit))
410+
if (repo_parse_commit(options->repo, commit))
413411
return -1;
414412

415413
name = fsck_get_object_name(options, &commit->object.oid);
416414
if (name)
417415
fsck_put_object_name(options, get_commit_tree_oid(commit),
418416
"%s:", name);
419417

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),
421419
OBJ_TREE, data, options);
422420
if (result < 0)
423421
return result;
@@ -474,7 +472,7 @@ static int fsck_walk_tag(struct tag *tag, void *data, struct fsck_options *optio
474472
{
475473
const char *name = fsck_get_object_name(options, &tag->object.oid);
476474

477-
if (parse_tag(the_repository, tag))
475+
if (parse_tag(options->repo, tag))
478476
return -1;
479477
if (name)
480478
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)
487485
return -1;
488486

489487
if (obj->type == OBJ_NONE)
490-
parse_object(the_repository, &obj->oid);
488+
parse_object(options->repo, &obj->oid);
491489

492490
switch (obj->type) {
493491
case OBJ_BLOB:
@@ -970,14 +968,14 @@ static int fsck_commit(const struct object_id *oid,
970968

971969
if (buffer >= buffer_end || !skip_prefix(buffer, "tree ", &buffer))
972970
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') {
974972
err = report(options, oid, OBJ_COMMIT, FSCK_MSG_BAD_TREE_SHA1, "invalid 'tree' line format - bad sha1");
975973
if (err)
976974
return err;
977975
}
978976
buffer = p + 1;
979977
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') {
981979
err = report(options, oid, OBJ_COMMIT, FSCK_MSG_BAD_PARENT_SHA1, "invalid 'parent' line format - bad sha1");
982980
if (err)
983981
return err;
@@ -1044,7 +1042,7 @@ int fsck_tag_standalone(const struct object_id *oid, const char *buffer,
10441042
ret = report(options, oid, OBJ_TAG, FSCK_MSG_MISSING_OBJECT, "invalid format - expected 'object' line");
10451043
goto done;
10461044
}
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') {
10481046
ret = report(options, oid, OBJ_TAG, FSCK_MSG_BAD_OBJECT_SHA1, "invalid 'object' line format - bad sha1");
10491047
if (ret)
10501048
goto done;
@@ -1336,9 +1334,9 @@ static int fsck_blobs(struct oidset *blobs_found, struct oidset *blobs_done,
13361334
if (oidset_contains(blobs_done, oid))
13371335
continue;
13381336

1339-
buf = odb_read_object(the_repository->objects, oid, &type, &size);
1337+
buf = odb_read_object(options->repo->objects, oid, &type, &size);
13401338
if (!buf) {
1341-
if (is_promisor_object(the_repository, oid))
1339+
if (is_promisor_object(options->repo, oid))
13421340
continue;
13431341
ret |= report(options,
13441342
oid, OBJ_BLOB, msg_missing,

0 commit comments

Comments
 (0)