hash: require hash algorithm in oidread() and oidclr()

Both `oidread()` and `oidclr()` use `the_repository` to derive the hash
function that shall be used. Require callers to pass in the hash
algorithm to get rid of this implicit dependency.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
Patrick Steinhardt
2024-06-14 08:49:54 +02:00
committed by Junio C Hamano
parent f4836570a7
commit 9da95bda74
48 changed files with 163 additions and 140 deletions

6
dir.c
View File

@@ -1687,7 +1687,7 @@ static void prep_exclude(struct dir_struct *dir,
}
/* Try to read per-directory file */
oidclr(&oid_stat.oid);
oidclr(&oid_stat.oid, the_repository->hash_algo);
oid_stat.valid = 0;
if (dir->exclude_per_dir &&
/*
@@ -3794,7 +3794,7 @@ static void read_oid(size_t pos, void *cb)
rd->data = rd->end + 1;
return;
}
oidread(&ud->exclude_oid, rd->data);
oidread(&ud->exclude_oid, rd->data, the_repository->hash_algo);
rd->data += the_hash_algo->rawsz;
}
@@ -3802,7 +3802,7 @@ static void load_oid_stat(struct oid_stat *oid_stat, const unsigned char *data,
const unsigned char *sha1)
{
stat_data_from_disk(&oid_stat->stat, data);
oidread(&oid_stat->oid, sha1);
oidread(&oid_stat->oid, sha1, the_repository->hash_algo);
oid_stat->valid = 1;
}