X-Git-Url: http://git.ipfire.org/?a=blobdiff_plain;f=fsck.c;h=90857e122d8be640469dba29894e65ac53d71692;hb=c251c83df276dc0bff4d008433268ad59b7a8df2;hp=939792752bf39c72cc536f00c21e2af8ed854c3e;hpb=2b69d3116ffb4a800c408b8cb0b508ca1886ea84;p=thirdparty%2Fgit.git diff --git a/fsck.c b/fsck.c index 939792752b..90857e122d 100644 --- a/fsck.c +++ b/fsck.c @@ -132,10 +132,10 @@ static int fsck_msg_type(enum fsck_msg_id msg_id, static void init_skiplist(struct fsck_options *options, const char *path) { - static struct sha1_array skiplist = SHA1_ARRAY_INIT; + static struct oid_array skiplist = OID_ARRAY_INIT; int sorted, fd; - char buffer[41]; - unsigned char sha1[20]; + char buffer[GIT_MAX_HEXSZ + 1]; + struct object_id oid; if (options->skiplist) sorted = options->skiplist->sorted; @@ -148,17 +148,18 @@ static void init_skiplist(struct fsck_options *options, const char *path) if (fd < 0) die("Could not open skip list: %s", path); for (;;) { + const char *p; int result = read_in_full(fd, buffer, sizeof(buffer)); if (result < 0) die_errno("Could not read '%s'", path); if (!result) break; - if (get_sha1_hex(buffer, sha1) || buffer[40] != '\n') + if (parse_oid_hex(buffer, &oid, &p) || *p != '\n') die("Invalid SHA-1: %s", buffer); - sha1_array_append(&skiplist, sha1); + oid_array_append(&skiplist, &oid); if (sorted && skiplist.nr > 1 && - hashcmp(skiplist.sha1[skiplist.nr - 2], - sha1) > 0) + oidcmp(&skiplist.oid[skiplist.nr - 2], + &oid) > 0) sorted = 0; } close(fd); @@ -279,7 +280,7 @@ static int report(struct fsck_options *options, struct object *object, return 0; if (options->skiplist && object && - sha1_array_lookup(options->skiplist, object->oid.hash) >= 0) + oid_array_lookup(options->skiplist, &object->oid) >= 0) return 0; if (msg_type == FSCK_FATAL) @@ -357,14 +358,14 @@ static int fsck_walk_tree(struct tree *tree, void *data, struct fsck_options *op continue; if (S_ISDIR(entry.mode)) { - obj = &lookup_tree(entry.oid->hash)->object; + obj = &lookup_tree(entry.oid)->object; if (name) put_object_name(options, obj, "%s%s/", name, entry.path); result = options->walk(obj, OBJ_TREE, data, options); } else if (S_ISREG(entry.mode) || S_ISLNK(entry.mode)) { - obj = &lookup_blob(entry.oid->hash)->object; + obj = &lookup_blob(entry.oid)->object; if (name) put_object_name(options, obj, "%s%s", name, entry.path); @@ -460,7 +461,7 @@ int fsck_walk(struct object *obj, void *data, struct fsck_options *options) return -1; if (obj->type == OBJ_NONE) - parse_object(obj->oid.hash); + parse_object(&obj->oid); switch (obj->type) { case OBJ_BLOB: