module documentation

Classes for dealing with packed git objects.

A pack is a compact representation of a bunch of objects, stored using deltas where possible.

They have two parts, the pack file, which stores the data, and an index that tells you where the data is.

To find an object you look in all of the index files 'til you find a match for the object name. You then use the pointer got from this as a pointer in to the corresponding packfile.

Class DeltaChainIterator Abstract iterator over pack data based on delta chains.
Class FilePackIndex Pack index that is based on a file.
Class HashWriter Wrapper for file-like object that computes hash of its data.
Class MemoryPackIndex Pack index that is stored entirely in memory.
Class ObjectContainer Protocol for objects that can contain git objects.
Class Pack A Git pack object.
Class PackChunkGenerator Generator for pack data chunks.
Class PackData The data contained in a packfile.
Class PackedObjectContainer Container for objects packed in a pack file.
Class PackIndex An index in to a packfile.
Class PackIndex1 Version 1 Pack Index file.
Class PackIndex2 Version 2 Pack Index file.
Class PackIndex3 Version 3 Pack Index file.
Class PackIndexer Delta chain iterator that yields index entries.
Class PackInflater Delta chain iterator that yields ShaFile objects.
Class PackStreamCopier Class to verify a pack stream as it is being read.
Class PackStreamReader Class to read a pack stream.
Class SHA1Reader Wrapper for file-like object that remembers the SHA1 of its data.
Class SHA1Writer Wrapper for file-like object that remembers the SHA1 of its data.
Class UnpackedObject Class encapsulating an object unpacked from a pack file.
Class UnpackedObjectIterator Delta chain iterator that yield unpacked objects.
Class UnpackedObjectStream Abstract base class for a stream of unpacked objects.
Exception PackFileDisappeared Raised when a pack file unexpectedly disappears.
Exception UnresolvedDeltas Delta objects could not be resolved.
Function apply_delta Based on the similar function in git's patch-delta.c.
Function bisect_find_sha Find a SHA in a data blob with sorted SHAs.
Function chunks_length Get the total length of a sequence of chunks.
Function compute_file_sha Hash a portion of a file into a new SHA.
Function deltas_from_sorted_objects Create deltas from sorted objects.
Function deltify_pack_objects Generate deltas for pack objects.
Function extend_pack Extend a pack file with more objects.
Function find_reusable_deltas Find deltas in a pack that can be reused.
Function full_unpacked_object Create an UnpackedObject from a ShaFile.
Function generate_unpacked_objects Create pack data from objects.
Function iter_sha1 Return the hexdigest of the SHA1 over a set of names.
Function load_pack_index Load an index file by path.
Function load_pack_index_file Load an index file from a file-like object.
Function obj_sha Compute the SHA for a numeric type and object chunks.
Function pack_header_chunks Yield chunks for a pack header.
Function pack_object_chunks Generate chunks for a pack object.
Function pack_object_header Create a pack object header for the given object info.
Function pack_objects_to_data Create pack data from objects.
Function read_pack_header Read the header of a pack file.
Function read_zlib_chunks Read zlib data from a buffer.
Function sort_objects_for_delta Sort objects for optimal delta compression.
Function take_msb_bytes Read bytes marked with most significant bit.
Function unpack_object Unpack a Git object.
Function verify_and_read Read from stream, verify hash, then yield verified chunks.
Function write_pack Write a new pack data file.
Function write_pack_data Write a new pack data file.
Function write_pack_from_container Write a new pack data file.
Function write_pack_header Write a pack header for the given number of objects.
Function write_pack_index Write a pack index file.
Function write_pack_index_v1 Write a new pack index file.
Function write_pack_index_v2 Write a new pack index file.
Function write_pack_index_v3 Write a new pack index file in v3 format.
Function write_pack_object Write pack object to a file.
Function write_pack_objects Write a new pack data file.
Constant DEFAULT_DELTA_BASE_CACHE_LIMIT Undocumented
Constant DEFAULT_PACK_DELTA_WINDOW_SIZE Undocumented
Constant DEFAULT_PACK_INDEX_VERSION Undocumented
Constant DELTA_TYPES Undocumented
Constant OFS_DELTA Undocumented
Constant PACK_SPOOL_FILE_MAX_SIZE Undocumented
Constant REF_DELTA Undocumented
Type Variable T Undocumented
Type Alias PackHint Undocumented
Type Alias PackIndexEntry Undocumented
Type Alias ProgressFn Undocumented
Type Alias ResolveExtRefFn Undocumented
Variable has_mmap Undocumented
Variable OldUnpackedObject Undocumented
Function _compute_object_size Compute the size of a unresolved object for use with LRUSizeCache.
Function _create_delta_py Use python difflib to work out how to transform base_buf to target_buf.
Function _create_delta_rs_wrapper Wrapper for Rust create_delta to match Python API.
Function _delta_encode_size Undocumented
Function _encode_copy_operation Undocumented
Function _load_file_contents Load contents from a file, preferring mmap when possible.
Constant _MAX_COPY_LEN Undocumented
Constant _ZLIB_BUFSIZE Undocumented
def apply_delta(src_buf: bytes | list[bytes], delta: bytes | list[bytes]) -> list[bytes]:

