aboutsummaryrefslogtreecommitdiff
path: root/object-file-convert.c
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2026-03-12 10:56:02 -0700
committerJunio C Hamano <gitster@pobox.com>2026-03-12 10:56:02 -0700
commit8194f1795bf0ca36f245adccc84bc86ab2aa90d1 (patch)
treec8d1bc1cc14dd618832cd9d2a5a932c33b27fd22 /object-file-convert.c
parent7f19e4e1b6a3ad259e2ed66033e01e03b8b74c5e (diff)
parentd49f23ae2f9def3c9065738bccbb9ca8dfb4b0f0 (diff)
downloadgit-8194f1795bf0ca36f245adccc84bc86ab2aa90d1.tar.xz
Merge branch 'bc/sha1-256-interop-02'
The code to maintain mapping between object names in multiple hash functions is being added, written in Rust. * bc/sha1-256-interop-02: object-file-convert: always make sure object ID algo is valid rust: add a small wrapper around the hashfile code rust: add a new binary object map format rust: add functionality to hash an object rust: add a build.rs script for tests rust: fix linking binaries with cargo hash: expose hash context functions to Rust write-or-die: add an fsync component for the object map csum-file: define hashwrite's count as a uint32_t rust: add additional helpers for ObjectID hash: add a function to look up hash algo structs rust: add a hash algorithm abstraction rust: add a ObjectID struct hash: use uint32_t for object_id algorithm conversion: don't crash when no destination algo repository: require Rust support for interoperability
Diffstat (limited to 'object-file-convert.c')
-rw-r--r--object-file-convert.c14
1 files changed, 11 insertions, 3 deletions
diff --git a/object-file-convert.c b/object-file-convert.c
index 7813286596..63ee18630b 100644
--- a/object-file-convert.c
+++ b/object-file-convert.c
@@ -12,7 +12,7 @@
#include "gpg-interface.h"
#include "object-file-convert.h"
-int repo_oid_to_algop(struct repository *repo, const struct object_id *src,
+int repo_oid_to_algop(struct repository *repo, const struct object_id *srcoid,
const struct git_hash_algo *to, struct object_id *dest)
{
/*
@@ -20,9 +20,17 @@ int repo_oid_to_algop(struct repository *repo, const struct object_id *src,
* default hash algorithm for that object.
*/
const struct git_hash_algo *from =
- src->algo ? &hash_algos[src->algo] : repo->hash_algo;
+ srcoid->algo ? &hash_algos[srcoid->algo] : repo->hash_algo;
+ struct object_id temp;
+ const struct object_id *src = srcoid;
- if (from == to) {
+ if (!srcoid->algo) {
+ oidcpy(&temp, srcoid);
+ temp.algo = hash_algo_by_ptr(repo->hash_algo);
+ src = &temp;
+ }
+
+ if (from == to || !to) {
if (src != dest)
oidcpy(dest, src);
return 0;