1#ifndef OBJECT_STORE_H 2#define OBJECT_STORE_H 3 4struct alternate_object_database { 5struct alternate_object_database *next; 6 7/* see alt_scratch_buf() */ 8struct strbuf scratch; 9size_t base_len; 10 11/* 12 * Used to store the results of readdir(3) calls when searching 13 * for unique abbreviated hashes. This cache is never 14 * invalidated, thus it's racy and not necessarily accurate. 15 * That's fine for its purpose; don't use it for tasks requiring 16 * greater accuracy! 17 */ 18char loose_objects_subdir_seen[256]; 19struct oid_array loose_objects_cache; 20 21char path[FLEX_ARRAY]; 22}; 23voidprepare_alt_odb(void); 24char*compute_alternate_path(const char*path,struct strbuf *err); 25typedefintalt_odb_fn(struct alternate_object_database *,void*); 26intforeach_alt_odb(alt_odb_fn,void*); 27 28/* 29 * Allocate a "struct alternate_object_database" but do _not_ actually 30 * add it to the list of alternates. 31 */ 32struct alternate_object_database *alloc_alt_odb(const char*dir); 33 34/* 35 * Add the directory to the on-disk alternates file; the new entry will also 36 * take effect in the current process. 37 */ 38voidadd_to_alternates_file(const char*dir); 39 40/* 41 * Add the directory to the in-memory list of alternates (along with any 42 * recursive alternates it points to), but do not modify the on-disk alternates 43 * file. 44 */ 45voidadd_to_alternates_memory(const char*dir); 46 47/* 48 * Returns a scratch strbuf pre-filled with the alternate object directory, 49 * including a trailing slash, which can be used to access paths in the 50 * alternate. Always use this over direct access to alt->scratch, as it 51 * cleans up any previous use of the scratch buffer. 52 */ 53struct strbuf *alt_scratch_buf(struct alternate_object_database *alt); 54 55struct packed_git { 56struct packed_git *next; 57struct list_head mru; 58struct pack_window *windows; 59 off_t pack_size; 60const void*index_data; 61size_t index_size; 62uint32_t num_objects; 63uint32_t num_bad_objects; 64unsigned char*bad_object_sha1; 65int index_version; 66time_t mtime; 67int pack_fd; 68unsigned pack_local:1, 69 pack_keep:1, 70 freshened:1, 71 do_not_close:1, 72 pack_promisor:1; 73unsigned char sha1[20]; 74struct revindex_entry *revindex; 75/* something like ".git/objects/pack/xxxxx.pack" */ 76char pack_name[FLEX_ARRAY];/* more */ 77}; 78 79struct raw_object_store { 80/* 81 * Path to the repository's object store. 82 * Cannot be NULL after initialization. 83 */ 84char*objectdir; 85 86/* Path to extra alternate object database if not NULL */ 87char*alternate_db; 88 89struct alternate_object_database *alt_odb_list; 90struct alternate_object_database **alt_odb_tail; 91 92/* 93 * private data 94 * 95 * should only be accessed directly by packfile.c 96 */ 97 98struct packed_git *packed_git; 99/* A most-recently-used ordered version of the packed_git list. */ 100struct list_head packed_git_mru; 101 102/* 103 * A fast, rough count of the number of objects in the repository. 104 * These two fields are not meant for direct access. Use 105 * approximate_object_count() instead. 106 */ 107unsigned long approximate_object_count; 108unsigned approximate_object_count_valid :1; 109 110/* 111 * Whether packed_git has already been populated with this repository's 112 * packs. 113 */ 114unsigned packed_git_initialized :1; 115}; 116 117struct raw_object_store *raw_object_store_new(void); 118voidraw_object_store_clear(struct raw_object_store *o); 119 120#endif/* OBJECT_STORE_H */