Based on the similar function in git's patch-delta.c.

Parameters
src_buf:bytes | list[bytes]Source buffer
delta:bytes | list[bytes]Delta instructions
Returns
list[bytes]Undocumented
def bisect_find_sha(start: int, end: int, sha: bytes, unpack_name: Callable[[int], bytes]) -> int | None:

Find a SHA in a data blob with sorted SHAs.

Returns: Index of the SHA, or None if it wasn't found

Parameters
start:intStart index of range to search
end:intEnd index of range to search
sha:bytesSha to find
unpack_name:Callable[[int], bytes]Callback to retrieve SHA by index
Returns
int | NoneUndocumented
def chunks_length(chunks: bytes | Iterable[bytes]) -> int:

Get the total length of a sequence of chunks.

Returns: Total length in bytes

Parameters
chunks:bytes | Iterable[bytes]Either a single bytes object or an iterable of bytes
Returns
intUndocumented
def compute_file_sha(f: IO[bytes], hash_func: Callable[[], HashObject], start_ofs: int = 0, end_ofs: int = 0, buffer_size: int = 1 << 16) -> HashObject:

Hash a portion of a file into a new SHA.

Returns: A new SHA object updated with data read from the file.

Parameters
f:IO[bytes]A file-like object to read from that supports seek().
hash_func:Callable[[], HashObject]A callable that returns a new HashObject.
start_ofs:intThe offset in the file to start reading at.
end_ofs:intThe offset in the file to end reading at, relative to the end of the file.
buffer_size:intA buffer size for reading.
Returns
HashObjectUndocumented
def deltas_from_sorted_objects(objects: Iterator[tuple[ShaFile, bytes | None]], window_size: int | None = None, progress: Callable[..., None] | None = None) -> Iterator[UnpackedObject]:

Create deltas from sorted objects.

Parameters
objects:Iterator[tuple[ShaFile, bytes | None]]Iterator of sorted objects to deltify
window_size:int | NoneDelta window size; None for default
progress:Callable[..., None] | NoneOptional progress reporting callback
Returns
Iterator[UnpackedObject]Iterator of UnpackedObject entries
def deltify_pack_objects(objects: Iterator[ShaFile] | Iterator[tuple[ShaFile, bytes | None]], *, window_size: int | None = None, progress: Callable[..., None] | None = None) -> Iterator[UnpackedObject]:

Generate deltas for pack objects.

