mirror of
https://github.com/git/git.git
synced 2025-12-12 20:36:24 +01:00
object-file: move loose object map into loose source
The loose object map is used to map from the repository's canonical object hash to the compatibility hash. As the name indicates, this map is only used for loose objects, and as such it is tied to a specific loose object source. Same as with preceding commits, move this map into the loose object source accordingly. Signed-off-by: Patrick Steinhardt <ps@pks.im> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
committed by
Junio C Hamano
parent
be659c97ea
commit
376016ec71
10
loose.c
10
loose.c
@@ -49,7 +49,7 @@ static int insert_loose_map(struct odb_source *source,
|
|||||||
const struct object_id *oid,
|
const struct object_id *oid,
|
||||||
const struct object_id *compat_oid)
|
const struct object_id *compat_oid)
|
||||||
{
|
{
|
||||||
struct loose_object_map *map = source->loose_map;
|
struct loose_object_map *map = source->loose->map;
|
||||||
int inserted = 0;
|
int inserted = 0;
|
||||||
|
|
||||||
inserted |= insert_oid_pair(map->to_compat, oid, compat_oid);
|
inserted |= insert_oid_pair(map->to_compat, oid, compat_oid);
|
||||||
@@ -65,8 +65,8 @@ static int load_one_loose_object_map(struct repository *repo, struct odb_source
|
|||||||
struct strbuf buf = STRBUF_INIT, path = STRBUF_INIT;
|
struct strbuf buf = STRBUF_INIT, path = STRBUF_INIT;
|
||||||
FILE *fp;
|
FILE *fp;
|
||||||
|
|
||||||
if (!source->loose_map)
|
if (!source->loose->map)
|
||||||
loose_object_map_init(&source->loose_map);
|
loose_object_map_init(&source->loose->map);
|
||||||
if (!source->loose->cache) {
|
if (!source->loose->cache) {
|
||||||
ALLOC_ARRAY(source->loose->cache, 1);
|
ALLOC_ARRAY(source->loose->cache, 1);
|
||||||
oidtree_init(source->loose->cache);
|
oidtree_init(source->loose->cache);
|
||||||
@@ -125,7 +125,7 @@ int repo_read_loose_object_map(struct repository *repo)
|
|||||||
|
|
||||||
int repo_write_loose_object_map(struct repository *repo)
|
int repo_write_loose_object_map(struct repository *repo)
|
||||||
{
|
{
|
||||||
kh_oid_map_t *map = repo->objects->sources->loose_map->to_compat;
|
kh_oid_map_t *map = repo->objects->sources->loose->map->to_compat;
|
||||||
struct lock_file lock;
|
struct lock_file lock;
|
||||||
int fd;
|
int fd;
|
||||||
khiter_t iter;
|
khiter_t iter;
|
||||||
@@ -231,7 +231,7 @@ int repo_loose_object_map_oid(struct repository *repo,
|
|||||||
khiter_t pos;
|
khiter_t pos;
|
||||||
|
|
||||||
for (source = repo->objects->sources; source; source = source->next) {
|
for (source = repo->objects->sources; source; source = source->next) {
|
||||||
struct loose_object_map *loose_map = source->loose_map;
|
struct loose_object_map *loose_map = source->loose->map;
|
||||||
if (!loose_map)
|
if (!loose_map)
|
||||||
continue;
|
continue;
|
||||||
map = (to == repo->compat_hash_algo) ?
|
map = (to == repo->compat_hash_algo) ?
|
||||||
|
|||||||
@@ -2014,5 +2014,6 @@ void odb_source_loose_free(struct odb_source_loose *loose)
|
|||||||
if (!loose)
|
if (!loose)
|
||||||
return;
|
return;
|
||||||
odb_source_loose_clear_cache(loose);
|
odb_source_loose_clear_cache(loose);
|
||||||
|
loose_object_map_clear(&loose->map);
|
||||||
free(loose);
|
free(loose);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -32,6 +32,9 @@ struct odb_source_loose {
|
|||||||
*/
|
*/
|
||||||
uint32_t subdir_seen[8]; /* 256 bits */
|
uint32_t subdir_seen[8]; /* 256 bits */
|
||||||
struct oidtree *cache;
|
struct oidtree *cache;
|
||||||
|
|
||||||
|
/* Map between object IDs for loose objects. */
|
||||||
|
struct loose_object_map *map;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct odb_source_loose *odb_source_loose_new(struct odb_source *source);
|
struct odb_source_loose *odb_source_loose_new(struct odb_source *source);
|
||||||
|
|||||||
1
odb.c
1
odb.c
@@ -370,7 +370,6 @@ static void odb_source_free(struct odb_source *source)
|
|||||||
{
|
{
|
||||||
free(source->path);
|
free(source->path);
|
||||||
odb_source_loose_free(source->loose);
|
odb_source_loose_free(source->loose);
|
||||||
loose_object_map_clear(&source->loose_map);
|
|
||||||
free(source);
|
free(source);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
3
odb.h
3
odb.h
@@ -51,9 +51,6 @@ struct odb_source {
|
|||||||
/* Private state for loose objects. */
|
/* Private state for loose objects. */
|
||||||
struct odb_source_loose *loose;
|
struct odb_source_loose *loose;
|
||||||
|
|
||||||
/* Map between object IDs for loose objects. */
|
|
||||||
struct loose_object_map *loose_map;
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* private data
|
* private data
|
||||||
*
|
*
|
||||||
|
|||||||
Reference in New Issue
Block a user