Interplane page as plain text, for reading tools and agents. English is the reference text: translate it with your own tool. Text in backticks and in ``` blocks (commands, fingerprints, file names) and link targets in <...> are exact: copy them, never translate them. Page: /drakestapleton/git/blob/master/odb/source-packed.h # git [Ported from github.com/git/git] Sync with Git 2.56.1 Brought by drakestapleton Sign in to star 0 stars 0 watching About Files History Releases Proposed changes Issues For developers branch `master` Branches Tags History `git / odb / source-packed.h` 94 lines ยท 2755 bytes Raw Blame History 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 this store is part of the local object directory of the 46 * owning repository. Packfiles loaded via this store inherit this 47 * flag via `pack_local`. Stores for alternates are not local. 48 */ 49 bool local; 50 51 /* 52 * Whether packfiles have already been populated with this store's 53 * packs. 54 */ 55 bool initialized; 56 57 /* 58 * Usually, packfiles will be reordered to the front of the `packs` 59 * list whenever an object is looked up via them. This has the effect 60 * that packs that contain a lot of accessed objects will be located 61 * towards the front. 62 * 63 * This is usually desirable, but there are exceptions. One exception 64 * is when the looking up multiple objects in a loop for each packfile. 65 * In that case, we may easily end up with an infinite loop as the 66 * packfiles get reordered to the front repeatedly. 67 * 68 * Setting this field to `true` thus disables these reorderings. 69 */ 70 bool skip_mru_updates; 71 }; 72 73 /* 74 * Allocate and initialize a new empty packfile store for the given object 75 * database. 76 */ 77 struct odb_source_packed *odb_source_packed_new(struct object_database *odb, 78 const char *path, 79 bool local); 80 81 /* 82 * Cast the given object database source to the packed backend. This will cause 83 * a BUG in case the source doesn't use this backend. 84 */ 85 static inline struct odb_source_packed *odb_source_packed_downcast(struct odb_source *source) 86 { 87 if (source->type != ODB_SOURCE_PACKED) 88 BUG("trying to downcast source of type '%s' to '%s'", 89 odb_source_type_to_name(source->type), 90 odb_source_type_to_name(ODB_SOURCE_PACKED)); 91 return container_of(source, struct odb_source_packed, base); 92 } 93 94 #endif