]> git.ipfire.org Git - thirdparty/git.git/commitdiff
replace-object: use hash algorithm from passed-in repository
authorPatrick Steinhardt <ps@pks.im>
Fri, 14 Jun 2024 06:50:51 +0000 (08:50 +0200)
committerJunio C Hamano <gitster@pobox.com>
Fri, 14 Jun 2024 17:26:34 +0000 (10:26 -0700)
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>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
replace-object.c

index 73f5acbcd9f8527a5659490f546d580ef50bd3fb..59252d565eff65d057213c603373d116e8f43d61 100644 (file)
@@ -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)) {
                free(repl_obj);
                warning(_("bad replace ref name: %s"), refname);
                return 0;