@matheusbsbs / matheus-bagliano / commits / b8b00f1693
Fork 0

fsck: drop blob struct from fsck_finish()

Since fsck_blob() no longer requires us to have a "struct blob", we don't need to create one. Which also means we don't need to worry about handling the case that lookup_blob() returns NULL (we'll still catch wrongly-identified blobs when we read the actual object contents and type from disk). Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Jeff King committed Oct 18, 2019 at 00:59 UTC b8b00f1693c149ba03e34d56d8804256e74f6eab
1 file changed +4 -14
fsck.c
+4 -14
@@ -1013,7 +1013,6 @@ int fsck_finish(struct fsck_options *options)
1013
1014 oidset_iter_init(&gitmodules_found, &iter);
1015 while ((oid = oidset_iter_next(&iter))) {
1016 - struct blob *blob;
1016 enum object_type type;
1017 unsigned long size;
1018 char *buf;
@@ -1021,31 +1020,22 @@ int fsck_finish(struct fsck_options *options)
1020 if (oidset_contains(&gitmodules_done, oid))
1021 continue;
1022
1024 - blob = lookup_blob(the_repository, oid);
1025 - if (!blob) {
1026 - struct object *obj = lookup_unknown_object(oid);
1027 - ret |= report(options, &obj->oid, obj->type,
1028 - FSCK_MSG_GITMODULES_BLOB,
1029 - "non-blob found at .gitmodules");
1030 - continue;
1031 - }
1032 -
1023 buf = read_object_file(oid, &type, &size);
1024 if (!buf) {
1035 - if (is_promisor_object(&blob->object.oid))
1025 + if (is_promisor_object(oid))
1026 continue;
1027 ret |= report(options,
1038 - &blob->object.oid, blob->object.type,
1028 + oid, OBJ_BLOB,
1029 FSCK_MSG_GITMODULES_MISSING,
1030 "unable to read .gitmodules blob");
1031 continue;
1032 }
1033
1034 if (type == OBJ_BLOB)
1045 - ret |= fsck_blob(&blob->object.oid, buf, size, options);
1035 + ret |= fsck_blob(oid, buf, size, options);
1036 else
1037 ret |= report(options,
1048 - &blob->object.oid, blob->object.type,
1038 + oid, type,
1039 FSCK_MSG_GITMODULES_BLOB,
1040 "non-blob found at .gitmodules");
1041 free(buf);