fsck-cache: notice missing "blob" objects.
[git.git] / fsck-cache.c
index edaf9e4..985adb6 100644 (file)
@@ -21,7 +21,7 @@ static void check_connectivity(void)
                struct object *obj = objs[i];
 
                if (show_unreachable && !(obj->flags & REACHABLE)) {
-                       printf("unreachable %s\n", sha1_to_hex(obj->sha1));
+                       printf("unreachable %s %s\n", obj->type, sha1_to_hex(obj->sha1));
                        continue;
                }
 
@@ -60,11 +60,19 @@ static int fsck_commit(unsigned char *sha1, void *data, unsigned long size)
        return 0;
 }
 
+static int fsck_blob(unsigned char *sha1, void *data, unsigned long size)
+{
+       struct blob *blob = lookup_blob(sha1);
+       blob->object.parsed = 1;
+       return 0;
+}
+
 static int fsck_entry(unsigned char *sha1, char *tag, void *data, 
                      unsigned long size)
 {
        if (!strcmp(tag, "blob")) {
-               lookup_blob(sha1); /* Nothing to check; but notice it. */
+               if (fsck_blob(sha1, data, size) < 0)
+                       return -1;
        } else if (!strcmp(tag, "tree")) {
                if (fsck_tree(sha1, data, size) < 0)
                        return -1;
@@ -85,12 +93,13 @@ static int fsck_name(char *hex)
                if (map) {
                        char type[100];
                        unsigned long size;
-                       void *buffer = NULL;
-                       if (!check_sha1_signature(sha1, map, mapsize))
-                               buffer = unpack_sha1_file(map, mapsize, type,
-                                                         &size);
+                       void *buffer = unpack_sha1_file(map, mapsize, type, &size);
+                       if (!buffer)
+                               return -1;
+                       if (check_sha1_signature(sha1, buffer, size, type) < 0)
+                               printf("sha1 mismatch %s\n", sha1_to_hex(sha1));
                        munmap(map, mapsize);
-                       if (buffer && !fsck_entry(sha1, type, buffer, size))
+                       if (!fsck_entry(sha1, type, buffer, size))
                                return 0;
                }
        }