2018-10-18 01:13:26 +03:00
|
|
|
#ifndef MIDX_H
|
|
|
|
#define MIDX_H
|
2018-07-12 22:39:21 +03:00
|
|
|
|
2018-07-12 22:39:33 +03:00
|
|
|
#include "repository.h"
|
|
|
|
|
2018-09-19 03:13:36 +03:00
|
|
|
struct object_id;
|
|
|
|
struct pack_entry;
|
2019-04-29 19:18:55 +03:00
|
|
|
struct repository;
|
2018-09-19 03:13:36 +03:00
|
|
|
|
2018-10-12 20:34:20 +03:00
|
|
|
#define GIT_TEST_MULTI_PACK_INDEX "GIT_TEST_MULTI_PACK_INDEX"
|
|
|
|
|
2018-07-12 22:39:23 +03:00
|
|
|
struct multi_pack_index {
|
2018-07-12 22:39:33 +03:00
|
|
|
struct multi_pack_index *next;
|
|
|
|
|
2018-07-12 22:39:23 +03:00
|
|
|
int fd;
|
|
|
|
|
|
|
|
const unsigned char *data;
|
|
|
|
size_t data_len;
|
|
|
|
|
|
|
|
uint32_t signature;
|
|
|
|
unsigned char version;
|
|
|
|
unsigned char hash_len;
|
|
|
|
unsigned char num_chunks;
|
|
|
|
uint32_t num_packs;
|
|
|
|
uint32_t num_objects;
|
|
|
|
|
2018-08-20 19:51:55 +03:00
|
|
|
int local;
|
|
|
|
|
2018-07-12 22:39:27 +03:00
|
|
|
const unsigned char *chunk_pack_names;
|
2018-07-12 22:39:31 +03:00
|
|
|
const uint32_t *chunk_oid_fanout;
|
2018-07-12 22:39:30 +03:00
|
|
|
const unsigned char *chunk_oid_lookup;
|
2018-07-12 22:39:32 +03:00
|
|
|
const unsigned char *chunk_object_offsets;
|
|
|
|
const unsigned char *chunk_large_offsets;
|
2018-07-12 22:39:27 +03:00
|
|
|
|
2018-07-12 22:39:28 +03:00
|
|
|
const char **pack_names;
|
2018-07-12 22:39:34 +03:00
|
|
|
struct packed_git **packs;
|
2018-07-12 22:39:23 +03:00
|
|
|
char object_dir[FLEX_ARRAY];
|
|
|
|
};
|
|
|
|
|
2018-08-20 19:51:55 +03:00
|
|
|
struct multi_pack_index *load_multi_pack_index(const char *object_dir, int local);
|
2019-04-29 19:18:55 +03:00
|
|
|
int prepare_midx_pack(struct repository *r, struct multi_pack_index *m, uint32_t pack_int_id);
|
2018-07-12 22:39:34 +03:00
|
|
|
int bsearch_midx(const struct object_id *oid, struct multi_pack_index *m, uint32_t *result);
|
2018-07-12 22:39:35 +03:00
|
|
|
struct object_id *nth_midxed_object_oid(struct object_id *oid,
|
|
|
|
struct multi_pack_index *m,
|
|
|
|
uint32_t n);
|
2019-04-29 19:18:55 +03:00
|
|
|
int fill_midx_entry(struct repository *r, const struct object_id *oid, struct pack_entry *e, struct multi_pack_index *m);
|
midx: check both pack and index names for containment
A midx file (and the struct we parse from it) contains a list of all of
the covered packfiles, mentioned by their ".idx" names (e.g.,
"pack-1234.idx", etc). And thus calls to midx_contains_pack() expect
callers to provide the idx name.
This works for most of the calls, but the one in open_packed_git_1()
tries to feed a packed_git->pack_name, which is the ".pack" name,
meaning we'll never find a match (even if the pack is covered by the
midx).
We can fix this by converting the ".pack" to ".idx" in the caller.
However, that requires allocating a new string. Instead, let's make
midx_contains_pack() a bit friendlier, and allow it take _either_ the
.pack or .idx variant.
All cleverness in the matching code is credited to René. Bugs are mine.
There's no test here, because while this does fix _a_ bug, it's masked
by another bug in that same caller. That will be covered (with a test)
in the next patch.
Helped-by: René Scharfe <l.s.r@web.de>
Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2019-04-05 21:06:04 +03:00
|
|
|
int midx_contains_pack(struct multi_pack_index *m, const char *idx_or_pack_name);
|
2018-08-20 19:51:55 +03:00
|
|
|
int prepare_multi_pack_index_one(struct repository *r, const char *object_dir, int local);
|
2018-07-12 22:39:23 +03:00
|
|
|
|
2018-07-12 22:39:21 +03:00
|
|
|
int write_midx_file(const char *object_dir);
|
2018-10-12 20:34:19 +03:00
|
|
|
void clear_midx_file(struct repository *r);
|
2019-04-29 19:18:55 +03:00
|
|
|
int verify_midx_file(struct repository *r, const char *object_dir);
|
2019-06-11 02:35:23 +03:00
|
|
|
int expire_midx_packs(struct repository *r, const char *object_dir);
|
2019-06-11 02:35:26 +03:00
|
|
|
int midx_repack(struct repository *r, const char *object_dir, size_t batch_size);
|
2018-07-12 22:39:21 +03:00
|
|
|
|
2018-10-12 20:34:19 +03:00
|
|
|
void close_midx(struct multi_pack_index *m);
|
2018-07-12 22:39:21 +03:00
|
|
|
|
|
|
|
#endif
|