blob: b18cf53bc4abf9650019aa7b4827696ea32056ac [file] [log] [blame]
Ramsay Jones0009d352018-10-17 23:13:26 +01001#ifndef MIDX_H
2#define MIDX_H
Derrick Stoleea3407732018-07-12 15:39:21 -04003
Derrick Stoleec4d25222018-07-12 15:39:33 -04004#include "repository.h"
5
Ramsay Jones642e5702018-09-19 01:13:36 +01006struct object_id;
7struct pack_entry;
Derrick Stolee64404a22019-04-29 09:18:55 -07008struct repository;
Ramsay Jones642e5702018-09-19 01:13:36 +01009
Derrick Stolee0465a502018-10-12 10:34:20 -070010#define GIT_TEST_MULTI_PACK_INDEX "GIT_TEST_MULTI_PACK_INDEX"
11
Derrick Stolee4d805602018-07-12 15:39:23 -040012struct multi_pack_index {
Derrick Stoleec4d25222018-07-12 15:39:33 -040013 struct multi_pack_index *next;
14
Derrick Stolee4d805602018-07-12 15:39:23 -040015 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 Stolee2cf489a2018-08-20 16:51:55 +000025 int local;
26
Derrick Stolee32f3c542018-07-12 15:39:27 -040027 const unsigned char *chunk_pack_names;
Derrick Stoleed7cacf22018-07-12 15:39:31 -040028 const uint32_t *chunk_oid_fanout;
Derrick Stolee0d5b3a52018-07-12 15:39:30 -040029 const unsigned char *chunk_oid_lookup;
Derrick Stolee662148c2018-07-12 15:39:32 -040030 const unsigned char *chunk_object_offsets;
31 const unsigned char *chunk_large_offsets;
Derrick Stolee32f3c542018-07-12 15:39:27 -040032
Derrick Stolee32275652018-07-12 15:39:28 -040033 const char **pack_names;
Derrick Stolee3715a632018-07-12 15:39:34 -040034 struct packed_git **packs;
Derrick Stolee4d805602018-07-12 15:39:23 -040035 char object_dir[FLEX_ARRAY];
36};
37
William Bakerefbc3ae2019-10-21 18:39:58 +000038#define MIDX_PROGRESS (1 << 0)
39
Derrick Stolee2cf489a2018-08-20 16:51:55 +000040struct multi_pack_index *load_multi_pack_index(const char *object_dir, int local);
Derrick Stolee64404a22019-04-29 09:18:55 -070041int prepare_midx_pack(struct repository *r, struct multi_pack_index *m, uint32_t pack_int_id);
Derrick Stolee3715a632018-07-12 15:39:34 -040042int bsearch_midx(const struct object_id *oid, struct multi_pack_index *m, uint32_t *result);
Derrick Stolee8aac67a2018-07-12 15:39:35 -040043struct object_id *nth_midxed_object_oid(struct object_id *oid,
44 struct multi_pack_index *m,
45 uint32_t n);
Derrick Stolee64404a22019-04-29 09:18:55 -070046int fill_midx_entry(struct repository *r, const struct object_id *oid, struct pack_entry *e, struct multi_pack_index *m);
Jeff King013fd7a2019-04-05 14:06:04 -040047int midx_contains_pack(struct multi_pack_index *m, const char *idx_or_pack_name);
Derrick Stolee2cf489a2018-08-20 16:51:55 +000048int prepare_multi_pack_index_one(struct repository *r, const char *object_dir, int local);
Derrick Stolee4d805602018-07-12 15:39:23 -040049
William Bakerefbc3ae2019-10-21 18:39:58 +000050int write_midx_file(const char *object_dir, unsigned flags);
Derrick Stolee1dcd9f22018-10-12 10:34:19 -070051void clear_midx_file(struct repository *r);
William Bakerefbc3ae2019-10-21 18:39:58 +000052int verify_midx_file(struct repository *r, const char *object_dir, unsigned flags);
53int expire_midx_packs(struct repository *r, const char *object_dir, unsigned flags);
54int midx_repack(struct repository *r, const char *object_dir, size_t batch_size, unsigned flags);
Derrick Stoleea3407732018-07-12 15:39:21 -040055
Derrick Stolee1dcd9f22018-10-12 10:34:19 -070056void close_midx(struct multi_pack_index *m);
Derrick Stoleea3407732018-07-12 15:39:21 -040057
58#endif