]> git.ipfire.org Git - thirdparty/git.git/commitdiff
conversion: don't crash when no destination algo
authorbrian m. carlson <sandals@crustytoothpaste.net>
Mon, 17 Nov 2025 22:16:08 +0000 (22:16 +0000)
committerJunio C Hamano <gitster@pobox.com>
Mon, 17 Nov 2025 22:24:14 +0000 (14:24 -0800)
When we set up a repository that doesn't have a compatibility hash
algorithm, we set the destination algorithm object to NULL.  In such a
case, we want to silently do nothing instead of crashing, so simply
treat the operation as a no-op and copy the object ID.

Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
object-file-convert.c

index 7ab875afe6cb3ac8fb505a6c25016528fdb29461..e44c8210840c58aad048edd8f3d1a70fbfa20aba 100644 (file)
@@ -23,7 +23,7 @@ int repo_oid_to_algop(struct repository *repo, const struct object_id *src,
        const struct git_hash_algo *from =
                src->algo ? &hash_algos[src->algo] : repo->hash_algo;
 
-       if (from == to) {
+       if (from == to || !to) {
                if (src != dest)
                        oidcpy(dest, src);
                return 0;