packfile: rename `struct packfile_store` to `odb_source_packed`

Not too long ago, we have introduced the packfile store in b7983adb51 (packfile: introduce a new `struct packfile_store`, 2025-09-23). This struct is responsible for managing all of our access to packfiles and is used as one of the two sources of objects for the "files" source. Back when I introduced this structure I didn't have the clear vision yet that it will eventually also turn into a proper object database source, and how exactly that infrastructure will look like. Now though it's becoming increasingly clear that it does make sense to treat it just the same as any of our other ODB sources. The consequence is that the naming is now a bit out-of-date: it's just another source and will be turned into a proper `struct odb_source` over the next couple of commits, but it's not named accordingly. Rename the structure to `odb_source_packed` to align it with this goal and to bring it in line with the other sources we already have. Signed-off-by: Patrick Steinhardt <ps@pks.im> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Patrick Steinhardt committed Jun 17, 2026 at 08:39 UTC e2fb4ba003dac9c71b78b997fb90aac10c11c2df
3 files changed +46 -46
odb/source-files.h
+2 -2
@@ -4,7 +4,7 @@
4 #include "odb/source.h"
5
6 struct odb_source_loose;
7 -struct packfile_store;
7 +struct odb_source_packed;
8
9 /*
10 * The files object database source uses a combination of loose objects and
@@ -13,7 +13,7 @@ struct packfile_store;
13 struct odb_source_files {
14 struct odb_source base;
15 struct odb_source_loose *loose;
16 - struct packfile_store *packed;
16 + struct odb_source_packed *packed;
17 };
18
19 /* Allocate and initialize a new object source. */
packfile.c
+28 -28
@@ -859,7 +859,7 @@ struct packed_git *add_packed_git(struct repository *r, const char *path,
859 return p;
860 }
861
862 -void packfile_store_add_pack(struct packfile_store *store,
862 +void packfile_store_add_pack(struct odb_source_packed *store,
863 struct packed_git *pack)
864 {
865 if (pack->pack_fd != -1)
@@ -869,7 +869,7 @@ void packfile_store_add_pack(struct packfile_store *store,
869 strmap_put(&store->packs_by_path, pack->pack_name, pack);
870 }
871
872 -struct packed_git *packfile_store_load_pack(struct packfile_store *store,
872 +struct packed_git *packfile_store_load_pack(struct odb_source_packed *store,
873 const char *idx_path, int local)
874 {
875 struct strbuf key = STRBUF_INIT;
@@ -1068,7 +1068,7 @@ static int sort_pack(const struct packfile_list_entry *a,
1068 return -1;
1069 }
1070
1071 -void packfile_store_prepare(struct packfile_store *store)
1071 +void packfile_store_prepare(struct odb_source_packed *store)
1072 {
1073 if (store->initialized)
1074 return;
@@ -1084,13 +1084,13 @@ void packfile_store_prepare(struct packfile_store *store)
1084 store->initialized = true;
1085 }
1086
1087 -void packfile_store_reprepare(struct packfile_store *store)
1087 +void packfile_store_reprepare(struct odb_source_packed *store)
1088 {
1089 store->initialized = false;
1090 packfile_store_prepare(store);
1091 }
1092
1093 -struct packfile_list_entry *packfile_store_get_packs(struct packfile_store *store)
1093 +struct packfile_list_entry *packfile_store_get_packs(struct odb_source_packed *store)
1094 {
1095 packfile_store_prepare(store);
1096
@@ -1103,7 +1103,7 @@ struct packfile_list_entry *packfile_store_get_packs(struct packfile_store *stor
1103 return store->packs.head;
1104 }
1105
1106 -int packfile_store_count_objects(struct packfile_store *store,
1106 +int packfile_store_count_objects(struct odb_source_packed *store,
1107 enum odb_count_objects_flags flags UNUSED,
1108 unsigned long *out)
1109 {
@@ -2160,7 +2160,7 @@ static int fill_pack_entry(const struct object_id *oid,
2160 return 1;
2161 }
2162
2163 -static int find_pack_entry(struct packfile_store *store,
2163 +static int find_pack_entry(struct odb_source_packed *store,
2164 const struct object_id *oid,
2165 struct pack_entry *e)
2166 {
@@ -2183,7 +2183,7 @@ static int find_pack_entry(struct packfile_store *store,
2183 return 0;
2184 }
2185
2186 -int packfile_store_freshen_object(struct packfile_store *store,
2186 +int packfile_store_freshen_object(struct odb_source_packed *store,
2187 const struct object_id *oid)
2188 {
2189 struct pack_entry e;
@@ -2199,7 +2199,7 @@ int packfile_store_freshen_object(struct packfile_store *store,
2199 return 1;
2200 }
2201
2202 -int packfile_store_read_object_info(struct packfile_store *store,
2202 +int packfile_store_read_object_info(struct odb_source_packed *store,
2203 const struct object_id *oid,
2204 struct object_info *oi,
2205 enum object_info_flags flags)
@@ -2234,7 +2234,7 @@ int packfile_store_read_object_info(struct packfile_store *store,
2234 return 0;
2235 }
2236
2237 -static void maybe_invalidate_kept_pack_cache(struct packfile_store *store,
2237 +static void maybe_invalidate_kept_pack_cache(struct odb_source_packed *store,
2238 unsigned flags)
2239 {
2240 if (!store->kept_cache.packs)
@@ -2245,7 +2245,7 @@ static void maybe_invalidate_kept_pack_cache(struct packfile_store *store,
2245 store->kept_cache.flags = 0;
2246 }
2247
2248 -struct packed_git **packfile_store_get_kept_pack_cache(struct packfile_store *store,
2248 +struct packed_git **packfile_store_get_kept_pack_cache(struct odb_source_packed *store,
2249 unsigned flags)
2250 {
2251 maybe_invalidate_kept_pack_cache(store, flags);
@@ -2365,8 +2365,8 @@ int for_each_object_in_pack(struct packed_git *p,
2365 return r;
2366 }
2367
2368 -struct packfile_store_for_each_object_wrapper_data {
2369 - struct packfile_store *store;
2368 +struct odb_source_packed_for_each_object_wrapper_data {
2369 + struct odb_source_packed *store;
2370 const struct object_info *request;
2371 odb_for_each_object_cb cb;
2372 void *cb_data;
@@ -2377,7 +2377,7 @@ static int packfile_store_for_each_object_wrapper(const struct object_id *oid,
2377 uint32_t index_pos,
2378 void *cb_data)
2379 {
2380 - struct packfile_store_for_each_object_wrapper_data *data = cb_data;
2380 + struct odb_source_packed_for_each_object_wrapper_data *data = cb_data;
2381
2382 if (data->request) {
2383 off_t offset = nth_packed_object_offset(pack, index_pos);
@@ -2411,10 +2411,10 @@ static int match_hash(unsigned len, const unsigned char *a, const unsigned char
2411 }
2412
2413 static int for_each_prefixed_object_in_midx(
2414 - struct packfile_store *store,
2414 + struct odb_source_packed *store,
2415 struct multi_pack_index *m,
2416 const struct odb_for_each_object_options *opts,
2417 - struct packfile_store_for_each_object_wrapper_data *data)
2417 + struct odb_source_packed_for_each_object_wrapper_data *data)
2418 {
2419 int ret;
2420
@@ -2470,10 +2470,10 @@ out:
2470 }
2471
2472 static int for_each_prefixed_object_in_pack(
2473 - struct packfile_store *store,
2473 + struct odb_source_packed *store,
2474 struct packed_git *p,
2475 const struct odb_for_each_object_options *opts,
2476 - struct packfile_store_for_each_object_wrapper_data *data)
2476 + struct odb_source_packed_for_each_object_wrapper_data *data)
2477 {
2478 uint32_t num, i, first = 0;
2479 int len = opts->prefix_hex_len > p->repo->hash_algo->hexsz ?
@@ -2519,9 +2519,9 @@ out:
2519 }
2520
2521 static int packfile_store_for_each_prefixed_object(
2522 - struct packfile_store *store,
2522 + struct odb_source_packed *store,
2523 const struct odb_for_each_object_options *opts,
2524 - struct packfile_store_for_each_object_wrapper_data *data)
2524 + struct odb_source_packed_for_each_object_wrapper_data *data)
2525 {
2526 struct packfile_list_entry *e;
2527 struct multi_pack_index *m;
@@ -2566,13 +2566,13 @@ out:
2566 return ret;
2567 }
2568
2569 -int packfile_store_for_each_object(struct packfile_store *store,
2569 +int packfile_store_for_each_object(struct odb_source_packed *store,
2570 const struct object_info *request,
2571 odb_for_each_object_cb cb,
2572 void *cb_data,
2573 const struct odb_for_each_object_options *opts)
2574 {
2575 - struct packfile_store_for_each_object_wrapper_data data = {
2575 + struct odb_source_packed_for_each_object_wrapper_data data = {
2576 .store = store,
2577 .request = request,
2578 .cb = cb,
@@ -2707,7 +2707,7 @@ static void find_abbrev_len_for_pack(struct packed_git *p,
2707 *out = len;
2708 }
2709
2710 -int packfile_store_find_abbrev_len(struct packfile_store *store,
2710 +int packfile_store_find_abbrev_len(struct odb_source_packed *store,
2711 const struct object_id *oid,
2712 unsigned min_len,
2713 unsigned *out)
@@ -2832,16 +2832,16 @@ int parse_pack_header_option(const char *in, unsigned char *out, unsigned int *l
2832 return 0;
2833 }
2834
2835 -struct packfile_store *packfile_store_new(struct odb_source *source)
2835 +struct odb_source_packed *packfile_store_new(struct odb_source *source)
2836 {
2837 - struct packfile_store *store;
2837 + struct odb_source_packed *store;
2838 CALLOC_ARRAY(store, 1);
2839 store->source = source;
2840 strmap_init(&store->packs_by_path);
2841 return store;
2842 }
2843
2844 -void packfile_store_free(struct packfile_store *store)
2844 +void packfile_store_free(struct odb_source_packed *store)
2845 {
2846 for (struct packfile_list_entry *e = store->packs.head; e; e = e->next)
2847 free(e->pack);
@@ -2851,7 +2851,7 @@ void packfile_store_free(struct packfile_store *store)
2851 free(store);
2852 }
2853
2854 -void packfile_store_close(struct packfile_store *store)
2854 +void packfile_store_close(struct odb_source_packed *store)
2855 {
2856 for (struct packfile_list_entry *e = store->packs.head; e; e = e->next) {
2857 if (e->pack->do_not_close)
@@ -2988,7 +2988,7 @@ int packfile_read_object_stream(struct odb_read_stream **out,
2988 }
2989
2990 int packfile_store_read_object_stream(struct odb_read_stream **out,
2991 - struct packfile_store *store,
2991 + struct odb_source_packed *store,
2992 const struct object_id *oid)
2993 {
2994 struct pack_entry e;
packfile.h
+16 -16
@@ -79,7 +79,7 @@ struct packed_git *packfile_list_find_oid(struct packfile_list_entry *packs,
79 /*
80 * A store that manages packfiles for a given object database.
81 */
82 -struct packfile_store {
82 +struct odb_source_packed {
83 struct odb_source *source;
84
85 /*
@@ -138,19 +138,19 @@ struct packfile_store {
138 * Allocate and initialize a new empty packfile store for the given object
139 * database source.
140 */
141 -struct packfile_store *packfile_store_new(struct odb_source *source);
141 +struct odb_source_packed *packfile_store_new(struct odb_source *source);
142
143 /*
144 * Free the packfile store and all its associated state. All packfiles
145 * tracked by the store will be closed.
146 */
147 -void packfile_store_free(struct packfile_store *store);
147 +void packfile_store_free(struct odb_source_packed *store);
148
149 /*
150 * Close all packfiles associated with this store. The packfiles won't be
151 * free'd, so they can be re-opened at a later point in time.
152 */
153 -void packfile_store_close(struct packfile_store *store);
153 +void packfile_store_close(struct odb_source_packed *store);
154
155 /*
156 * Prepare the packfile store by loading packfiles and multi-pack indices for
@@ -159,7 +159,7 @@ void packfile_store_close(struct packfile_store *store);
159 * It shouldn't typically be necessary to call this function directly, as
160 * functions that access the store know to prepare it.
161 */
162 -void packfile_store_prepare(struct packfile_store *store);
162 +void packfile_store_prepare(struct odb_source_packed *store);
163
164 /*
165 * Clear the packfile caches and try to look up any new packfiles that have
@@ -167,20 +167,20 @@ void packfile_store_prepare(struct packfile_store *store);
167 *
168 * This function must be called under the `odb_read_lock()`.
169 */
170 -void packfile_store_reprepare(struct packfile_store *store);
170 +void packfile_store_reprepare(struct odb_source_packed *store);
171
172 /*
173 * Add the pack to the store so that contained objects become accessible via
174 * the store. This moves ownership into the store.
175 */
176 -void packfile_store_add_pack(struct packfile_store *store,
176 +void packfile_store_add_pack(struct odb_source_packed *store,
177 struct packed_git *pack);
178
179 /*
180 * Get all packs managed by the given store, including packfiles that are
181 * referenced by multi-pack indices.
182 */
183 -struct packfile_list_entry *packfile_store_get_packs(struct packfile_store *store);
183 +struct packfile_list_entry *packfile_store_get_packs(struct odb_source_packed *store);
184
185 struct repo_for_each_pack_data {
186 struct odb_source *source;
@@ -239,7 +239,7 @@ static inline void repo_for_each_pack_data_next(struct repo_for_each_pack_data *
239 repo_for_each_pack_data_next(&eack_pack_data))
240
241 int packfile_store_read_object_stream(struct odb_read_stream **out,
242 - struct packfile_store *store,
242 + struct odb_source_packed *store,
243 const struct object_id *oid);
244
245 /*
@@ -248,7 +248,7 @@ int packfile_store_read_object_stream(struct odb_read_stream **out,
248 * not found, 0 if it was and read successfully, and a negative error code in
249 * case the object was corrupted.
250 */
251 -int packfile_store_read_object_info(struct packfile_store *store,
251 +int packfile_store_read_object_info(struct odb_source_packed *store,
252 const struct object_id *oid,
253 struct object_info *oi,
254 enum object_info_flags flags);
@@ -258,10 +258,10 @@ int packfile_store_read_object_info(struct packfile_store *store,
258 * either the newly opened packfile or the preexisting packfile. Returns a
259 * `NULL` pointer in case the packfile could not be opened.
260 */
261 -struct packed_git *packfile_store_load_pack(struct packfile_store *store,
261 +struct packed_git *packfile_store_load_pack(struct odb_source_packed *store,
262 const char *idx_path, int local);
263
264 -int packfile_store_freshen_object(struct packfile_store *store,
264 +int packfile_store_freshen_object(struct odb_source_packed *store,
265 const struct object_id *oid);
266
267 enum kept_pack_type {
@@ -276,7 +276,7 @@ enum kept_pack_type {
276 *
277 * Return 0 on success, a negative error code otherwise.
278 */
279 -int packfile_store_count_objects(struct packfile_store *store,
279 +int packfile_store_count_objects(struct odb_source_packed *store,
280 enum odb_count_objects_flags flags,
281 unsigned long *out);
282
@@ -285,7 +285,7 @@ int packfile_store_count_objects(struct packfile_store *store,
285 * combination of `kept_pack_type` flags. The cache is computed on demand and
286 * will be recomputed whenever the flags change.
287 */
288 -struct packed_git **packfile_store_get_kept_pack_cache(struct packfile_store *store,
288 +struct packed_git **packfile_store_get_kept_pack_cache(struct odb_source_packed *store,
289 unsigned flags);
290
291 struct pack_window {
@@ -365,13 +365,13 @@ int for_each_object_in_pack(struct packed_git *p,
365 *
366 * The flags parameter is a combination of `odb_for_each_object_flags`.
367 */
368 -int packfile_store_for_each_object(struct packfile_store *store,
368 +int packfile_store_for_each_object(struct odb_source_packed *store,
369 const struct object_info *request,
370 odb_for_each_object_cb cb,
371 void *cb_data,
372 const struct odb_for_each_object_options *opts);
373
374 -int packfile_store_find_abbrev_len(struct packfile_store *store,
374 +int packfile_store_find_abbrev_len(struct odb_source_packed *store,
375 const struct object_id *oid,
376 unsigned min_len,
377 unsigned *out);