diff options
| author | Junio C Hamano <gitster@pobox.com> | 2024-03-28 14:13:50 -0700 |
|---|---|---|
| committer | Junio C Hamano <gitster@pobox.com> | 2024-03-28 14:13:50 -0700 |
| commit | 1002f28a527d33893f7dab068dbac7011f84af65 (patch) | |
| tree | 9b9ada23d952e936d496597d03064c10d8d9f73d /repository.c | |
| parent | c75fd8d8150afdf836b63a8e0534d9b9e3e111ba (diff) | |
| parent | 7673ecd2dcdcf0aae01cccdb5c25f9b96160a8c0 (diff) | |
| download | git-1002f28a527d33893f7dab068dbac7011f84af65.tar.gz | |
Merge branch 'eb/hash-transition'
Work to support a repository that work with both SHA-1 and SHA-256
hash algorithms has started.
* eb/hash-transition: (30 commits)
t1016-compatObjectFormat: add tests to verify the conversion between objects
t1006: test oid compatibility with cat-file
t1006: rename sha1 to oid
test-lib: compute the compatibility hash so tests may use it
builtin/ls-tree: let the oid determine the output algorithm
object-file: handle compat objects in check_object_signature
tree-walk: init_tree_desc take an oid to get the hash algorithm
builtin/cat-file: let the oid determine the output algorithm
rev-parse: add an --output-object-format parameter
repository: implement extensions.compatObjectFormat
object-file: update object_info_extended to reencode objects
object-file-convert: convert commits that embed signed tags
object-file-convert: convert commit objects when writing
object-file-convert: don't leak when converting tag objects
object-file-convert: convert tag objects when writing
object-file-convert: add a function to convert trees between algorithms
object: factor out parse_mode out of fast-import and tree-walk into in object.h
cache: add a function to read an OID of a specific algorithm
tag: sign both hashes
commit: export add_header_signature to support handling signatures on tags
...
Diffstat (limited to 'repository.c')
| -rw-r--r-- | repository.c | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/repository.c b/repository.c index 7aacb51b65..e15b416944 100644 --- a/repository.c +++ b/repository.c @@ -14,6 +14,7 @@ #include "read-cache-ll.h" #include "remote.h" #include "setup.h" +#include "loose.h" #include "submodule-config.h" #include "sparse-index.h" #include "trace2.h" @@ -104,6 +105,15 @@ void repo_set_hash_algo(struct repository *repo, int hash_algo) repo->hash_algo = &hash_algos[hash_algo]; } +void repo_set_compat_hash_algo(struct repository *repo, int algo) +{ + if (hash_algo_by_ptr(repo->hash_algo) == algo) + BUG("hash_algo and compat_hash_algo match"); + repo->compat_hash_algo = algo ? &hash_algos[algo] : NULL; + if (repo->compat_hash_algo) + repo_read_loose_object_map(repo); +} + void repo_set_ref_storage_format(struct repository *repo, unsigned int format) { repo->ref_storage_format = format; @@ -189,6 +199,7 @@ int repo_init(struct repository *repo, goto error; repo_set_hash_algo(repo, format.hash_algo); + repo_set_compat_hash_algo(repo, format.compat_hash_algo); repo_set_ref_storage_format(repo, format.ref_storage_format); repo->repository_format_worktree_config = format.worktree_config; @@ -199,6 +210,9 @@ int repo_init(struct repository *repo, if (worktree) repo_set_worktree(repo, worktree); + if (repo->compat_hash_algo) + repo_read_loose_object_map(repo); + clear_repository_format(&format); return 0; |
