Access to base git objects.
| Class | |
A Git Blob object. |
| Class | |
A git commit object. |
| Class | |
SHA object that behaves like hashlib's but is given a fixed value. |
| Class | |
A git SHA file. |
| Class | |
A Git Tag object. |
| Class | |
A Git tree object. |
| Class | |
Named tuple encapsulating a single tree entry. |
| Exception | |
An unexpectedly empty file was encountered. |
| Exception | |
A submodule was encountered while resolving a path. |
| Function | check |
Check if a string is a valid hex sha string. |
| Function | check |
Check if the specified identity is valid. |
| Function | check |
Check if the specified time is not prone to overflow error. |
| Function | filename |
Takes an object filename and returns its corresponding hex sha. |
| Function | format |
Format an event. |
| Function | format |
Format a timezone for Git serialization. |
| Function | git |
Formats items into a space separated line. |
| Function | hex |
Takes a hex sha and returns its filename relative to the given path. |
| Function | hex |
Takes a hex sha and returns a binary sha. |
| Function | is |
Check if a ShaFile is a Blob. |
| Function | is |
Check if a ShaFile is a Commit. |
| Function | is |
Check if a ShaFile is a Tag. |
| Function | is |
Check if a ShaFile is a Tree. |
| Function | key |
Sort key for tree entry. |
| Function | key |
Sort key for tree entry in name order. |
| Function | object |
Get the object class corresponding to the given type. |
| Function | object |
Return an object header for the given numeric type and text length. |
| Function | parse |
Parse a commit with broken author/committer lines. |
| Function | parse |
Parse event. |
| Function | parse |
Parse event, accepting broken formats. |
| Function | parse |
Parse a timezone text fragment (e.g. '+0100'). |
| Function | parse |
Parse a timezone text fragment, accepting broken formats. |
| Function | parse |
Parse a tree text. |
| Function | pretty |
Pretty format tree entry. |
| Function | S |
Check if a mode indicates a submodule. |
| Function | serializable |
A property that helps tracking whether serialization is necessary. |
| Function | serialize |
Serialize the items in a tree to a text. |
| Function | sha |
Takes a string and returns the hex of the sha within. |
| Function | sorted |
Iterate over a tree entries dictionary. |
| Function | valid |
Check if a hex string is a valid SHA1 or SHA256. |
| Constant | BEGIN |
Undocumented |
| Constant | BEGIN |
Undocumented |
| Constant | MAX |
Undocumented |
| Constant | OBJECT |
Undocumented |
| Constant | S |
Undocumented |
| Constant | SIGNATURE |
Undocumented |
| Constant | SIGNATURE |
Undocumented |
| Constant | ZERO |
Undocumented |
| Type Variable | |
Undocumented |
| Variable | |
Undocumented |
| Variable | |
Undocumented |
| Function | _decompress |
Undocumented |
| Function | _format |
Undocumented |
| Function | _parse |
Parse a commit object from chunks. |
| Function | _parse |
Parse a commit object from chunks, accepting broken formats. |
| Function | _parse |
Parse a message with a list of fields and a body. |
| Function | _path |
Convert a path to bytes for use in error messages. |
| Constant | _AUTHOR |
Undocumented |
| Constant | _COMMITTER |
Undocumented |
| Constant | _ENCODING |
Undocumented |
| Constant | _GPGSIG |
Undocumented |
| Constant | _MERGETAG |
Undocumented |
| Constant | _OBJECT |
Undocumented |
| Constant | _PARENT |
Undocumented |
| Constant | _TAG |
Undocumented |
| Constant | _TAGGER |
Undocumented |
| Constant | _TIME |
Undocumented |
| Constant | _TREE |
Undocumented |
| Constant | _TYPE |
Undocumented |
| Constant | _TYPE |
Undocumented |
Check if a string is a valid hex sha string.
| Parameters | |
hex:str | bytes | Hex string to check |
errorstr | Error message to use in exception |
| Raises | |
ObjectFormatException | Raised when the string is not valid |
Check if the specified time is not prone to overflow error.
This will raise an exception if the time is not valid.
| Parameters | |
timeint | time in seconds |
Parse a commit with broken author/committer lines.
This function handles various broken formats found in the wild: - Missing angle brackets around email addresses - Unsigned timezones (e.g., "0000" instead of "+0000") - Double-negative timezones (e.g., "--700") - Negative timestamps - Long/short/nonsensical timezone values
Warning: Commits parsed with this function may not round-trip correctly through serialization, as the broken formatting is normalized during parsing. The .check() method will likely fail for commits with malformed identity fields.
Example
>>> data = b'''tree d80c186a03f423a81b39df39dc87fd269736ca86 ... author [email protected] 1234567890 -0500 ... committer [email protected] 1234567890 -0500 ... ... Commit message ... ''' >>> commit = parse_commit_broken(data) >>> commit.author b'[email protected]'
| Parameters | |
data:bytes | Raw commit data as bytes |
| Returns | |
Commit | A Commit object with normalized fields |
Parse event, accepting broken formats.
This function handles various broken author/committer/tagger line formats: - Missing angle brackets around email - Unsigned timezones - Double-negative timezones
Returns: Tuple of (author, time, (timezone, timezone_neg_utc))
| Parameters | |
value:bytes | Bytes representing a git commit/tag line |
| Returns | |
tuple[ | Undocumented |
| Raises | |
ObjectFormatException in case of parsing error | |
Parse a timezone text fragment, accepting broken formats.
This function handles various broken timezone formats found in the wild: - Missing sign prefix (e.g., '0000' instead of '+0000') - Double negative (e.g., '--700')
- Returns: Tuple with timezone as seconds difference to UTC
- and a boolean indicating whether this was a UTC timezone prefixed with a negative sign (-0000).
| Parameters | |
text:bytes | Text to parse. |
| Returns | |
tuple[ | Undocumented |
bytes, sha_len: int | None = None, *, strict: bool = False) -> Iterator[ tuple[ bytes, int, bytes]]:
¶
Parse a tree text.
Returns: iterator of tuples of (name, mode, sha)
| Parameters | |
text:bytes | Serialized text to parse |
shaint | None | Length of the object IDs in bytes |
strict:bool | Whether to be strict about format |
| Returns | |
Iterator[ | Undocumented |
| Raises | |
ObjectFormatException | if the object was malformed in some way |
dict[ bytes, tuple[ int, ObjectID]], name_order: bool) -> Iterator[ TreeEntry]:
¶
Iterate over a tree entries dictionary.
Returns: Iterator over (name, mode, hexsha)
| Parameters | |
entries:dict[ | Dictionary mapping names to (mode, sha) tuples |
namebool | If True, iterate entries in order of their name. If False, iterate entries in tree order, that is, treat subtree entries as having '/' appended. |
| Returns | |
Iterator[ | Undocumented |
Sequence[ tuple[ bytes, bytes]], body: bytes | None) -> Iterator[ bytes]:
¶
Undocumented
Iterable[ bytes]) -> tuple[ bytes | None, list[ bytes], tuple[ bytes | None, int | None, tuple[ int | None, bool | None]], tuple[ bytes | None, int | None, tuple[ int | None, bool | None]], bytes | None, list[ Tag], bytes | None, bytes | None, list[ tuple[ bytes, bytes]]]:
¶
Parse a commit object from chunks.
- Returns: Tuple of (tree, parents, author_info, commit_info,
- encoding, mergetag, gpgsig, message, extra)
| Parameters | |
chunks:Iterable[ | Chunks to parse |
| Returns | |
tuple[ | Undocumented |
Iterable[ bytes]) -> tuple[ bytes | None, list[ bytes], tuple[ bytes | None, int | None, tuple[ int | None, bool | None]], tuple[ bytes | None, int | None, tuple[ int | None, bool | None]], bytes | None, list[ Tag], bytes | None, bytes | None, list[ tuple[ bytes, bytes]]]:
¶
Parse a commit object from chunks, accepting broken formats.
This function handles various broken author/committer line formats: - Missing angle brackets around email - Unsigned timezones - Double-negative timezones
- Returns: Tuple of (tree, parents, author_info, commit_info,
- encoding, mergetag, gpgsig, message, extra)
| Parameters | |
chunks:Iterable[ | Chunks to parse |
| Returns | |
tuple[ | Undocumented |
Iterable[ bytes]) -> Iterator[ tuple[ None, None] | tuple[ bytes | None, bytes]]:
¶
Parse a message with a list of fields and a body.
- Returns: iterator of tuples of (field, value), one per header line, in the
- order read from the text, possibly including duplicates. Includes a field named None for the freeform tag/commit text.
| Parameters | |
chunks:Iterable[ | the raw chunks of the tag or commit object. |
| Returns | |
Iterator[ | Undocumented |
Undocumented
| Value |
|