/src/git/odb/source-packed.h
Line | Count | Source |
1 | | #ifndef ODB_SOURCE_PACKED_H |
2 | | #define ODB_SOURCE_PACKED_H |
3 | | |
4 | | #include "odb/source.h" |
5 | | #include "packfile-list.h" |
6 | | #include "strmap.h" |
7 | | |
8 | | /* |
9 | | * A store that manages packfiles for a given object database. |
10 | | */ |
11 | | struct odb_source_packed { |
12 | | struct odb_source base; |
13 | | |
14 | | /* |
15 | | * The list of packfiles in the order in which they have been most |
16 | | * recently used. |
17 | | */ |
18 | | struct packfile_list packs; |
19 | | |
20 | | /* |
21 | | * Cache of packfiles which are marked as "kept", either because there |
22 | | * is an on-disk ".keep" file or because they are marked as "kept" in |
23 | | * memory. |
24 | | * |
25 | | * Should not be accessed directly, but via |
26 | | * `packfile_store_get_kept_pack_cache()`. The list of packs gets |
27 | | * invalidated when the stored flags and the flags passed to |
28 | | * `packfile_store_get_kept_pack_cache()` mismatch. |
29 | | */ |
30 | | struct { |
31 | | struct packed_git **packs; |
32 | | unsigned flags; |
33 | | } kept_cache; |
34 | | |
35 | | /* The multi-pack index that belongs to this specific packfile store. */ |
36 | | struct multi_pack_index *midx; |
37 | | |
38 | | /* |
39 | | * A map of packfile names to packed_git structs for tracking which |
40 | | * packs have been loaded already. |
41 | | */ |
42 | | struct strmap packs_by_path; |
43 | | |
44 | | /* |
45 | | * Whether packfiles have already been populated with this store's |
46 | | * packs. |
47 | | */ |
48 | | bool initialized; |
49 | | |
50 | | /* |
51 | | * Usually, packfiles will be reordered to the front of the `packs` |
52 | | * list whenever an object is looked up via them. This has the effect |
53 | | * that packs that contain a lot of accessed objects will be located |
54 | | * towards the front. |
55 | | * |
56 | | * This is usually desirable, but there are exceptions. One exception |
57 | | * is when the looking up multiple objects in a loop for each packfile. |
58 | | * In that case, we may easily end up with an infinite loop as the |
59 | | * packfiles get reordered to the front repeatedly. |
60 | | * |
61 | | * Setting this field to `true` thus disables these reorderings. |
62 | | */ |
63 | | bool skip_mru_updates; |
64 | | }; |
65 | | |
66 | | /* |
67 | | * Allocate and initialize a new empty packfile store for the given object |
68 | | * database. |
69 | | */ |
70 | | struct odb_source_packed *odb_source_packed_new(struct object_database *odb, |
71 | | const char *path, |
72 | | bool local); |
73 | | |
74 | | /* |
75 | | * Cast the given object database source to the packed backend. This will cause |
76 | | * a BUG in case the source doesn't use this backend. |
77 | | */ |
78 | | static inline struct odb_source_packed *odb_source_packed_downcast(struct odb_source *source) |
79 | 0 | { |
80 | 0 | if (source->type != ODB_SOURCE_PACKED) |
81 | 0 | BUG("trying to downcast source of type '%s' to '%s'", |
82 | 0 | odb_source_type_to_name(source->type), |
83 | 0 | odb_source_type_to_name(ODB_SOURCE_PACKED)); |
84 | 0 | return container_of(source, struct odb_source_packed, base); |
85 | 0 | } Unexecuted instantiation: run-command.c:odb_source_packed_downcast Unexecuted instantiation: tag.c:odb_source_packed_downcast Unexecuted instantiation: diff.c:odb_source_packed_downcast Unexecuted instantiation: list-objects.c:odb_source_packed_downcast Unexecuted instantiation: object-file.c:odb_source_packed_downcast Unexecuted instantiation: source.c:odb_source_packed_downcast Unexecuted instantiation: source-files.c:odb_source_packed_downcast Unexecuted instantiation: source-packed.c:odb_source_packed_downcast Unexecuted instantiation: pack-bitmap.c:odb_source_packed_downcast Unexecuted instantiation: pack-check.c:odb_source_packed_downcast Unexecuted instantiation: pack-objects.c:odb_source_packed_downcast Unexecuted instantiation: pack-revindex.c:odb_source_packed_downcast Unexecuted instantiation: pack-write.c:odb_source_packed_downcast Unexecuted instantiation: packfile.c:odb_source_packed_downcast Unexecuted instantiation: packfile-list.c:odb_source_packed_downcast Unexecuted instantiation: path.c:odb_source_packed_downcast Unexecuted instantiation: promisor-remote.c:odb_source_packed_downcast Unexecuted instantiation: pseudo-merge.c:odb_source_packed_downcast Unexecuted instantiation: repack.c:odb_source_packed_downcast Unexecuted instantiation: repack-geometry.c:odb_source_packed_downcast Unexecuted instantiation: repo-settings.c:odb_source_packed_downcast Unexecuted instantiation: revision.c:odb_source_packed_downcast Unexecuted instantiation: commit-graph.c:odb_source_packed_downcast Unexecuted instantiation: connected.c:odb_source_packed_downcast Unexecuted instantiation: fetch-pack.c:odb_source_packed_downcast Unexecuted instantiation: fsck.c:odb_source_packed_downcast Unexecuted instantiation: midx.c:odb_source_packed_downcast Unexecuted instantiation: pack-bitmap-write.c:odb_source_packed_downcast Unexecuted instantiation: pack-mtimes.c:odb_source_packed_downcast Unexecuted instantiation: transport-helper.c:odb_source_packed_downcast Unexecuted instantiation: fuzz-pack-headers.c:odb_source_packed_downcast Unexecuted instantiation: fuzz-pack-idx.c:odb_source_packed_downcast |
86 | | |
87 | | #endif |