Merge branch 'ma/help-w-check-for-requested-page'
[git.git] / midx.h
blobaa3da557bb0ae974f3e686c3f0f018161d854651
1 #ifndef MIDX_H
2 #define MIDX_H
4 #include "repository.h"
6 struct object_id;
7 struct pack_entry;
8 struct repository;
10 #define GIT_TEST_MULTI_PACK_INDEX "GIT_TEST_MULTI_PACK_INDEX"
11 #define GIT_TEST_MULTI_PACK_INDEX_WRITE_BITMAP \
12 "GIT_TEST_MULTI_PACK_INDEX_WRITE_BITMAP"
14 struct multi_pack_index {
15 struct multi_pack_index *next;
17 const unsigned char *data;
18 size_t data_len;
20 const uint32_t *revindex_data;
21 const uint32_t *revindex_map;
22 size_t revindex_len;
24 uint32_t signature;
25 unsigned char version;
26 unsigned char hash_len;
27 unsigned char num_chunks;
28 uint32_t num_packs;
29 uint32_t num_objects;
31 int local;
33 const unsigned char *chunk_pack_names;
34 const uint32_t *chunk_oid_fanout;
35 const unsigned char *chunk_oid_lookup;
36 const unsigned char *chunk_object_offsets;
37 const unsigned char *chunk_large_offsets;
39 const char **pack_names;
40 struct packed_git **packs;
41 char object_dir[FLEX_ARRAY];
44 #define MIDX_PROGRESS (1 << 0)
45 #define MIDX_WRITE_REV_INDEX (1 << 1)
46 #define MIDX_WRITE_BITMAP (1 << 2)
48 const unsigned char *get_midx_checksum(struct multi_pack_index *m);
49 char *get_midx_filename(const char *object_dir);
50 char *get_midx_rev_filename(struct multi_pack_index *m);
52 struct multi_pack_index *load_multi_pack_index(const char *object_dir, int local);
53 int prepare_midx_pack(struct repository *r, struct multi_pack_index *m, uint32_t pack_int_id);
54 int bsearch_midx(const struct object_id *oid, struct multi_pack_index *m, uint32_t *result);
55 off_t nth_midxed_offset(struct multi_pack_index *m, uint32_t pos);
56 uint32_t nth_midxed_pack_int_id(struct multi_pack_index *m, uint32_t pos);
57 struct object_id *nth_midxed_object_oid(struct object_id *oid,
58 struct multi_pack_index *m,
59 uint32_t n);
60 int fill_midx_entry(struct repository *r, const struct object_id *oid, struct pack_entry *e, struct multi_pack_index *m);
61 int midx_contains_pack(struct multi_pack_index *m, const char *idx_or_pack_name);
62 int prepare_multi_pack_index_one(struct repository *r, const char *object_dir, int local);
64 int write_midx_file(const char *object_dir, const char *preferred_pack_name, unsigned flags);
65 void clear_midx_file(struct repository *r);
66 int verify_midx_file(struct repository *r, const char *object_dir, unsigned flags);
67 int expire_midx_packs(struct repository *r, const char *object_dir, unsigned flags);
68 int midx_repack(struct repository *r, const char *object_dir, size_t batch_size, unsigned flags);
70 void close_midx(struct multi_pack_index *m);
72 #endif