Returns: Iterator over type_num, object id, delta_base, content
delta_base is None for full text entries
Parameters
objects:Iterator[ShaFile] | Iterator[tuple[ShaFile, bytes | None]]An iterable of (object, path) tuples to deltify.
window_size:int | NoneWindow size; None for default
progress:Callable[..., None] | NoneOptional progress reporting callback
Returns
Iterator[UnpackedObject]Undocumented
def extend_pack(f: BinaryIO, object_ids: Set[RawObjectID], get_raw: Callable[[(RawObjectID | ObjectID)], tuple[int, bytes]], object_format: ObjectFormat, *, compression_level: int = -1, progress: Callable[[bytes], None] | None = None) -> tuple[bytes, list[tuple[RawObjectID, int, int]]]:

Extend a pack file with more objects.

The caller should make sure that object_ids does not contain any objects that are already in the pack

def find_reusable_deltas(container: PackedObjectContainer, object_ids: Set[ObjectID], *, other_haves: Set[ObjectID] | None = None, progress: Callable[..., None] | None = None) -> Iterator[UnpackedObject]:

Find deltas in a pack that can be reused.

Parameters
container:PackedObjectContainerPack container to search for deltas
object_ids:Set[ObjectID]Set of object IDs to find deltas for
other_haves:Set[ObjectID] | NoneSet of other object IDs we have
progress:Callable[..., None] | NoneOptional progress reporting callback
Returns
Iterator[UnpackedObject]Iterator of UnpackedObject entries that can be reused
def full_unpacked_object(o: ShaFile) -> UnpackedObject:

Create an UnpackedObject from a ShaFile.

Parameters
o:ShaFileShaFile object to convert
Returns
UnpackedObjectUnpackedObject with full object data
def generate_unpacked_objects(container: PackedObjectContainer, object_ids: Sequence[tuple[ObjectID, PackHint | None]], delta_window_size: int | None = None, deltify: bool | None = None, reuse_deltas: bool = True, ofs_delta: bool = True, other_haves: set[ObjectID] | None = None, progress: Callable[..., None] | None = None) -> Iterator[UnpackedObject]:

Create pack data from objects.

Returns: Tuples with (type_num, hexdigest, delta base, object chunks)

def iter_sha1(iter: Iterable[bytes]) -> bytes:

Return the hexdigest of the SHA1 over a set of names.

Returns: 40-byte hex sha1 digest

Parameters
iter:Iterable[bytes]Iterator over string objects
Returns
bytesUndocumented
def load_pack_index(path: str | os.PathLike[str], object_format: ObjectFormat) -> PackIndex:

Load an index file by path.

Returns: A PackIndex loaded from the given path

Parameters
path:str | os.PathLike[str]Path to the index file
object_format:ObjectFormatHash algorithm used by the repository
Returns
PackIndexUndocumented
def load_pack_index_file(path: str | os.PathLike[str], f: IO[bytes] | _GitFile, object_format: ObjectFormat) -> PackIndex:

Load an index file from a file-like object.

Returns: A PackIndex loaded from the given file

Parameters
path:str | os.PathLike[str]Path for the index file
f:IO[bytes] | _GitFileFile-like object
object_format:ObjectFormatHash algorithm used by the repository
Returns
PackIndexUndocumented
def obj_sha(type: int, chunks: bytes | Iterable[bytes], hash_func: Callable[[], HashObject] = sha1) -> bytes:

Compute the SHA for a numeric type and object chunks.

Parameters
type:intObject type number
chunks:bytes | Iterable[bytes]Object data chunks
hash_func:Callable[[], HashObject]Hash function to use (defaults to sha1)
Returns
bytesBinary hash digest
def pack_header_chunks(num_objects: int) -> Iterator[bytes]:

Yield chunks for a pack header.

def pack_object_chunks(type: int, object: list[bytes] | tuple[bytes | int, list[bytes]], object_format: ObjectFormat, *, compression_level: int = -1) -> Iterator[bytes]:

Generate chunks for a pack object.

Returns: Chunks

