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 | |
Multi-pack-index for efficient object lookup across multiple pack files. |
| Function | load |
Load a multi-pack-index file by path. |
| Function | load |
Load a multi-pack-index from a file-like object. |
| Function | write |
Write a multi-pack-index file. |
| Function | write |
Write a multi-pack-index file to disk. |
| Constant | CHUNK |
Undocumented |
| Constant | CHUNK |
Undocumented |
| Constant | CHUNK |
Undocumented |
| Constant | CHUNK |
Undocumented |
| Constant | CHUNK |
Undocumented |
| Constant | CHUNK |
Undocumented |
| Constant | CHUNK |
Undocumented |
| Constant | HASH |
Undocumented |
| Constant | HASH |
Undocumented |
| Constant | MIDX |
Undocumented |
| Constant | MIDX |
Undocumented |
| Variable | has |
Undocumented |
Load a multi-pack-index file by path.
| Parameters | |
path:str | os.PathLike[ | Path to the MIDX file |
| Returns | |
MultiPackIndex | A MultiPackIndex loaded from the given path |
Load a multi-pack-index from a file-like object.
| Parameters | |
path:str | os.PathLike[ | Path for the MIDX file |
f:IO[ | File-like object |
| Returns | |
MultiPackIndex | A MultiPackIndex loaded from the given file |
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[ | File-like object to write to |
packlist[ | List of (pack_name, entries) tuples where entries are (sha, offset, crc32) tuples, sorted by SHA |
hashint | Hash algorithm to use (1=SHA-1, 2=SHA-256) |
| Returns | |
bytes | SHA-1 checksum of the written MIDX file |
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[ | Path where to write the MIDX file |
packlist[ | List of (pack_name, entries) tuples where entries are (sha, offset, crc32) tuples, sorted by SHA |
hashint | Hash algorithm to use (1=SHA-1, 2=SHA-256) |
| Returns | |
bytes | SHA-1 checksum of the written MIDX file |