diff options
Diffstat (limited to 'object-file-convert.c')
| -rw-r--r-- | object-file-convert.c | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/object-file-convert.c b/object-file-convert.c index 7ab875afe6..63ee18630b 100644 --- a/object-file-convert.c +++ b/object-file-convert.c @@ -6,14 +6,13 @@ #include "hex.h" #include "repository.h" #include "hash.h" -#include "hash.h" #include "object.h" #include "loose.h" #include "commit.h" #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) { /* @@ -21,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 (!srcoid->algo) { + oidcpy(&temp, srcoid); + temp.algo = hash_algo_by_ptr(repo->hash_algo); + src = &temp; + } - if (from == to) { + if (from == to || !to) { if (src != dest) oidcpy(dest, src); return 0; |