Parameters
type:intNumeric type of the object
object:list[bytes] | tuple[bytes | int, list[bytes]]Object to write
object_format:ObjectFormatObject format (hash algorithm) to use
compression_level:intthe zlib compression level
Returns
Iterator[bytes]Undocumented
def pack_object_header(type_num: int, delta_base: bytes | int | None, size: int, object_format: ObjectFormat) -> bytearray:

Create a pack object header for the given object info.

Returns: A header for a packed object.

Parameters
type_num:intNumeric type of the object.
delta_base:bytes | int | NoneDelta base offset or ref, or None for whole objects.
size:intUncompressed object size.
object_format:ObjectFormatObject format (hash algorithm) to use.
Returns
bytearrayUndocumented
def pack_objects_to_data(objects: Sequence[ShaFile] | Sequence[tuple[ShaFile, bytes | None]] | Sequence[tuple[ShaFile, PackHint | None]], *, deltify: bool | None = None, delta_window_size: int | None = None, ofs_delta: bool = True, progress: Callable[..., None] | None = None) -> tuple[int, Iterator[UnpackedObject]]:

Create pack data from objects.

Returns: Tuples with (type_num, hexdigest, delta base, object chunks)

Parameters
objects:Sequence[ShaFile] | Sequence[tuple[ShaFile, bytes | None]] | Sequence[tuple[ShaFile, PackHint | None]]Pack objects
deltify:bool | NoneWhether to deltify pack objects
delta_window_size:int | NoneDelta window size
ofs_delta:boolWhether to use offset deltas
progress:Callable[..., None] | NoneOptional progress reporting callback
Returns
tuple[int, Iterator[UnpackedObject]]Undocumented
def read_pack_header(read: Callable[[int], bytes]) -> tuple[int, int]:

Read the header of a pack file.

Returns: Tuple of (pack version, number of objects). If no data is
available to read, returns (None, None).
Parameters
read:Callable[[int], bytes]Read function
Returns
tuple[int, int]Undocumented
def read_zlib_chunks(read_some: Callable[[int], bytes], unpacked: UnpackedObject, include_comp: bool = False, buffer_size: int = _ZLIB_BUFSIZE) -> bytes:

Read zlib data from a buffer.

This function requires that the buffer have additional data following the compressed data, which is guaranteed to be the case for git pack files.

Returns: Leftover unused data from the decompression.

Parameters
read_some:Callable[[int], bytes]Read function that returns at least one byte, but may return less than the requested size.
unpacked:UnpackedObjectAn UnpackedObject to write result data to. If its crc32 attr is not None, the CRC32 of the compressed bytes will be computed using this starting CRC32. After this function, will have the following attrs set: * comp_chunks (if include_comp is True) * decomp_chunks * decomp_len * crc32
include_comp:boolIf True, include compressed data in the result.
buffer_size:intSize of the read buffer.
Returns
bytesUndocumented
Raises
zlib.errorif a decompression error occurred.
def sort_objects_for_delta(objects: Iterator[ShaFile] | Iterator[tuple[ShaFile, PackHint | None]]) -> Iterator[tuple[ShaFile, bytes | None]]:

Sort objects for optimal delta compression.

Parameters
objects:Iterator[ShaFile] | Iterator[tuple[ShaFile, PackHint | None]]Iterator of objects or (object, hint) tuples
Returns
Iterator[tuple[ShaFile, bytes | None]]Iterator of sorted (ShaFile, path) tuples
def take_msb_bytes(read: Callable[[int], bytes], crc32: int | None = None) -> tuple[list[int], int | None]:

Read bytes marked with most significant bit.

Parameters
read:Callable[[int], bytes]Read function
crc32:int | NoneOptional CRC32 checksum to update
Returns
tuple[list[int], int | None]Tuple of (list of bytes read, updated CRC32 or None)
def unpack_object(read_all: Callable[[int], bytes], hash_func: Callable[[], HashObject], read_some: Callable[[int], bytes] | None = None, compute_crc32: bool = False, include_comp: bool = False, zlib_bufsize: int = _ZLIB_BUFSIZE) -> tuple[UnpackedObject, bytes]:

