|
3 | 3 | #include "path.h" |
4 | 4 | #include "object-file.h" |
5 | 5 | #include "odb.h" |
| 6 | +#include "odb/source-files.h" |
6 | 7 | #include "hex.h" |
7 | 8 | #include "repository.h" |
8 | 9 | #include "wrapper.h" |
@@ -49,27 +50,29 @@ static int insert_loose_map(struct odb_source *source, |
49 | 50 | const struct object_id *oid, |
50 | 51 | const struct object_id *compat_oid) |
51 | 52 | { |
52 | | - struct loose_object_map *map = source->loose->map; |
| 53 | + struct odb_source_files *files = odb_source_files_downcast(source); |
| 54 | + struct loose_object_map *map = files->loose->map; |
53 | 55 | int inserted = 0; |
54 | 56 |
|
55 | 57 | inserted |= insert_oid_pair(map->to_compat, oid, compat_oid); |
56 | 58 | inserted |= insert_oid_pair(map->to_storage, compat_oid, oid); |
57 | 59 | if (inserted) |
58 | | - oidtree_insert(source->loose->cache, compat_oid); |
| 60 | + oidtree_insert(files->loose->cache, compat_oid); |
59 | 61 |
|
60 | 62 | return inserted; |
61 | 63 | } |
62 | 64 |
|
63 | 65 | static int load_one_loose_object_map(struct repository *repo, struct odb_source *source) |
64 | 66 | { |
| 67 | + struct odb_source_files *files = odb_source_files_downcast(source); |
65 | 68 | struct strbuf buf = STRBUF_INIT, path = STRBUF_INIT; |
66 | 69 | FILE *fp; |
67 | 70 |
|
68 | | - if (!source->loose->map) |
69 | | - loose_object_map_init(&source->loose->map); |
70 | | - if (!source->loose->cache) { |
71 | | - ALLOC_ARRAY(source->loose->cache, 1); |
72 | | - oidtree_init(source->loose->cache); |
| 71 | + if (!files->loose->map) |
| 72 | + loose_object_map_init(&files->loose->map); |
| 73 | + if (!files->loose->cache) { |
| 74 | + ALLOC_ARRAY(files->loose->cache, 1); |
| 75 | + oidtree_init(files->loose->cache); |
73 | 76 | } |
74 | 77 |
|
75 | 78 | insert_loose_map(source, repo->hash_algo->empty_tree, repo->compat_hash_algo->empty_tree); |
@@ -125,7 +128,8 @@ int repo_read_loose_object_map(struct repository *repo) |
125 | 128 |
|
126 | 129 | int repo_write_loose_object_map(struct repository *repo) |
127 | 130 | { |
128 | | - kh_oid_map_t *map = repo->objects->sources->loose->map->to_compat; |
| 131 | + struct odb_source_files *files = odb_source_files_downcast(repo->objects->sources); |
| 132 | + kh_oid_map_t *map = files->loose->map->to_compat; |
129 | 133 | struct lock_file lock; |
130 | 134 | int fd; |
131 | 135 | khiter_t iter; |
@@ -231,7 +235,8 @@ int repo_loose_object_map_oid(struct repository *repo, |
231 | 235 | khiter_t pos; |
232 | 236 |
|
233 | 237 | for (source = repo->objects->sources; source; source = source->next) { |
234 | | - struct loose_object_map *loose_map = source->loose->map; |
| 238 | + struct odb_source_files *files = odb_source_files_downcast(source); |
| 239 | + struct loose_object_map *loose_map = files->loose->map; |
235 | 240 | if (!loose_map) |
236 | 241 | continue; |
237 | 242 | map = (to == repo->compat_hash_algo) ? |
|
0 commit comments