2 * Copyright (C) the libgit2 contributors. All rights reserved.
4 * This file is part of libgit2, distributed under the GNU GPL v2 with
5 * a Linking Exception. For full terms see the included COPYING file.
8 #ifndef INCLUDE_midx_h__
9 #define INCLUDE_midx_h__
15 #include "git2/sys/midx.h"
22 * A multi-pack-index file.
24 * This file contains a merged index for multiple independent .pack files. This
25 * can help speed up locating objects without requiring a garbage collection
26 * cycle to create a single .pack file.
28 * Support for this feature was added in git 2.21, and requires the
29 * `core.multiPackIndex` config option to be set.
31 typedef struct git_midx_file
{
34 /* The table of Packfile Names. */
35 git_vector packfile_names
;
37 /* The OID Fanout table. */
38 const uint32_t *oid_fanout
;
39 /* The total number of objects in the index. */
42 /* The OID Lookup table. */
45 /* The Object Offsets table. Each entry has two 4-byte fields with the pack index and the offset. */
46 const unsigned char *object_offsets
;
48 /* The Object Large Offsets table. */
49 const unsigned char *object_large_offsets
;
50 /* The number of entries in the Object Large Offsets table. Each entry has an 8-byte with an offset */
51 size_t num_object_large_offsets
;
53 /* The trailer of the file. Contains the SHA1-checksum of the whole file. */
56 /* something like ".git/objects/pack/multi-pack-index". */
61 * An entry in the multi-pack-index file. Similar in purpose to git_pack_entry.
63 typedef struct git_midx_entry
{
64 /* The index within idx->packfile_names where the packfile name can be found. */
66 /* The offset within the .pack file where the requested object is found. */
68 /* The SHA-1 hash of the requested object. */
73 * A writer for `multi-pack-index` files.
75 struct git_midx_writer
{
77 * The path of the directory where the .pack/.idx files are stored. The
78 * `multi-pack-index` file will be written to the same directory.
82 /* The list of `git_pack_file`s. */
87 git_midx_file
**idx_out
,
89 bool git_midx_needs_refresh(
90 const git_midx_file
*idx
,
92 int git_midx_entry_find(
95 const git_oid
*short_oid
,
97 int git_midx_foreach_entry(
99 git_odb_foreach_cb cb
,
101 int git_midx_close(git_midx_file
*idx
);
102 void git_midx_free(git_midx_file
*idx
);
104 /* This is exposed for use in the fuzzers. */
107 const unsigned char *data
,