Unpack a Git object.

Returns: A tuple of (unpacked, unused), where unused is the unused data

leftover from decompression, and unpacked in an UnpackedObject with the following attrs set:

  • obj_chunks (for non-delta types)
  • pack_type_num
  • delta_base (for delta types)
  • comp_chunks (if include_comp is True)
  • decomp_chunks
  • decomp_len
  • crc32 (if compute_crc32 is True)
Parameters
read_all:Callable[[int], bytes]Read function that blocks until the number of requested bytes are read.
hash_func:Callable[[], HashObject]Hash function to use for computing object IDs.
read_some:Callable[[int], bytes] | NoneRead function that returns at least one byte, but may not return the number of bytes requested.
compute_crc32:boolIf True, compute the CRC32 of the compressed data. If False, the returned CRC32 will be None.
include_comp:boolIf True, include compressed data in the result.
zlib_bufsize:intAn optional buffer size for zlib operations.
Returns
tuple[UnpackedObject, bytes]Undocumented
def verify_and_read(read_func: Callable[[int], bytes], expected_hash: bytes, hash_algo: str, progress: Callable[[bytes], None] | None = None) -> Iterator[bytes]:

Read from stream, verify hash, then yield verified chunks.

This function downloads data to a temporary file (in-memory for small files, on-disk for large ones) while computing its hash. Only after the hash is verified to match expected_hash will it yield any data. This prevents corrupted or malicious data from reaching the caller.

Parameters
read_func:Callable[[int], bytes]Function to read bytes (like file.read or HTTP response reader)
expected_hash:bytesExpected hash as hex string bytes (e.g., b'a3b2c1...')
hash_algo:strHash algorithm name ('sha1' or 'sha256')
progress:Callable[[bytes], None] | NoneOptional progress callback
Returns
Iterator[bytes]Undocumented
Yields
Chunks of verified data (only after hash verification succeeds)
Raises
ValueErrorIf hash doesn't match or algorithm unsupported
def write_pack(filename: str, objects: Sequence[ShaFile] | Sequence[tuple[ShaFile, bytes | None]], object_format: ObjectFormat, *, deltify: bool | None = None, delta_window_size: int | None = None, compression_level: int = -1) -> tuple[bytes, bytes]:

Write a new pack data file.

Returns: Tuple with checksum of pack file and index file

Parameters
filename:strPath to the new pack file (without .pack extension)
objects:Sequence[ShaFile] | Sequence[tuple[ShaFile, bytes | None]]Objects to write to the pack
object_format:ObjectFormatObject format
deltify:bool | NoneWhether to deltify pack objects
delta_window_size:int | NoneDelta window size
compression_level:intthe zlib compression level
Returns
tuple[bytes, bytes]Undocumented
def write_pack_data(write: Callable[[bytes], None] | Callable[[(bytes | bytearray | memoryview)], int] | IO[bytes], records: Iterator[UnpackedObject], object_format: ObjectFormat, *, num_records: int | None = None, progress: Callable[..., None] | None = None, compression_level: int = -1) -> tuple[dict[bytes, tuple[int, int]], bytes]:

Write a new pack data file.

Returns: Dict mapping id -> (offset, crc32 checksum), pack checksum

Parameters
write:Callable[[bytes], None] | Callable[[(bytes | bytearray | memoryview)], int] | IO[bytes]Write function to use
records:Iterator[UnpackedObject]Iterator over type_num, object_id, delta_base, raw
object_format:ObjectFormatObject format (hash algorithm) to use
num_records:int | NoneNumber of records (defaults to len(records) if None)
progress:Callable[..., None] | NoneFunction to report progress to
compression_level:intthe zlib compression level
Returns
tuple[dict[bytes, tuple[int, int]], bytes]Undocumented
def write_pack_from_container(write: Callable[[bytes], None] | Callable[[(bytes | bytearray | memoryview)], int] | IO[bytes], container: PackedObjectContainer, object_ids: Sequence[tuple[ObjectID, PackHint | None]], object_format: ObjectFormat, *, delta_window_size: int | None = None, deltify: bool | None = None, reuse_deltas: bool = True, compression_level: int = -1, other_haves: set[ObjectID] | None = None) -> tuple[dict[bytes, tuple[int, int]], bytes]:

