Skip to content

Commit 268babd

Browse files
bk2204gitster
authored andcommitted
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>
1 parent fa13080 commit 268babd

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

packfile.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1121,13 +1121,14 @@ int unpack_object_header(struct packed_git *p,
11211121
void mark_bad_packed_object(struct packed_git *p, const unsigned char *sha1)
11221122
{
11231123
unsigned i;
1124+
const unsigned hashsz = the_hash_algo->rawsz;
11241125
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))
11261127
return;
11271128
p->bad_object_sha1 = xrealloc(p->bad_object_sha1,
11281129
st_mult(GIT_MAX_RAWSZ,
11291130
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);
11311132
p->num_bad_objects++;
11321133
}
11331134

0 commit comments

Comments
 (0)