Ramsay Jones | 0009d35 | 2018-10-17 23:13:26 +0100 | [diff] [blame] | 1 | #ifndef MIDX_H |
| 2 | #define MIDX_H |
Derrick Stolee | a340773 | 2018-07-12 15:39:21 -0400 | [diff] [blame] | 3 | |
Derrick Stolee | c4d2522 | 2018-07-12 15:39:33 -0400 | [diff] [blame] | 4 | #include "repository.h" |
Taylor Blau | 56d863e | 2021-09-28 21:55:01 -0400 | [diff] [blame] | 5 | #include "string-list.h" |
Derrick Stolee | c4d2522 | 2018-07-12 15:39:33 -0400 | [diff] [blame] | 6 | |
Ramsay Jones | 642e570 | 2018-09-19 01:13:36 +0100 | [diff] [blame] | 7 | struct object_id; |
| 8 | struct pack_entry; |
Derrick Stolee | 64404a2 | 2019-04-29 09:18:55 -0700 | [diff] [blame] | 9 | struct repository; |
Ramsay Jones | 642e570 | 2018-09-19 01:13:36 +0100 | [diff] [blame] | 10 | |
Derrick Stolee | 0465a50 | 2018-10-12 10:34:20 -0700 | [diff] [blame] | 11 | #define GIT_TEST_MULTI_PACK_INDEX "GIT_TEST_MULTI_PACK_INDEX" |
Taylor Blau | ff1e653 | 2021-08-31 16:52:43 -0400 | [diff] [blame] | 12 | #define GIT_TEST_MULTI_PACK_INDEX_WRITE_BITMAP \ |
| 13 | "GIT_TEST_MULTI_PACK_INDEX_WRITE_BITMAP" |
Derrick Stolee | 0465a50 | 2018-10-12 10:34:20 -0700 | [diff] [blame] | 14 | |
Derrick Stolee | 4d80560 | 2018-07-12 15:39:23 -0400 | [diff] [blame] | 15 | struct multi_pack_index { |
Derrick Stolee | c4d2522 | 2018-07-12 15:39:33 -0400 | [diff] [blame] | 16 | struct multi_pack_index *next; |
| 17 | |
Derrick Stolee | 4d80560 | 2018-07-12 15:39:23 -0400 | [diff] [blame] | 18 | const unsigned char *data; |
| 19 | size_t data_len; |
| 20 | |
Taylor Blau | f894081 | 2021-03-30 11:04:26 -0400 | [diff] [blame] | 21 | const uint32_t *revindex_data; |
| 22 | const uint32_t *revindex_map; |
| 23 | size_t revindex_len; |
| 24 | |
Derrick Stolee | 4d80560 | 2018-07-12 15:39:23 -0400 | [diff] [blame] | 25 | uint32_t signature; |
| 26 | unsigned char version; |
| 27 | unsigned char hash_len; |
| 28 | unsigned char num_chunks; |
| 29 | uint32_t num_packs; |
| 30 | uint32_t num_objects; |
| 31 | |
Derrick Stolee | 2cf489a | 2018-08-20 16:51:55 +0000 | [diff] [blame] | 32 | int local; |
| 33 | |
Derrick Stolee | 32f3c54 | 2018-07-12 15:39:27 -0400 | [diff] [blame] | 34 | const unsigned char *chunk_pack_names; |
Derrick Stolee | d7cacf2 | 2018-07-12 15:39:31 -0400 | [diff] [blame] | 35 | const uint32_t *chunk_oid_fanout; |
Derrick Stolee | 0d5b3a5 | 2018-07-12 15:39:30 -0400 | [diff] [blame] | 36 | const unsigned char *chunk_oid_lookup; |
Derrick Stolee | 662148c | 2018-07-12 15:39:32 -0400 | [diff] [blame] | 37 | const unsigned char *chunk_object_offsets; |
| 38 | const unsigned char *chunk_large_offsets; |
Taylor Blau | 7f514b7 | 2022-01-25 17:41:17 -0500 | [diff] [blame] | 39 | const unsigned char *chunk_revindex; |
Derrick Stolee | 32f3c54 | 2018-07-12 15:39:27 -0400 | [diff] [blame] | 40 | |
Derrick Stolee | 3227565 | 2018-07-12 15:39:28 -0400 | [diff] [blame] | 41 | const char **pack_names; |
Derrick Stolee | 3715a63 | 2018-07-12 15:39:34 -0400 | [diff] [blame] | 42 | struct packed_git **packs; |
Derrick Stolee | 4d80560 | 2018-07-12 15:39:23 -0400 | [diff] [blame] | 43 | char object_dir[FLEX_ARRAY]; |
| 44 | }; |
| 45 | |
William Baker | efbc3ae | 2019-10-21 18:39:58 +0000 | [diff] [blame] | 46 | #define MIDX_PROGRESS (1 << 0) |
Taylor Blau | 38ff7ca | 2021-03-30 11:04:32 -0400 | [diff] [blame] | 47 | #define MIDX_WRITE_REV_INDEX (1 << 1) |
Taylor Blau | c528e17 | 2021-08-31 16:52:24 -0400 | [diff] [blame] | 48 | #define MIDX_WRITE_BITMAP (1 << 2) |
Taylor Blau | caca3c9 | 2021-09-14 18:06:06 -0400 | [diff] [blame] | 49 | #define MIDX_WRITE_BITMAP_HASH_CACHE (1 << 3) |
Abhradeep Chakraborty | 76f14b7 | 2022-08-14 16:55:09 +0000 | [diff] [blame] | 50 | #define MIDX_WRITE_BITMAP_LOOKUP_TABLE (1 << 4) |
William Baker | efbc3ae | 2019-10-21 18:39:58 +0000 | [diff] [blame] | 51 | |
Taylor Blau | 0f533c7 | 2021-08-31 16:52:21 -0400 | [diff] [blame] | 52 | const unsigned char *get_midx_checksum(struct multi_pack_index *m); |
Taylor Blau | 60980ae | 2021-10-26 17:01:21 -0400 | [diff] [blame] | 53 | void get_midx_filename(struct strbuf *out, const char *object_dir); |
| 54 | void get_midx_rev_filename(struct strbuf *out, struct multi_pack_index *m); |
Taylor Blau | f894081 | 2021-03-30 11:04:26 -0400 | [diff] [blame] | 55 | |
Derrick Stolee | 2cf489a | 2018-08-20 16:51:55 +0000 | [diff] [blame] | 56 | struct multi_pack_index *load_multi_pack_index(const char *object_dir, int local); |
Derrick Stolee | 64404a2 | 2019-04-29 09:18:55 -0700 | [diff] [blame] | 57 | int prepare_midx_pack(struct repository *r, struct multi_pack_index *m, uint32_t pack_int_id); |
Derrick Stolee | 3715a63 | 2018-07-12 15:39:34 -0400 | [diff] [blame] | 58 | int bsearch_midx(const struct object_id *oid, struct multi_pack_index *m, uint32_t *result); |
Taylor Blau | 62f2c1b | 2021-03-30 11:04:20 -0400 | [diff] [blame] | 59 | off_t nth_midxed_offset(struct multi_pack_index *m, uint32_t pos); |
| 60 | uint32_t nth_midxed_pack_int_id(struct multi_pack_index *m, uint32_t pos); |
Derrick Stolee | 8aac67a | 2018-07-12 15:39:35 -0400 | [diff] [blame] | 61 | struct object_id *nth_midxed_object_oid(struct object_id *oid, |
| 62 | struct multi_pack_index *m, |
| 63 | uint32_t n); |
Derrick Stolee | 64404a2 | 2019-04-29 09:18:55 -0700 | [diff] [blame] | 64 | int fill_midx_entry(struct repository *r, const struct object_id *oid, struct pack_entry *e, struct multi_pack_index *m); |
Jeff King | 013fd7a | 2019-04-05 14:06:04 -0400 | [diff] [blame] | 65 | int midx_contains_pack(struct multi_pack_index *m, const char *idx_or_pack_name); |
Derrick Stolee | 2cf489a | 2018-08-20 16:51:55 +0000 | [diff] [blame] | 66 | int prepare_multi_pack_index_one(struct repository *r, const char *object_dir, int local); |
Derrick Stolee | 4d80560 | 2018-07-12 15:39:23 -0400 | [diff] [blame] | 67 | |
Taylor Blau | 56d863e | 2021-09-28 21:55:01 -0400 | [diff] [blame] | 68 | /* |
| 69 | * Variant of write_midx_file which writes a MIDX containing only the packs |
| 70 | * specified in packs_to_include. |
| 71 | */ |
Taylor Blau | 08944d1 | 2021-09-28 21:55:07 -0400 | [diff] [blame] | 72 | int write_midx_file(const char *object_dir, |
| 73 | const char *preferred_pack_name, |
| 74 | const char *refs_snapshot, |
| 75 | unsigned flags); |
Taylor Blau | 56d863e | 2021-09-28 21:55:01 -0400 | [diff] [blame] | 76 | int write_midx_file_only(const char *object_dir, |
| 77 | struct string_list *packs_to_include, |
| 78 | const char *preferred_pack_name, |
Taylor Blau | 08944d1 | 2021-09-28 21:55:07 -0400 | [diff] [blame] | 79 | const char *refs_snapshot, |
Taylor Blau | 56d863e | 2021-09-28 21:55:01 -0400 | [diff] [blame] | 80 | unsigned flags); |
Derrick Stolee | 1dcd9f2 | 2018-10-12 10:34:19 -0700 | [diff] [blame] | 81 | void clear_midx_file(struct repository *r); |
William Baker | efbc3ae | 2019-10-21 18:39:58 +0000 | [diff] [blame] | 82 | int verify_midx_file(struct repository *r, const char *object_dir, unsigned flags); |
| 83 | int expire_midx_packs(struct repository *r, const char *object_dir, unsigned flags); |
| 84 | int midx_repack(struct repository *r, const char *object_dir, size_t batch_size, unsigned flags); |
Derrick Stolee | a340773 | 2018-07-12 15:39:21 -0400 | [diff] [blame] | 85 | |
Derrick Stolee | 1dcd9f2 | 2018-10-12 10:34:19 -0700 | [diff] [blame] | 86 | void close_midx(struct multi_pack_index *m); |
Derrick Stolee | a340773 | 2018-07-12 15:39:21 -0400 | [diff] [blame] | 87 | |
| 88 | #endif |