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" |
| 5 | |
Ramsay Jones | 642e570 | 2018-09-19 01:13:36 +0100 | [diff] [blame] | 6 | struct object_id; |
| 7 | struct pack_entry; |
Derrick Stolee | 64404a2 | 2019-04-29 09:18:55 -0700 | [diff] [blame] | 8 | struct repository; |
Ramsay Jones | 642e570 | 2018-09-19 01:13:36 +0100 | [diff] [blame] | 9 | |
Derrick Stolee | 0465a50 | 2018-10-12 10:34:20 -0700 | [diff] [blame] | 10 | #define GIT_TEST_MULTI_PACK_INDEX "GIT_TEST_MULTI_PACK_INDEX" |
| 11 | |
Derrick Stolee | 4d80560 | 2018-07-12 15:39:23 -0400 | [diff] [blame] | 12 | struct multi_pack_index { |
Derrick Stolee | c4d2522 | 2018-07-12 15:39:33 -0400 | [diff] [blame] | 13 | struct multi_pack_index *next; |
| 14 | |
Derrick Stolee | 4d80560 | 2018-07-12 15:39:23 -0400 | [diff] [blame] | 15 | const unsigned char *data; |
| 16 | size_t data_len; |
| 17 | |
| 18 | uint32_t signature; |
| 19 | unsigned char version; |
| 20 | unsigned char hash_len; |
| 21 | unsigned char num_chunks; |
| 22 | uint32_t num_packs; |
| 23 | uint32_t num_objects; |
| 24 | |
Derrick Stolee | 2cf489a | 2018-08-20 16:51:55 +0000 | [diff] [blame] | 25 | int local; |
| 26 | |
Derrick Stolee | 32f3c54 | 2018-07-12 15:39:27 -0400 | [diff] [blame] | 27 | const unsigned char *chunk_pack_names; |
Derrick Stolee | d7cacf2 | 2018-07-12 15:39:31 -0400 | [diff] [blame] | 28 | const uint32_t *chunk_oid_fanout; |
Derrick Stolee | 0d5b3a5 | 2018-07-12 15:39:30 -0400 | [diff] [blame] | 29 | const unsigned char *chunk_oid_lookup; |
Derrick Stolee | 662148c | 2018-07-12 15:39:32 -0400 | [diff] [blame] | 30 | const unsigned char *chunk_object_offsets; |
| 31 | const unsigned char *chunk_large_offsets; |
Derrick Stolee | 32f3c54 | 2018-07-12 15:39:27 -0400 | [diff] [blame] | 32 | |
Derrick Stolee | 3227565 | 2018-07-12 15:39:28 -0400 | [diff] [blame] | 33 | const char **pack_names; |
Derrick Stolee | 3715a63 | 2018-07-12 15:39:34 -0400 | [diff] [blame] | 34 | struct packed_git **packs; |
Derrick Stolee | 4d80560 | 2018-07-12 15:39:23 -0400 | [diff] [blame] | 35 | char object_dir[FLEX_ARRAY]; |
| 36 | }; |
| 37 | |
William Baker | efbc3ae | 2019-10-21 18:39:58 +0000 | [diff] [blame] | 38 | #define MIDX_PROGRESS (1 << 0) |
| 39 | |
Derrick Stolee | 2cf489a | 2018-08-20 16:51:55 +0000 | [diff] [blame] | 40 | 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] | 41 | 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] | 42 | int bsearch_midx(const struct object_id *oid, struct multi_pack_index *m, uint32_t *result); |
Derrick Stolee | 8aac67a | 2018-07-12 15:39:35 -0400 | [diff] [blame] | 43 | struct object_id *nth_midxed_object_oid(struct object_id *oid, |
| 44 | struct multi_pack_index *m, |
| 45 | uint32_t n); |
Derrick Stolee | 64404a2 | 2019-04-29 09:18:55 -0700 | [diff] [blame] | 46 | 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] | 47 | 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] | 48 | 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] | 49 | |
William Baker | efbc3ae | 2019-10-21 18:39:58 +0000 | [diff] [blame] | 50 | int write_midx_file(const char *object_dir, unsigned flags); |
Derrick Stolee | 1dcd9f2 | 2018-10-12 10:34:19 -0700 | [diff] [blame] | 51 | void clear_midx_file(struct repository *r); |
William Baker | efbc3ae | 2019-10-21 18:39:58 +0000 | [diff] [blame] | 52 | int verify_midx_file(struct repository *r, const char *object_dir, unsigned flags); |
| 53 | int expire_midx_packs(struct repository *r, const char *object_dir, unsigned flags); |
| 54 | 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] | 55 | |
Derrick Stolee | 1dcd9f2 | 2018-10-12 10:34:19 -0700 | [diff] [blame] | 56 | void close_midx(struct multi_pack_index *m); |
Derrick Stolee | a340773 | 2018-07-12 15:39:21 -0400 | [diff] [blame] | 57 | |
| 58 | #endif |