Write a new pack data file.

Returns: Dict mapping id -> (offset, crc32 checksum), pack checksum

Parameters
write:Callable[[bytes], None] | Callable[[(bytes | bytearray | memoryview)], int] | IO[bytes]write function to use
container:PackedObjectContainerPackedObjectContainer
object_ids:Sequence[tuple[ObjectID, PackHint | None]]Sequence of (object_id, hint) tuples to write
object_format:ObjectFormatObject format (hash algorithm) to use
delta_window_size:int | NoneSliding window size for searching for deltas; Set to None for default window size.
deltify:bool | NoneWhether to deltify objects
reuse_deltas:boolWhether to reuse existing deltas
compression_level:intthe zlib compression level to use
other_haves:set[ObjectID] | NoneSet of additional object IDs the receiver has
Returns
tuple[dict[bytes, tuple[int, int]], bytes]Undocumented
def write_pack_header(write: Callable[[bytes], int] | IO[bytes], num_objects: int):

Write a pack header for the given number of objects.

def write_pack_index(f: IO[bytes], entries: Iterable[tuple[bytes, int, int | None]], pack_checksum: bytes, progress: Callable[..., None] | None = None, version: int | None = None) -> bytes:

Write a pack index file.

Parameters
f:IO[bytes]File-like object to write to.
entries:Iterable[tuple[bytes, int, int | None]]List of (checksum, offset, crc32) tuples
pack_checksum:bytesChecksum of the pack file.
progress:Callable[..., None] | NoneProgress function (not currently used)
version:int | NonePack index version to use (1, 2, or 3). If None, defaults to DEFAULT_PACK_INDEX_VERSION.
Returns
bytesSHA of the written index file
Raises
ValueErrorIf an unsupported version is specified
def write_pack_index_v1(f: IO[bytes], entries: Iterable[tuple[bytes, int, int | None]], pack_checksum: bytes) -> bytes:

Write a new pack index file.

Returns: The SHA of the written index file

Parameters
f:IO[bytes]A file-like object to write to
entries:Iterable[tuple[bytes, int, int | None]]List of tuples with object name (sha), offset_in_pack, and crc32_checksum.
pack_checksum:bytesChecksum of the pack file.
Returns
bytesUndocumented
def write_pack_index_v2(f: IO[bytes], entries: Iterable[tuple[bytes, int, int | None]], pack_checksum: bytes) -> bytes:

Write a new pack index file.

Returns: The checksum of the index file written

Parameters
f:IO[bytes]File-like object to write to
entries:Iterable[tuple[bytes, int, int | None]]List of tuples with object name (sha), offset_in_pack, and crc32_checksum.
pack_checksum:bytesChecksum of the pack file.
Returns
bytesUndocumented
def write_pack_index_v3(f: IO[bytes], entries: Iterable[tuple[bytes, int, int | None]], pack_checksum: bytes, hash_format: int = 1) -> bytes:

Write a new pack index file in v3 format.

Returns: The SHA of the index file written

Parameters
f:IO[bytes]File-like object to write to
entries:Iterable[tuple[bytes, int, int | None]]List of tuples with object name (sha), offset_in_pack, and crc32_checksum.
pack_checksum:bytesChecksum of the pack file.
hash_format:intHash algorithm identifier (1 = SHA-1, 2 = SHA-256)
Returns
bytesUndocumented
def write_pack_object(write: Callable[[bytes], int], type: int, object: list[bytes] | tuple[bytes | int, list[bytes]], object_format: ObjectFormat, *, sha: HashObject | None = None, compression_level: int = -1) -> int:

