git/midx.h

#ifndef MIDX_H
#define MIDX_H

#include "string-list.h"

struct object_id;
struct pack_entry;
struct repository;
struct bitmapped_pack;

#define MIDX_SIGNATURE
#define MIDX_VERSION
#define MIDX_BYTE_FILE_VERSION
#define MIDX_BYTE_HASH_VERSION
#define MIDX_BYTE_NUM_CHUNKS
#define MIDX_BYTE_NUM_PACKS
#define MIDX_HEADER_SIZE

#define MIDX_CHUNK_ALIGNMENT
#define MIDX_CHUNKID_PACKNAMES
#define MIDX_CHUNKID_BITMAPPEDPACKS
#define MIDX_CHUNKID_OIDFANOUT
#define MIDX_CHUNKID_OIDLOOKUP
#define MIDX_CHUNKID_OBJECTOFFSETS
#define MIDX_CHUNKID_LARGEOFFSETS
#define MIDX_CHUNKID_REVINDEX
#define MIDX_CHUNKID_BASE
#define MIDX_CHUNK_OFFSET_WIDTH
#define MIDX_LARGE_OFFSET_NEEDED

#define GIT_TEST_MULTI_PACK_INDEX
#define GIT_TEST_MULTI_PACK_INDEX_WRITE_INCREMENTAL

struct multi_pack_index {};

#define MIDX_PROGRESS
#define MIDX_WRITE_REV_INDEX
#define MIDX_WRITE_BITMAP
#define MIDX_WRITE_BITMAP_HASH_CACHE
#define MIDX_WRITE_BITMAP_LOOKUP_TABLE
#define MIDX_WRITE_INCREMENTAL

#define MIDX_EXT_REV
#define MIDX_EXT_BITMAP
#define MIDX_EXT_MIDX

const unsigned char *get_midx_checksum(struct multi_pack_index *m);
void get_midx_filename(struct strbuf *out, const char *object_dir);
void get_midx_filename_ext(struct strbuf *out, const char *object_dir,
			   const unsigned char *hash, const char *ext);
void get_midx_chain_dirname(struct strbuf *buf, const char *object_dir);
void get_midx_chain_filename(struct strbuf *buf, const char *object_dir);
void get_split_midx_filename_ext(struct strbuf *buf, const char *object_dir,
				 const unsigned char *hash, const char *ext);

struct multi_pack_index *load_multi_pack_index(const char *object_dir, int local);
int prepare_midx_pack(struct repository *r, struct multi_pack_index *m, uint32_t pack_int_id);
struct packed_git *nth_midxed_pack(struct multi_pack_index *m,
				   uint32_t pack_int_id);
int nth_bitmapped_pack(struct repository *r, struct multi_pack_index *m,
		       struct bitmapped_pack *bp, uint32_t pack_int_id);
int bsearch_one_midx(const struct object_id *oid, struct multi_pack_index *m,
		     uint32_t *result);
int bsearch_midx(const struct object_id *oid, struct multi_pack_index *m,
		 uint32_t *result);
int midx_has_oid(struct multi_pack_index *m, const struct object_id *oid);
off_t nth_midxed_offset(struct multi_pack_index *m, uint32_t pos);
uint32_t nth_midxed_pack_int_id(struct multi_pack_index *m, uint32_t pos);
struct object_id *nth_midxed_object_oid(struct object_id *oid,
					struct multi_pack_index *m,
					uint32_t n);
int fill_midx_entry(struct repository *r, const struct object_id *oid, struct pack_entry *e, struct multi_pack_index *m);
int midx_contains_pack(struct multi_pack_index *m,
		       const char *idx_or_pack_name);
int midx_preferred_pack(struct multi_pack_index *m, uint32_t *pack_int_id);
int prepare_multi_pack_index_one(struct repository *r, const char *object_dir, int local);

/*
 * Variant of write_midx_file which writes a MIDX containing only the packs
 * specified in packs_to_include.
 */
int write_midx_file(const char *object_dir,
		    const char *preferred_pack_name,
		    const char *refs_snapshot,
		    unsigned flags);
int write_midx_file_only(const char *object_dir,
			 struct string_list *packs_to_include,
			 const char *preferred_pack_name,
			 const char *refs_snapshot,
			 unsigned flags);
void clear_midx_file(struct repository *r);
int verify_midx_file(struct repository *r, const char *object_dir, unsigned flags);
int expire_midx_packs(struct repository *r, const char *object_dir, unsigned flags);
int midx_repack(struct repository *r, const char *object_dir, size_t batch_size, unsigned flags);

void close_midx(struct multi_pack_index *m);

#endif