repack: make '--quiet' disable progress
[git/debian.git] / midx.h
blob6e32297fa3aaf0edeea852c5760e328b3ed5d061
1 #ifndef MIDX_H
2 #define MIDX_H
4 #include "repository.h"
5 #include "string-list.h"
7 struct object_id;
8 struct pack_entry;
9 struct repository;
11 #define GIT_TEST_MULTI_PACK_INDEX "GIT_TEST_MULTI_PACK_INDEX"
12 #define GIT_TEST_MULTI_PACK_INDEX_WRITE_BITMAP \
13 "GIT_TEST_MULTI_PACK_INDEX_WRITE_BITMAP"
15 struct multi_pack_index {
16 struct multi_pack_index *next;
18 const unsigned char *data;
19 size_t data_len;
21 const uint32_t *revindex_data;
22 const uint32_t *revindex_map;
23 size_t revindex_len;
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;
32 int local;
34 const unsigned char *chunk_pack_names;
35 const uint32_t *chunk_oid_fanout;
36 const unsigned char *chunk_oid_lookup;
37 const unsigned char *chunk_object_offsets;
38 const unsigned char *chunk_large_offsets;
40 const char **pack_names;
41 struct packed_git **packs;
42 char object_dir[FLEX_ARRAY];
45 #define MIDX_PROGRESS (1 << 0)
46 #define MIDX_WRITE_REV_INDEX (1 << 1)
47 #define MIDX_WRITE_BITMAP (1 << 2)
48 #define MIDX_WRITE_BITMAP_HASH_CACHE (1 << 3)
50 const unsigned char *get_midx_checksum(struct multi_pack_index *m);
51 char *get_midx_filename(const char *object_dir);
52 char *get_midx_rev_filename(struct multi_pack_index *m);
54 struct multi_pack_index *load_multi_pack_index(const char *object_dir, int local);
55 int prepare_midx_pack(struct repository *r, struct multi_pack_index *m, uint32_t pack_int_id);
56 int bsearch_midx(const struct object_id *oid, struct multi_pack_index *m, uint32_t *result);
57 off_t nth_midxed_offset(struct multi_pack_index *m, uint32_t pos);
58 uint32_t nth_midxed_pack_int_id(struct multi_pack_index *m, uint32_t pos);
59 struct object_id *nth_midxed_object_oid(struct object_id *oid,
60 struct multi_pack_index *m,
61 uint32_t n);
62 int fill_midx_entry(struct repository *r, const struct object_id *oid, struct pack_entry *e, struct multi_pack_index *m);
63 int midx_contains_pack(struct multi_pack_index *m, const char *idx_or_pack_name);
64 int prepare_multi_pack_index_one(struct repository *r, const char *object_dir, int local);
67 * Variant of write_midx_file which writes a MIDX containing only the packs
68 * specified in packs_to_include.
70 int write_midx_file(const char *object_dir,
71 const char *preferred_pack_name,
72 const char *refs_snapshot,
73 unsigned flags);
74 int write_midx_file_only(const char *object_dir,
75 struct string_list *packs_to_include,
76 const char *preferred_pack_name,
77 const char *refs_snapshot,
78 unsigned flags);
79 void clear_midx_file(struct repository *r);
80 int verify_midx_file(struct repository *r, const char *object_dir, unsigned flags);
81 int expire_midx_packs(struct repository *r, const char *object_dir, unsigned flags);
82 int midx_repack(struct repository *r, const char *object_dir, size_t batch_size, unsigned flags);
84 void close_midx(struct multi_pack_index *m);
86 #endif