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/midx.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 / midx.h` 173 lines ยท 6474 bytes Raw Blame History 1 #ifndef MIDX_H 2 #define MIDX_H 3 4 #include "string-list.h" 5 6 struct object_id; 7 struct pack_entry; 8 struct repository; 9 struct bitmapped_pack; 10 struct git_hash_algo; 11 struct odb_source; 12 struct strvec; 13 14 #define MIDX_SIGNATURE 0x4d494458 /* "MIDX" */ 15 #define MIDX_VERSION_V1 1 16 #define MIDX_VERSION_V2 2 17 #define MIDX_BYTE_FILE_VERSION 4 18 #define MIDX_BYTE_HASH_VERSION 5 19 #define MIDX_BYTE_NUM_CHUNKS 6 20 #define MIDX_BYTE_NUM_PACKS 8 21 #define MIDX_HEADER_SIZE 12 22 23 #define MIDX_CHUNK_ALIGNMENT 4 24 #define MIDX_CHUNKID_PACKNAMES 0x504e414d /* "PNAM" */ 25 #define MIDX_CHUNKID_BITMAPPEDPACKS 0x42544d50 /* "BTMP" */ 26 #define MIDX_CHUNKID_OIDFANOUT 0x4f494446 /* "OIDF" */ 27 #define MIDX_CHUNKID_OIDLOOKUP 0x4f49444c /* "OIDL" */ 28 #define MIDX_CHUNKID_OBJECTOFFSETS 0x4f4f4646 /* "OOFF" */ 29 #define MIDX_CHUNKID_LARGEOFFSETS 0x4c4f4646 /* "LOFF" */ 30 #define MIDX_CHUNKID_REVINDEX 0x52494458 /* "RIDX" */ 31 #define MIDX_CHUNKID_BASE 0x42415345 /* "BASE" */ 32 #define MIDX_CHUNK_OFFSET_WIDTH (2 * sizeof(uint32_t)) 33 #define MIDX_LARGE_OFFSET_NEEDED 0x80000000 34 35 #define GIT_TEST_MULTI_PACK_INDEX "GIT_TEST_MULTI_PACK_INDEX" 36 #define GIT_TEST_MULTI_PACK_INDEX_WRITE_INCREMENTAL \ 37 "GIT_TEST_MULTI_PACK_INDEX_WRITE_INCREMENTAL" 38 39 struct multi_pack_index { 40 struct odb_source_packed *source; 41 42 const unsigned char *data; 43 size_t data_len; 44 45 const uint32_t *revindex_data; 46 const uint32_t *revindex_map; 47 size_t revindex_len; 48 49 uint32_t signature; 50 unsigned char version; 51 unsigned char hash_len; 52 unsigned char num_chunks; 53 uint32_t num_packs; 54 uint32_t num_objects; 55 int preferred_pack_idx; 56 57 int has_chain; 58 59 const unsigned char *chunk_pack_names; 60 size_t chunk_pack_names_len; 61 const uint32_t *chunk_bitmapped_packs; 62 size_t chunk_bitmapped_packs_len; 63 const uint32_t *chunk_oid_fanout; 64 const unsigned char *chunk_oid_lookup; 65 const unsigned char *chunk_object_offsets; 66 const unsigned char *chunk_large_offsets; 67 size_t chunk_large_offsets_len; 68 const unsigned char *chunk_revindex; 69 size_t chunk_revindex_len; 70 71 struct multi_pack_index *base_midx; 72 uint32_t num_objects_in_base; 73 uint32_t num_packs_in_base; 74 75 const char **pack_names; 76 size_t *pack_names_sorted; 77 struct packed_git **packs; 78 }; 79 80 #define MIDX_PROGRESS (1 << 0) 81 #define MIDX_WRITE_REV_INDEX (1 << 1) 82 #define MIDX_WRITE_BITMAP (1 << 2) 83 #define MIDX_WRITE_BITMAP_HASH_CACHE (1 << 3) 84 #define MIDX_WRITE_BITMAP_LOOKUP_TABLE (1 << 4) 85 #define MIDX_WRITE_INCREMENTAL (1 << 5) 86 #define MIDX_WRITE_COMPACT (1 << 6) 87 #define MIDX_WRITE_NO_CHAIN (1 << 7) 88 89 #define MIDX_EXT_REV "rev" 90 #define MIDX_EXT_BITMAP "bitmap" 91 #define MIDX_EXT_MIDX "midx" 92 93 const char *midx_get_checksum_hex(const struct multi_pack_index *m) /* static buffer */; 94 const unsigned char *midx_get_checksum_hash(const struct multi_pack_index *m); 95 void get_midx_filename(struct odb_source_packed *source, struct strbuf *out); 96 void get_midx_filename_ext(struct odb_source_packed *source, struct strbuf *out, 97 const unsigned char *hash, const char *ext); 98 void get_midx_chain_dirname(struct odb_source_packed *source, struct strbuf *out); 99 void get_midx_chain_filename(struct odb_source_packed *source, struct strbuf *out); 100 void get_split_midx_filename_ext(struct odb_source_packed *source, struct strbuf *buf, 101 const unsigned char *hash, const char *ext); 102 103 struct multi_pack_index *get_multi_pack_index(struct odb_source_packed *source); 104 struct multi_pack_index *load_multi_pack_index(struct odb_source_packed *source); 105 int prepare_midx_pack(struct multi_pack_index *m, uint32_t pack_int_id); 106 struct packed_git *nth_midxed_pack(struct multi_pack_index *m, 107 uint32_t pack_int_id); 108 int nth_bitmapped_pack(struct multi_pack_index *m, 109 struct bitmapped_pack *bp, uint32_t pack_int_id); 110 int bsearch_one_midx(const struct object_id *oid, struct multi_pack_index *m, 111 uint32_t *result); 112 int bsearch_midx(const struct object_id *oid, struct multi_pack_index *m, 113 uint32_t *result); 114 int midx_has_oid(struct multi_pack_index *m, const struct object_id *oid); 115 off_t nth_midxed_offset(struct multi_pack_index *m, uint32_t pos); 116 uint32_t nth_midxed_pack_int_id(struct multi_pack_index *m, uint32_t pos); 117 struct object_id *nth_midxed_object_oid(struct object_id *oid, 118 struct multi_pack_index *m, 119 uint32_t n); 120 /* 121 * Result of looking an object up in a multi-pack-index. MIDX_FILL_HIT means 122 * "e was filled in"; the two miss variants distinguish an object the midx does 123 * not know about (MIDX_FILL_MISS) from one it does know about but whose owning 124 * pack we can no longer open (MIDX_FILL_OWNER_UNAVAILABLE -- the signature of a 125 * concurrent repack having removed that pack). A known-bad (corrupt) object 126 * reports MIDX_FILL_MISS but also sets *bad_pack, if provided, to the owning 127 * pack so the caller can tell "corrupt" apart from "absent". 128 */ 129 enum midx_fill_result { 130 MIDX_FILL_MISS = 0, 131 MIDX_FILL_HIT, 132 MIDX_FILL_OWNER_UNAVAILABLE, 133 }; 134 135 enum midx_fill_result midx_fill_entry(struct multi_pack_index *m, 136 const struct object_id *oid, 137 struct pack_entry *e, 138 struct packed_git **bad_pack); 139 int midx_contains_pack(struct multi_pack_index *m, 140 const char *idx_or_pack_name); 141 int midx_layer_contains_pack(struct multi_pack_index *m, 142 const char *idx_or_pack_name); 143 int midx_preferred_pack(struct multi_pack_index *m, uint32_t *pack_int_id); 144 int prepare_multi_pack_index_one(struct odb_source_packed *source); 145 146 /* 147 * Variant of write_midx_file which writes a MIDX containing only the packs 148 * specified in packs_to_include. 149 */ 150 int write_midx_file(struct odb_source_packed *source, 151 const char *preferred_pack_name, const char *refs_snapshot, 152 unsigned flags); 153 int write_midx_file_only(struct odb_source_packed *source, 154 struct string_list *packs_to_include, 155 const char *preferred_pack_name, 156 const char *refs_snapshot, 157 const char *incremental_base, 158 unsigned flags); 159 int write_midx_file_compact(struct odb_source_packed *source, 160 struct multi_pack_index *from, 161 struct multi_pack_index *to, 162 const char *incremental_base, 163 unsigned flags); 164 void clear_midx_file(struct repository *r); 165 void clear_incremental_midx_files(struct repository *r, 166 const struct strvec *keep_hashes); 167 int verify_midx_file(struct odb_source_packed *source, unsigned flags); 168 int expire_midx_packs(struct odb_source_packed *source, unsigned flags); 169 int midx_repack(struct odb_source_packed *source, size_t batch_size, unsigned flags); 170 171 void close_midx(struct multi_pack_index *m); 172 173 #endif