mirror of
https://github.com/git/git.git
synced 2026-08-08 17:11:48 +00:00
When a repository is configured to use a compatibility hash function
then we load the loose object map when we initialize the repository.
This object map provides the mappings between the canonical object hash
and the compatibility object hash.
Loading the object map happens in `repo_set_compat_hash_algo()`, which
calls `repo_read_loose_object_map()` in case the compatibility object
hash is non-zero. This setup sequence has two major downsides:
- We assume that the primary object database is the "files" object
database and unconditionally downcast it. This will cause us to BUG
in case a different object database type was used together with a
compat hash algorithm.
- We require the object database to already have been initialized when
configuring the object database. This means that we must intermix
configuration of the repository and initialization of its
sub-structures in a weird way.
Refactor the logic so that we instead load the loose object map via the
"loose" backend, which fixes both of the above issues.
Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
28 lines
803 B
C
28 lines
803 B
C
#ifndef LOOSE_H
|
|
#define LOOSE_H
|
|
|
|
#include "khash.h"
|
|
|
|
struct repository;
|
|
struct odb_source_loose;
|
|
|
|
struct loose_object_map {
|
|
kh_oid_map_t *to_compat;
|
|
kh_oid_map_t *to_storage;
|
|
};
|
|
|
|
void loose_object_map_init(struct loose_object_map **map);
|
|
void loose_object_map_clear(struct loose_object_map **map);
|
|
int loose_object_map_load(struct odb_source_loose *loose);
|
|
int repo_loose_object_map_oid(struct repository *repo,
|
|
const struct object_id *src,
|
|
const struct git_hash_algo *dest_algo,
|
|
struct object_id *dest);
|
|
int repo_add_loose_object_map(struct odb_source_loose *loose,
|
|
const struct object_id *oid,
|
|
const struct object_id *compat_oid);
|
|
int repo_read_loose_object_map(struct repository *repo);
|
|
int repo_write_loose_object_map(struct repository *repo);
|
|
|
|
#endif
|