Write pack object to a file.

Returns: CRC32 checksum of the written object

Parameters
write:Callable[[bytes], int]Write function to use
type:intNumeric type of the object
object:list[bytes] | tuple[bytes | int, list[bytes]]Object to write
object_format:ObjectFormatObject format (hash algorithm) to use
sha:HashObject | NoneOptional SHA-1 hasher to update
compression_level:intthe zlib compression level
Returns
intUndocumented
def write_pack_objects(write: Callable[[bytes], None] | IO[bytes], objects: Sequence[ShaFile] | Sequence[tuple[ShaFile, bytes | None]], object_format: ObjectFormat, *, delta_window_size: int | None = None, deltify: bool | None = None, compression_level: int = -1) -> tuple[dict[bytes, tuple[int, int]], bytes]:

Write a new pack data file.

Returns: Dict mapping id -> (offset, crc32 checksum), pack checksum

Parameters
write:Callable[[bytes], None] | IO[bytes]write function to use
objects:Sequence[ShaFile] | Sequence[tuple[ShaFile, bytes | None]]Sequence of (object, path) tuples to write
object_format:ObjectFormatObject format (hash algorithm) to use
delta_window_size:int | NoneSliding window size for searching for deltas; Set to None for default window size.
deltify:bool | NoneWhether to deltify objects
compression_level:intthe zlib compression level to use
Returns
tuple[dict[bytes, tuple[int, int]], bytes]Undocumented
DEFAULT_DELTA_BASE_CACHE_LIMIT =

Undocumented

Value
96 * 1024 * 1024
DEFAULT_PACK_DELTA_WINDOW_SIZE: int =

Undocumented

Value
10
DEFAULT_PACK_INDEX_VERSION: int =

Undocumented

Value
2
DELTA_TYPES =

Undocumented

Value
(OFS_DELTA, REF_DELTA)
OFS_DELTA: int =

Undocumented

Value
6
PACK_SPOOL_FILE_MAX_SIZE =

Undocumented

Value
16 * 1024 * 1024
REF_DELTA: int =

Undocumented

Value
7
T =

Undocumented

Value
TypeVar('T')
PackHint =

Undocumented

Value
tuple[int, bytes | None]
PackIndexEntry =

Undocumented

Value
tuple[RawObjectID, int, int | None]
ProgressFn =

Undocumented

Value
Callable[[int, str], None]
ResolveExtRefFn =

Undocumented

Value
Callable[[bytes], tuple[int, OldUnpackedObject]]
has_mmap: bool =

Undocumented

OldUnpackedObject =

Undocumented

def _compute_object_size(value: tuple[int, Any]) -> int:

Compute the size of a unresolved object for use with LRUSizeCache.

def _create_delta_py(base_buf: bytes, target_buf: bytes) -> Iterator[bytes]:

Use python difflib to work out how to transform base_buf to target_buf.

Parameters
base_buf:bytesBase buffer
target_buf:bytesTarget buffer
Returns
Iterator[bytes]Undocumented
def _create_delta_rs_wrapper(base_buf: bytes, target_buf: bytes) -> Iterator[bytes]:

Wrapper for Rust create_delta to match Python API.

def _delta_encode_size(size: int) -> bytes:

Undocumented

def _encode_copy_operation(start: int, length: int) -> bytes:

Undocumented

def _load_file_contents(f: IO[bytes] | _GitFile, size: int | None = None) -> tuple[bytes | Any, int]:

Load contents from a file, preferring mmap when possible.

Returns: Tuple of (contents, size)

Parameters
f:IO[bytes] | _GitFileFile-like object to load
size:int | NoneExpected size, or None to determine from file
Returns
tuple[bytes | Any, int]Undocumented
_MAX_COPY_LEN: int =

Undocumented

Value
65535
_ZLIB_BUFSIZE: int =

Undocumented

Value
65536