packfile: convert has_packed_and_bad() to object_id

The single caller has a full object ID, so pass it on instead of just its hash member. Signed-off-by: René Scharfe <l.s.r@web.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>

René Scharfe committed Sep 11, 2021 at 22:42 UTC 7407d733a4a99cf946cab0c82e03c41dbd305b7c
3 files changed +4 -4
object-file.c
+1 -1
@@ -1725,7 +1725,7 @@ void *read_object_file_extended(struct repository *r,
1725 die(_("loose object %s (stored in %s) is corrupt"),
1726 oid_to_hex(repl), path);
1727
1728 - if ((p = has_packed_and_bad(r, repl->hash)) != NULL)
1728 + if ((p = has_packed_and_bad(r, repl)) != NULL)
1729 die(_("packed object %s (stored in %s) is corrupt"),
1730 oid_to_hex(repl), p->pack_name);
1731 obj_read_unlock();
packfile.c
+2 -2
@@ -1176,14 +1176,14 @@ void mark_bad_packed_object(struct packed_git *p, const struct object_id *oid)
1176 }
1177
1178 const struct packed_git *has_packed_and_bad(struct repository *r,
1179 - const unsigned char *sha1)
1179 + const struct object_id *oid)
1180 {
1181 struct packed_git *p;
1182 unsigned i;
1183
1184 for (p = r->objects->packed_git; p; p = p->next)
1185 for (i = 0; i < p->num_bad_objects; i++)
1186 - if (hasheq(sha1,
1186 + if (hasheq(oid->hash,
1187 p->bad_object_sha1 + the_hash_algo->rawsz * i))
1188 return p;
1189 return NULL;
packfile.h
+1 -1
@@ -160,7 +160,7 @@ int packed_object_info(struct repository *r,
160 off_t offset, struct object_info *);
161
162 void mark_bad_packed_object(struct packed_git *, const struct object_id *);
163 -const struct packed_git *has_packed_and_bad(struct repository *r, const unsigned char *sha1);
163 +const struct packed_git *has_packed_and_bad(struct repository *, const struct object_id *);
164
165 #define ON_DISK_KEEP_PACKS 1
166 #define IN_CORE_KEEP_PACKS 2