Merge branch 'sp/reflog' into next
[gitweb.git] / fsck-objects.c
index cc09143a92a64a0d7e14fb7195cd39c05bb0b49f..1922b6d84c51588b22553141f608c9a07182560b 100644 (file)
@@ -446,6 +446,13 @@ static int fsck_cache_tree(struct cache_tree *it)
 
        if (0 <= it->entry_count) {
                struct object *obj = parse_object(it->sha1);
+               if (!obj) {
+                       error("%s: invalid sha1 pointer in cache-tree",
+                             sha1_to_hex(it->sha1));
+                       return 1;
+               }
+               mark_reachable(obj, REACHABLE);
+               obj->used = 1;
                if (obj->type != tree_type)
                        err |= objerror(obj, "non-tree in cache-tree");
        }