convert "hashcmp() == 0" to hasheq()
This is the partner patch to the previous one, but covering the "hash" variants instead of "oid". Note that our coccinelle rule is slightly more complex to avoid triggering the call in hasheq(). I didn't bother to add a new rule to convert: - hasheq(E1->hash, E2->hash) + oideq(E1, E2) Since these are new functions, there won't be any such existing callers. And since most of the code is already using oideq, we're not likely to introduce new ones. We might still see "!hashcmp(E1->hash, E2->hash)" from topics in flight. But because our new rule comes after the existing ones, that should first get converted to "!oidcmp(E1, E2)" and then to "oideq(E1, E2)". Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:

committed by
Junio C Hamano

parent
4a7e27e957
commit
e3ff0683e2
10
packfile.c
10
packfile.c
@ -1015,7 +1015,7 @@ void mark_bad_packed_object(struct packed_git *p, const unsigned char *sha1)
|
||||
{
|
||||
unsigned i;
|
||||
for (i = 0; i < p->num_bad_objects; i++)
|
||||
if (!hashcmp(sha1, p->bad_object_sha1 + GIT_SHA1_RAWSZ * i))
|
||||
if (hasheq(sha1, p->bad_object_sha1 + GIT_SHA1_RAWSZ * i))
|
||||
return;
|
||||
p->bad_object_sha1 = xrealloc(p->bad_object_sha1,
|
||||
st_mult(GIT_MAX_RAWSZ,
|
||||
@ -1031,8 +1031,8 @@ const struct packed_git *has_packed_and_bad(const unsigned char *sha1)
|
||||
|
||||
for (p = the_repository->objects->packed_git; p; p = p->next)
|
||||
for (i = 0; i < p->num_bad_objects; i++)
|
||||
if (!hashcmp(sha1,
|
||||
p->bad_object_sha1 + the_hash_algo->rawsz * i))
|
||||
if (hasheq(sha1,
|
||||
p->bad_object_sha1 + the_hash_algo->rawsz * i))
|
||||
return p;
|
||||
return NULL;
|
||||
}
|
||||
@ -1830,8 +1830,8 @@ static int fill_pack_entry(const struct object_id *oid,
|
||||
if (p->num_bad_objects) {
|
||||
unsigned i;
|
||||
for (i = 0; i < p->num_bad_objects; i++)
|
||||
if (!hashcmp(oid->hash,
|
||||
p->bad_object_sha1 + the_hash_algo->rawsz * i))
|
||||
if (hasheq(oid->hash,
|
||||
p->bad_object_sha1 + the_hash_algo->rawsz * i))
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user