module documentation

Multi-Pack-Index (MIDX) support.

A multi-pack-index (MIDX) provides a single index that covers multiple pack files, enabling fast object lookup across all packs without opening each pack index.

The MIDX file format consists of: - A header with signature, version, and hash algorithm - A chunk lookup table - Multiple chunks containing pack names, OID fanout, OID lookup, and object offsets - A trailer with checksum

This module provides: - Reading MIDX files - Writing MIDX files - Integration with pack-based object stores

Limitations: - Incremental MIDX chains are not yet supported (base_midx_files must be 0) - BTMP (bitmapped packfiles) chunk is not yet implemented - RIDX (reverse index) chunk is not yet implemented

Note: Incremental MIDX chains were introduced in Git 2.47 as an experimental feature, where multiple MIDX files can be chained together. The format includes a base_midx_files field in the header and uses a multi-pack-index.d/ directory with a multi-pack-index-chain file. This feature is not yet supported by Dulwich as the specification is still evolving.

Class MultiPackIndex Multi-pack-index for efficient object lookup across multiple pack files.
Function load_midx Load a multi-pack-index file by path.
Function load_midx_file Load a multi-pack-index from a file-like object.
Function write_midx Write a multi-pack-index file.
Function write_midx_file Write a multi-pack-index file to disk.
Constant CHUNK_BTMP Undocumented
Constant CHUNK_LOFF Undocumented
Constant CHUNK_OIDF Undocumented
Constant CHUNK_OIDL Undocumented
Constant CHUNK_OOFF Undocumented
Constant CHUNK_PNAM Undocumented
Constant CHUNK_RIDX Undocumented
Constant HASH_ALGORITHM_SHA1 Undocumented
Constant HASH_ALGORITHM_SHA256 Undocumented
Constant MIDX_SIGNATURE Undocumented
Constant MIDX_VERSION Undocumented
Variable has_mmap Undocumented
def load_midx(path: str | os.PathLike[str]) -> MultiPackIndex:

Load a multi-pack-index file by path.

Parameters
path:str | os.PathLike[str]Path to the MIDX file
Returns
MultiPackIndexA MultiPackIndex loaded from the given path
def load_midx_file(path: str | os.PathLike[str], f: IO[bytes] | _GitFile) -> MultiPackIndex:

Load a multi-pack-index from a file-like object.

Parameters
path:str | os.PathLike[str]Path for the MIDX file
f:IO[bytes] | _GitFileFile-like object
Returns
MultiPackIndexA MultiPackIndex loaded from the given file
def write_midx(f: IO[bytes], pack_index_entries: list[tuple[str, list[tuple[RawObjectID, int, int | None]]]], hash_algorithm: int = HASH_ALGORITHM_SHA1) -> bytes:

Write a multi-pack-index file.

Parameters
f:IO[bytes]File-like object to write to
pack_index_entries:list[tuple[str, list[tuple[RawObjectID, int, int | None]]]]List of (pack_name, entries) tuples where entries are (sha, offset, crc32) tuples, sorted by SHA
hash_algorithm:intHash algorithm to use (1=SHA-1, 2=SHA-256)
Returns
bytesSHA-1 checksum of the written MIDX file
def write_midx_file(path: str | os.PathLike[str], pack_index_entries: list[tuple[str, list[tuple[RawObjectID, int, int | None]]]], hash_algorithm: int = HASH_ALGORITHM_SHA1) -> bytes:

Write a multi-pack-index file to disk.

Parameters
path:str | os.PathLike[str]Path where to write the MIDX file
pack_index_entries:list[tuple[str, list[tuple[RawObjectID, int, int | None]]]]List of (pack_name, entries) tuples where entries are (sha, offset, crc32) tuples, sorted by SHA
hash_algorithm:intHash algorithm to use (1=SHA-1, 2=SHA-256)
Returns
bytesSHA-1 checksum of the written MIDX file
CHUNK_BTMP: bytes =

Undocumented

Value
b'BTMP'
CHUNK_LOFF: bytes =

Undocumented

Value
b'LOFF'
CHUNK_OIDF: bytes =

Undocumented

Value
b'OIDF'
CHUNK_OIDL: bytes =

Undocumented

Value
b'OIDL'
CHUNK_OOFF: bytes =

Undocumented

Value
b'OOFF'
CHUNK_PNAM: bytes =

Undocumented

Value
b'PNAM'
CHUNK_RIDX: bytes =

Undocumented

Value
b'RIDX'
HASH_ALGORITHM_SHA1: int =

Undocumented

Value
1
HASH_ALGORITHM_SHA256: int =

Undocumented

Value
2
MIDX_SIGNATURE: bytes =

Undocumented

Value
b'MIDX'
MIDX_VERSION: int =

Undocumented

Value
1
has_mmap: bool =

Undocumented