diff options
author | Edward Thomson <ethomson@vercel.com> | 2023-02-23 13:56:00 +0000 |
---|---|---|
committer | Edward Thomson <ethomson@vercel.com> | 2023-02-23 13:56:00 +0000 |
commit | 7afc57c6527bbeda0a5b66b40f733f176e85edb4 (patch) | |
tree | d2cdae31e644e86695c0e067cc1d5b53941d3e85 /src/libgit2/odb.c | |
parent | c9387a61656cd666d76a0491f6839c1a32835ca0 (diff) | |
download | libgit2-ethomson/sha256_fix.tar.gz |
betterethomson/sha256_fix
Diffstat (limited to 'src/libgit2/odb.c')
-rw-r--r-- | src/libgit2/odb.c | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/src/libgit2/odb.c b/src/libgit2/odb.c index edf4f001f..d50c7df9b 100644 --- a/src/libgit2/odb.c +++ b/src/libgit2/odb.c @@ -587,6 +587,13 @@ static int add_backend_internal( GIT_ERROR_CHECK_VERSION(backend, GIT_ODB_BACKEND_VERSION, "git_odb_backend"); +#ifdef GIT_EXPERIMENTAL_SHA256 + if (!backend->oid_type) { + git_error_set(GIT_ERROR_ODB, "backend oid type is not set"); + return -1; + } +#endif + /* Check if the backend is already owned by another ODB */ GIT_ASSERT(!backend->odb || backend->odb == odb); @@ -1704,7 +1711,6 @@ int git_odb_open_wstream( (error = hash_header(ctx, size, type)) < 0) goto done; - (*stream)->oid_type = db->options.oid_type; (*stream)->hash_ctx = ctx; (*stream)->declared_size = size; (*stream)->received_bytes = 0; @@ -1750,7 +1756,7 @@ int git_odb_stream_finalize_write(git_oid *out, git_odb_stream *stream) git_hash_final(out->id, stream->hash_ctx); #ifdef GIT_EXPERIMENTAL_SHA256 - out->type = stream->oid_type; + out->type = stream->backend->oid_type; #endif if (git_odb__freshen(stream->backend->odb, out)) |