Ensure the pack index is opened before access
In this particular location of fsck the index should have already been opened by verify_pack, which is called just before we get here and loop through the object names. However, just in case a future version of that function does not use the index file we'll double-check its open before we access the num_objects field. Better safe now than sorry later. Signed-off-by: Shawn O. Pearce <spearce@spearce.org> Signed-off-by: Junio C Hamano <junkio@cox.net>
Shawn O. Pearce committed
May 30, 2007 at 02:13 UTC
b77ffe8a57a0921f58cff22dcf1ed6ae64d89d6a
1 file changed
+4
-1
builtin-fsck.c
+4
-1
@@ -668,7 +668,10 @@ int cmd_fsck(int argc, char **argv, const char *prefix)
668
verify_pack(p, 0);
669
670
for (p = packed_git; p; p = p->next) {
671
- uint32_t i, num = p->num_objects;
671
+ uint32_t i, num;
672
+ if (open_pack_index(p))
673
+ continue;
674
+ num = p->num_objects;
675
for (i = 0; i < num; i++)
676
fsck_sha1(nth_packed_object_sha1(p, i));
677
}