class documentation

A block containing reference records.

Class Method decode Decode a ref block from bytes - simplified.
Method __init__ Initialize RefBlock.
Method add_ref Add a reference to the block.
Method encode Encode the ref block with restart points for Git compatibility.
Instance Variable refs Undocumented
Class Method _find_ref_data_end Find where ref records end in the data.
Method _create_embedded_footer Create the embedded footer pattern Git uses.
def decode(cls, data: bytes, min_update_index: int = 0) -> RefBlock:

Decode a ref block from bytes - simplified.

def __init__(self):

Initialize RefBlock.

def add_ref(self, refname: bytes, value_type: int, value: bytes, update_index: int = 1):

Add a reference to the block.

def encode(self, min_update_index: int = 0, embed_footer: bool = False, header_data: bytes = b'') -> bytes:

Encode the ref block with restart points for Git compatibility.

Undocumented

def _find_ref_data_end(cls, data: bytes) -> int:

Find where ref records end in the data.

Git embeds a footer at the end of ref blocks that contains offset information. This footer is marked by a special pattern (0x00 0x00 0x1c) where 0x1c (28) represents the version 2 header size.

Parameters
data:bytesThe raw block data to search
Returns
intThe position where ref records end and footer begins
def _create_embedded_footer(self, ref_offsets: list[int], header_data: bytes) -> bytes:

Create the embedded footer pattern Git uses.