module documentation

Utilities for reading and generating reflogs.

Function drop_reflog_entry Drop the specified reflog entry.
Function expire_reflog Expire reflog entries based on age and reachability.
Function format_reflog_line Generate a single reflog line.
Function iter_reflogs Iterate over all reflogs in a repository.
Function parse_reflog_line Parse a reflog line.
Function parse_reflog_spec Parse a reflog specification like 'HEAD@{1}' or 'refs/heads/master@{2}'.
Function read_reflog Read reflog.
Variable Entry Undocumented
def drop_reflog_entry(f: BinaryIO, index: int, rewrite: bool = False):

Drop the specified reflog entry.

Parameters
f:BinaryIOFile-like object
index:intReflog entry index (in Git reflog reverse 0-indexed order)
rewrite:boolIf a reflog entry's predecessor is removed, set its old SHA to the new SHA of the entry that now precedes it
def expire_reflog(f: BinaryIO, expire_time: int | None = None, expire_unreachable_time: int | None = None, reachable_checker: Callable[[bytes], bool] | None = None) -> int:

Expire reflog entries based on age and reachability.

Parameters
f:BinaryIOFile-like object for the reflog
expire_time:int | NoneExpire entries older than this timestamp (seconds since epoch). If None, entries are not expired based on age alone.
expire_unreachable_time:int | NoneExpire unreachable entries older than this timestamp. If None, unreachable entries are not expired.
reachable_checker:Callable[[bytes], bool] | NoneOptional callable that takes a SHA and returns True if the commit is reachable. If None, all entries are considered reachable.
Returns
intNumber of entries expired
def format_reflog_line(old_sha: bytes | None, new_sha: bytes, committer: bytes, timestamp: int | float, timezone: int, message: bytes) -> bytes:

Generate a single reflog line.

Parameters
old_sha:bytes | NoneOld Commit SHA
new_sha:bytesNew Commit SHA
committer:bytesCommitter name and e-mail
timestamp:int | floatTimestamp
timezone:intTimezone
message:bytesMessage
Returns
bytesUndocumented
def iter_reflogs(logs_dir: str) -> Generator[bytes, None, None]:

Iterate over all reflogs in a repository.

Parameters
logs_dir:strPath to the logs directory (e.g., .git/logs)
Returns
Generator[bytes, None, None]Undocumented
Yields
Reference names (as bytes) that have reflogs
def parse_reflog_line(line: bytes) -> Entry:

Parse a reflog line.

Returns: Tuple of (old_sha, new_sha, committer, timestamp, timezone,
message)
Parameters
line:bytesLine to parse
Returns
EntryUndocumented
def parse_reflog_spec(refspec: str | bytes) -> tuple[bytes, int]:

Parse a reflog specification like 'HEAD@{1}' or 'refs/heads/master@{2}'.

Parameters
refspec:str | bytesReflog specification (e.g., 'HEAD@{1}', 'master@{0}')
Returns
tuple[bytes, int]Tuple of (ref_name, index) where index is in Git reflog order (0 = newest)
Raises
ValueErrorIf the refspec is not a valid reflog specification
def read_reflog(f: BinaryIO | IO[bytes] | _GitFile) -> Generator[Entry, None, None]:

Read reflog.

Returns: Iterator over Entry objects

Parameters
f:BinaryIO | IO[bytes] | _GitFileFile-like object
Returns
Generator[Entry, None, None]Undocumented
Entry =

Undocumented