packfile: express constants in terms of the_hash_algo
Replace uses of GIT_SHA1_RAWSZ with references to the_hash_algo to avoid dependence on a particular hash length. It's likely that in the future, we'll update the pack format to indicate what hash algorithm it uses, and then this code will change. However, at least on an interim basis, make it easier to develop on a pure SHA-256 Git by using the_hash_algo here. Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
brian m. carlson committed
Oct 15, 2018 at 00:01 UTC
268babd6fb06cfb897d48f7a9adb4828f5f6b45f
1 file changed
+3
-2
packfile.c
+3
-2
@@ -1121,13 +1121,14 @@ int unpack_object_header(struct packed_git *p,
1121
void mark_bad_packed_object(struct packed_git *p, const unsigned char *sha1)
1122
{
1123
unsigned i;
1124
+ const unsigned hashsz = the_hash_algo->rawsz;
1125
for (i = 0; i < p->num_bad_objects; i++)
1125
- if (hasheq(sha1, p->bad_object_sha1 + GIT_SHA1_RAWSZ * i))
1126
+ if (hasheq(sha1, p->bad_object_sha1 + hashsz * i))
1127
return;
1128
p->bad_object_sha1 = xrealloc(p->bad_object_sha1,
1129
st_mult(GIT_MAX_RAWSZ,
1130
st_add(p->num_bad_objects, 1)));
1130
- hashcpy(p->bad_object_sha1 + GIT_SHA1_RAWSZ * p->num_bad_objects, sha1);
1131
+ hashcpy(p->bad_object_sha1 + hashsz * p->num_bad_objects, sha1);
1132
p->num_bad_objects++;
1133
}
1134