midx: mark bad packed objects
authorDerrick Stolee <dstolee@microsoft.com>
Mon, 20 Aug 2018 16:51:57 +0000 (16:51 +0000)
committerJunio C Hamano <gitster@pobox.com>
Mon, 20 Aug 2018 22:31:39 +0000 (15:31 -0700)
When an object fails to decompress from a pack-file, we mark the object
as 'bad' so we can retry with a different copy of the object (if such a
copy exists).

Before now, the multi-pack-index did not update the bad objects list for
the pack-files it contains, and we did not check the bad objects list
when reading an object. Now, do both.

Signed-off-by: Derrick Stolee <dstolee@microsoft.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
midx.c
diff --git a/midx.c b/midx.c
index 6824acf5f8937910edfc74ca0827cec1f4416cfb..7fa75a37a3cd45d69ee5e7eabcd705a14f2bc4d4 100644 (file)
--- a/midx.c
+++ b/midx.c
@@ -280,6 +280,16 @@ static int nth_midxed_pack_entry(struct multi_pack_index *m, struct pack_entry *
        if (!is_pack_valid(p))
                return 0;
 
+       if (p->num_bad_objects) {
+               uint32_t i;
+               struct object_id oid;
+               nth_midxed_object_oid(&oid, m, pos);
+               for (i = 0; i < p->num_bad_objects; i++)
+                       if (!hashcmp(oid.hash,
+                                    p->bad_object_sha1 + the_hash_algo->rawsz * i))
+                               return 0;
+       }
+
        e->offset = nth_midxed_offset(m, pos);
        e->p = p;