mirror of
https://github.com/git/git
synced 2024-08-24 18:26:02 +00:00
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>
This commit is contained in:
parent
fa130802d9
commit
268babd6fb
|
@ -1121,13 +1121,14 @@ int unpack_object_header(struct packed_git *p,
|
|||
void mark_bad_packed_object(struct packed_git *p, const unsigned char *sha1)
|
||||
{
|
||||
unsigned i;
|
||||
const unsigned hashsz = the_hash_algo->rawsz;
|
||||
for (i = 0; i < p->num_bad_objects; i++)
|
||||
if (hasheq(sha1, p->bad_object_sha1 + GIT_SHA1_RAWSZ * i))
|
||||
if (hasheq(sha1, p->bad_object_sha1 + hashsz * i))
|
||||
return;
|
||||
p->bad_object_sha1 = xrealloc(p->bad_object_sha1,
|
||||
st_mult(GIT_MAX_RAWSZ,
|
||||
st_add(p->num_bad_objects, 1)));
|
||||
hashcpy(p->bad_object_sha1 + GIT_SHA1_RAWSZ * p->num_bad_objects, sha1);
|
||||
hashcpy(p->bad_object_sha1 + hashsz * p->num_bad_objects, sha1);
|
||||
p->num_bad_objects++;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue