module documentation

Object specification.

Exception AmbiguousShortId The short id is ambiguous.
Function parse_commit Parse a string referring to a single commit.
Function parse_commit_range Parse a string referring to a commit range.
Function parse_object Parse a string referring to an object.
Function parse_ref Parse a string referring to a reference.
Function parse_refs Parse a list of refspecs to a list of refs.
Function parse_reftuple Parse a reftuple spec.
Function parse_reftuples Parse a list of reftuple specs to a list of reftuples.
Function parse_tree Parse a string referring to a tree.
Function scan_for_short_id Scan an object store for a short id.
Function to_bytes Convert text to bytes.
Function _parse_number_suffix Parse a number from the start of suffix, return (number, remaining).
Function _resolve_object Resolve a reference to an object using multiple strategies.
def parse_commit(repo: BaseRepo, committish: str | bytes | Commit | Tag) -> Commit:

Parse a string referring to a single commit.

Returns: A Commit object

Parameters
repo:BaseRepoA repository object
committish:str | bytes | Commit | TagA string referring to a single commit, or a Commit or Tag object.
Returns
CommitUndocumented
Raises
KeyErrorWhen the reference commits can not be found
ValueErrorIf the range can not be parsed
def parse_commit_range(repo: Repo, committish: str | bytes) -> tuple[Commit, Commit] | None:

Parse a string referring to a commit range.

Parameters
repo:RepoA Repo object
committish:str | bytesA string referring to a commit or range (e.g., "HEAD~3..HEAD")
Returns
tuple[Commit, Commit] | NoneNone if committish is a single commit reference A tuple of (start_commit, end_commit) if it's a range
Raises
KeyErrorWhen the commits can not be found
ValueErrorIf the range can not be parsed
def parse_object(repo: Repo, objectish: bytes | str) -> ShaFile:

Parse a string referring to an object.

Returns: A git object

Parameters
repo:RepoA Repo object
objectish:bytes | strA string referring to an object
Returns
ShaFileUndocumented
Raises
KeyErrorIf the object can not be found
def parse_ref(container: Repo | RefsContainer, refspec: str | bytes) -> Ref:

Parse a string referring to a reference.

Returns: A ref

Parameters
container:Repo | RefsContainerA RefsContainer object
refspec:str | bytesA string referring to a ref
Returns
RefUndocumented
Raises
KeyErrorIf the ref can not be found
def parse_refs(container: Repo | RefsContainer, refspecs: bytes | str | Sequence[bytes | str]) -> list[Ref]:

Parse a list of refspecs to a list of refs.

Returns: A list of refs

Parameters
container:Repo | RefsContainerA RefsContainer object
refspecs:bytes | str | Sequence[bytes | str]A list of refspecs or a string
Returns
list[Ref]Undocumented
Raises
KeyErrorIf one of the refs can not be found
def parse_reftuple(lh_container: Repo | RefsContainer, rh_container: Repo | RefsContainer, refspec: str | bytes, force: bool = False) -> tuple[Ref | None, Ref | None, bool]:

Parse a reftuple spec.

Returns: A tuple with left and right ref

Parameters
lh_container:Repo | RefsContainerA RefsContainer object
rh_container:Repo | RefsContainerA RefsContainer object
refspec:str | bytesA string
force:boolWhether to force the operation
Returns
tuple[Ref | None, Ref | None, bool]Undocumented
Raises
KeyErrorIf one of the refs can not be found
def parse_reftuples(lh_container: Repo | RefsContainer, rh_container: Repo | RefsContainer, refspecs: bytes | Sequence[bytes], force: bool = False) -> list[tuple[Ref | None, Ref | None, bool]]:

Parse a list of reftuple specs to a list of reftuples.

Returns: A list of refs

Parameters
lh_container:Repo | RefsContainerA RefsContainer object
rh_container:Repo | RefsContainerA RefsContainer object
refspecs:bytes | Sequence[bytes]A list of refspecs or a string
force:boolForce overwriting for all reftuples
Returns
list[tuple[Ref | None, Ref | None, bool]]Undocumented
Raises
KeyErrorIf one of the refs can not be found
def parse_tree(repo: BaseRepo, treeish: bytes | str | Tree | Commit | Tag) -> Tree:

Parse a string referring to a tree.

Returns: A Tree object

Parameters
repo:BaseRepoA repository object
treeish:bytes | str | Tree | Commit | TagA string referring to a tree, or a Tree, Commit, or Tag object
Returns
TreeUndocumented
Raises
KeyErrorIf the object can not be found
def scan_for_short_id(object_store: BaseObjectStore, prefix: bytes, tp: type[ShaFile]) -> ShaFile:

Scan an object store for a short id.

def to_bytes(text: str | bytes) -> bytes:

Convert text to bytes.

Parameters
text:str | bytesText to convert (str or bytes)
Returns
bytesBytes representation of text
def _parse_number_suffix(suffix: bytes) -> tuple[int, bytes]:

Parse a number from the start of suffix, return (number, remaining).

def _resolve_object(repo: Repo, ref: Ref | ObjectID | RawObjectID | bytes) -> ShaFile:

Resolve a reference to an object using multiple strategies.