diff mbox series

[v3,15/20] replace-object: use hash algorithm from passed-in repository

Message ID e1f4bffea1fde0f34d800d40508a246c5462e41e.1718347699.git.ps@pks.im (mailing list archive)
State Accepted
Commit 99cf4d6d35c7e98dde958e75ff39cd01f2088506
Headers show
Series Introduce `USE_THE_REPOSITORY_VARIABLE` macro | expand

Commit Message

Patrick Steinhardt June 14, 2024, 6:50 a.m. UTC
In `register_replace_ref()`, we pass in a repository but then use
`get_oid_hex()` to parse passed-in object IDs, which implicitly uses
`the_repository`. Fix this by using the hash algorithm from the
passed-in repository instead.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
 replace-object.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
diff mbox series


diff --git a/replace-object.c b/replace-object.c
index 73f5acbcd9..59252d565e 100644
--- a/replace-object.c
+++ b/replace-object.c
@@ -20,7 +20,7 @@  static int register_replace_ref(const char *refname,
 	const char *hash = slash ? slash + 1 : refname;
 	struct replace_object *repl_obj = xmalloc(sizeof(*repl_obj));
-	if (get_oid_hex(hash, &repl_obj->original.oid)) {
+	if (get_oid_hex_algop(hash, &repl_obj->original.oid, r->hash_algo)) {
 		warning(_("bad replace ref name: %s"), refname);
 		return 0;