refs/packed-backend: express constants using the_hash_algo

Switch uses of GIT_SHA1_HEXSZ to use the_hash_algo so that they are appropriate for the any given hash length. 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 49d166081bb5ddefa57fd97fd517449264ee5246
1 file changed +7 -7
refs/packed-backend.c
+7 -7
@@ -274,8 +274,8 @@ struct snapshot_record {
274 static int cmp_packed_ref_records(const void *v1, const void *v2)
275 {
276 const struct snapshot_record *e1 = v1, *e2 = v2;
277 - const char *r1 = e1->start + GIT_SHA1_HEXSZ + 1;
278 - const char *r2 = e2->start + GIT_SHA1_HEXSZ + 1;
277 + const char *r1 = e1->start + the_hash_algo->hexsz + 1;
278 + const char *r2 = e2->start + the_hash_algo->hexsz + 1;
279
280 while (1) {
281 if (*r1 == '\n')
@@ -297,7 +297,7 @@ static int cmp_packed_ref_records(const void *v1, const void *v2)
297 */
298 static int cmp_record_to_refname(const char *rec, const char *refname)
299 {
300 - const char *r1 = rec + GIT_SHA1_HEXSZ + 1;
300 + const char *r1 = rec + the_hash_algo->hexsz + 1;
301 const char *r2 = refname;
302
303 while (1) {
@@ -344,7 +344,7 @@ static void sort_snapshot(struct snapshot *snapshot)
344 if (!eol)
345 /* The safety check should prevent this. */
346 BUG("unterminated line found in packed-refs");
347 - if (eol - pos < GIT_SHA1_HEXSZ + 2)
347 + if (eol - pos < the_hash_algo->hexsz + 2)
348 die_invalid_line(snapshot->refs->path,
349 pos, eof - pos);
350 eol++;
@@ -456,7 +456,7 @@ static void verify_buffer_safe(struct snapshot *snapshot)
456 return;
457
458 last_line = find_start_of_record(start, eof - 1);
459 - if (*(eof - 1) != '\n' || eof - last_line < GIT_SHA1_HEXSZ + 2)
459 + if (*(eof - 1) != '\n' || eof - last_line < the_hash_algo->hexsz + 2)
460 die_invalid_line(snapshot->refs->path,
461 last_line, eof - last_line);
462 }
@@ -796,7 +796,7 @@ static int next_record(struct packed_ref_iterator *iter)
796
797 iter->base.flags = REF_ISPACKED;
798
799 - if (iter->eof - p < GIT_SHA1_HEXSZ + 2 ||
799 + if (iter->eof - p < the_hash_algo->hexsz + 2 ||
800 parse_oid_hex(p, &iter->oid, &p) ||
801 !isspace(*p++))
802 die_invalid_line(iter->snapshot->refs->path,
@@ -826,7 +826,7 @@ static int next_record(struct packed_ref_iterator *iter)
826
827 if (iter->pos < iter->eof && *iter->pos == '^') {
828 p = iter->pos + 1;
829 - if (iter->eof - p < GIT_SHA1_HEXSZ + 1 ||
829 + if (iter->eof - p < the_hash_algo->hexsz + 1 ||
830 parse_oid_hex(p, &iter->peeled, &p) ||
831 *p++ != '\n')
832 die_invalid_line(iter->snapshot->refs->path,