Skip to content

Commit 49d1660

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

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

refs/packed-backend.c

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -274,8 +274,8 @@ struct snapshot_record {
274274
static int cmp_packed_ref_records(const void *v1, const void *v2)
275275
{
276276
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;
279279

280280
while (1) {
281281
if (*r1 == '\n')
@@ -297,7 +297,7 @@ static int cmp_packed_ref_records(const void *v1, const void *v2)
297297
*/
298298
static int cmp_record_to_refname(const char *rec, const char *refname)
299299
{
300-
const char *r1 = rec + GIT_SHA1_HEXSZ + 1;
300+
const char *r1 = rec + the_hash_algo->hexsz + 1;
301301
const char *r2 = refname;
302302

303303
while (1) {
@@ -344,7 +344,7 @@ static void sort_snapshot(struct snapshot *snapshot)
344344
if (!eol)
345345
/* The safety check should prevent this. */
346346
BUG("unterminated line found in packed-refs");
347-
if (eol - pos < GIT_SHA1_HEXSZ + 2)
347+
if (eol - pos < the_hash_algo->hexsz + 2)
348348
die_invalid_line(snapshot->refs->path,
349349
pos, eof - pos);
350350
eol++;
@@ -456,7 +456,7 @@ static void verify_buffer_safe(struct snapshot *snapshot)
456456
return;
457457

458458
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)
460460
die_invalid_line(snapshot->refs->path,
461461
last_line, eof - last_line);
462462
}
@@ -796,7 +796,7 @@ static int next_record(struct packed_ref_iterator *iter)
796796

797797
iter->base.flags = REF_ISPACKED;
798798

799-
if (iter->eof - p < GIT_SHA1_HEXSZ + 2 ||
799+
if (iter->eof - p < the_hash_algo->hexsz + 2 ||
800800
parse_oid_hex(p, &iter->oid, &p) ||
801801
!isspace(*p++))
802802
die_invalid_line(iter->snapshot->refs->path,
@@ -826,7 +826,7 @@ static int next_record(struct packed_ref_iterator *iter)
826826

827827
if (iter->pos < iter->eof && *iter->pos == '^') {
828828
p = iter->pos + 1;
829-
if (iter->eof - p < GIT_SHA1_HEXSZ + 1 ||
829+
if (iter->eof - p < the_hash_algo->hexsz + 1 ||
830830
parse_oid_hex(p, &iter->peeled, &p) ||
831831
*p++ != '\n')
832832
die_invalid_line(iter->snapshot->refs->path,

0 commit comments

Comments
 (0)