Skip to content

Commit 94b5e09

Browse files
bk2204gitster
authored andcommitted
sha1-file: convert constants to uses of the_hash_algo
Convert one use of 20 and several uses of GIT_SHA1_HEXSZ into references to the_hash_algo. Signed-off-by: brian m. carlson <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 2ed1960 commit 94b5e09

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

sha1-file.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -336,7 +336,7 @@ int raceproof_create_file(const char *path, create_file_fn fn, void *cb)
336336
static void fill_sha1_path(struct strbuf *buf, const unsigned char *sha1)
337337
{
338338
int i;
339-
for (i = 0; i < 20; i++) {
339+
for (i = 0; i < the_hash_algo->rawsz; i++) {
340340
static char hex[] = "0123456789abcdef";
341341
unsigned int val = sha1[i];
342342
strbuf_addch(buf, hex[val >> 4]);
@@ -1473,7 +1473,7 @@ void *read_object_with_reference(const struct object_id *oid,
14731473
}
14741474
ref_length = strlen(ref_type);
14751475

1476-
if (ref_length + GIT_SHA1_HEXSZ > isize ||
1476+
if (ref_length + the_hash_algo->hexsz > isize ||
14771477
memcmp(buffer, ref_type, ref_length) ||
14781478
get_oid_hex((char *) buffer + ref_length, &actual_oid)) {
14791479
free(buffer);
@@ -2062,9 +2062,9 @@ int for_each_file_in_obj_subdir(unsigned int subdir_nr,
20622062
namelen = strlen(de->d_name);
20632063
strbuf_setlen(path, baselen);
20642064
strbuf_add(path, de->d_name, namelen);
2065-
if (namelen == GIT_SHA1_HEXSZ - 2 &&
2065+
if (namelen == the_hash_algo->hexsz - 2 &&
20662066
!hex_to_bytes(oid.hash + 1, de->d_name,
2067-
GIT_SHA1_RAWSZ - 1)) {
2067+
the_hash_algo->rawsz - 1)) {
20682068
if (obj_cb) {
20692069
r = obj_cb(&oid, path->buf, data);
20702070
if (r)

0 commit comments

Comments
 (0)