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

View File

@ -122,7 +122,7 @@ static int parse_next_oid(const char **next, const char *end,
goto invalid;
} else {
/* Without -z, an empty value means all zeros: */
oidclr(oid);
oidclr(oid, the_repository->hash_algo);
}
} else {
/* With -z, read the next NUL-terminated line */
@ -142,7 +142,7 @@ static int parse_next_oid(const char **next, const char *end,
/* With -z, treat an empty value as all zeros: */
warning("%s %s: missing <new-oid>, treating as zero",
command, refname);
oidclr(oid);
oidclr(oid, the_repository->hash_algo);
} else {
/*
* With -z, an empty non-required value means
@ -291,7 +291,7 @@ static void parse_cmd_verify(struct ref_transaction *transaction,
if (parse_next_oid(&next, end, &old_oid, "verify", refname,
PARSE_SHA1_OLD))
oidclr(&old_oid);
oidclr(&old_oid, the_repository->hash_algo);
if (*next != line_termination)
die("verify %s: extra input: %s", refname, next);
@ -564,7 +564,7 @@ int cmd_update_ref(int argc, const char **argv, const char *prefix)
* The empty string implies that the reference
* must not already exist:
*/
oidclr(&oldoid);
oidclr(&oldoid, the_repository->hash_algo);
else if (repo_get_oid(the_repository, oldval, &oldoid))
die("%s: not a valid old SHA1", oldval);
}