summaryrefslogtreecommitdiff
path: root/packfile.c
diff options
context:
space:
mode:
authorbrian m. carlson <sandals@crustytoothpaste.net>2018-10-15 00:01:54 (GMT)
committerJunio C Hamano <gitster@pobox.com>2018-10-15 03:53:15 (GMT)
commit268babd6fb06cfb897d48f7a9adb4828f5f6b45f (patch)
tree2d4afd8ad6c0b8e1fa05289bcd46b61835911d72 /packfile.c
parentfa130802d9ccde50e4097b2b1c5324990be3ffb4 (diff)
downloadgit-268babd6fb06cfb897d48f7a9adb4828f5f6b45f.zip
git-268babd6fb06cfb897d48f7a9adb4828f5f6b45f.tar.gz
git-268babd6fb06cfb897d48f7a9adb4828f5f6b45f.tar.bz2
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>
Diffstat (limited to 'packfile.c')
-rw-r--r--packfile.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/packfile.c b/packfile.c
index 841b361..17f993b 100644
--- a/packfile.c
+++ b/packfile.c
@@ -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++;
}