module documentation

Access to base git objects.

Class Blob A Git Blob object.
Class Commit A git commit object
Class FixedSha SHA object that behaves like hashlib's but is given a fixed value.
Class ShaFile A git SHA file.
Class Tag A Git Tag object.
Class Tree A Git tree object
Class TreeEntry Named tuple encapsulating a single tree entry.
Exception EmptyFileException An unexpectedly empty file was encountered.
Exception SubmoduleEncountered A submodule was encountered while resolving a path.
Function check_hexsha Check if a string is a valid hex sha string.
Function check_identity Check if the specified identity is valid.
Function check_time Check if the specified time is not prone to overflow error.
Function filename_to_hex Takes an object filename and returns its corresponding hex sha.
Function format_timezone Format a timezone for Git serialization.
Function git_line Formats items into a space separated line.
Function hex_to_filename Takes a hex sha and returns its filename relative to the given path.
Function hex_to_sha Takes a hex sha and returns a binary sha
Function key_entry Sort key for tree entry.
Function key_entry_name_order Sort key for tree entry in name order.
Function object_class Get the object class corresponding to the given type.
Function object_header Return an object header for the given numeric type and text length.
Function parse_commit Parse a commit object from chunks.
Function parse_time_entry Parse time entry behavior
Function parse_timezone Parse a timezone text fragment (e.g. '+0100').
Function parse_tree Parse a tree text.
Function pretty_format_tree_entry Pretty format tree entry.
Function S_ISGITLINK Check if a mode indicates a submodule.
Function serializable_property A property that helps tracking whether serialization is necessary.
Function serialize_tree Serialize the items in a tree to a text.
Function sha_to_hex Takes a string and returns the hex of the sha within
Function sorted_tree_items Iterate over a tree entries dictionary.
Function valid_hexsha Undocumented
Constant BEGIN_PGP_SIGNATURE Undocumented
Constant MAX_TIME Undocumented
Constant OBJECT_CLASSES Undocumented
Constant S_IFGITLINK Undocumented
Constant ZERO_SHA Undocumented
Function _decompress Undocumented
Function _parse_message Parse a message with a list of fields and a body.
Constant _AUTHOR_HEADER Undocumented
Constant _COMMITTER_HEADER Undocumented
Constant _ENCODING_HEADER Undocumented
Constant _GPGSIG_HEADER Undocumented
Constant _MERGETAG_HEADER Undocumented
Constant _OBJECT_HEADER Undocumented
Constant _PARENT_HEADER Undocumented
Constant _TAG_HEADER Undocumented
Constant _TAGGER_HEADER Undocumented
Constant _TREE_HEADER Undocumented
Constant _TYPE_HEADER Undocumented
Constant _TYPE_MAP Undocumented
def check_hexsha(hex, error_msg):

Check if a string is a valid hex sha string.

Parameters
hexHex string to check
error_msgError message to use in exception
Raises
ObjectFormatExceptionRaised when the string is not valid
def check_identity(identity, error_msg):

Check if the specified identity is valid.

This will raise an exception if the identity is not valid.

Parameters
identity:bytesIdentity string
error_msg:strError message to use in exception
def check_time(time_seconds):

Check if the specified time is not prone to overflow error.

This will raise an exception if the time is not valid.

Parameters
time_secondstime in seconds
def filename_to_hex(filename):

Takes an object filename and returns its corresponding hex sha.

def format_timezone(offset, unnecessary_negative_timezone=False):

Format a timezone for Git serialization.

Parameters
offsetTimezone offset as seconds difference to UTC
unnecessary_negative_timezoneWhether to use a minus sign for UTC or positive timezones (-0000 and --700 rather than +0000 / +0700).
def git_line(*items):

Formats items into a space separated line.

def hex_to_filename(path, hex):

Takes a hex sha and returns its filename relative to the given path.

def hex_to_sha(hex):

Takes a hex sha and returns a binary sha

def key_entry(entry):

Sort key for tree entry.

Parameters
entry(name, value) tuplee
def key_entry_name_order(entry):

Sort key for tree entry in name order.

def object_class(type):

Get the object class corresponding to the given type.

Returns: The ShaFile subclass corresponding to the given type, or None if
type is not a valid type name/number.
Parameters
type:Union[bytes, int]Either a type name string or a numeric type.
Returns
Optional[Type[ShaFile]]Undocumented
def object_header(num_type, length):

Return an object header for the given numeric type and text length.

Parameters
num_type:intUndocumented
length:intUndocumented
Returns
bytesUndocumented
def parse_commit(chunks):

Parse a commit object from chunks.

Returns: Tuple of (tree, parents, author_info, commit_info,
encoding, mergetag, gpgsig, message, extra)
Parameters
chunksChunks to parse
def parse_time_entry(value):

Parse time entry behavior

Returns: Tuple of (author, time, (timezone, timezone_neg_utc))

Parameters
valueBytes representing a git commit/tag line
Raises
ObjectFormatException in case of parsing error (malformed
field date)
def parse_timezone(text):

Parse a timezone text fragment (e.g. '+0100').

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
textText to parse.
def parse_tree(text, strict=False):

Parse a tree text.

Returns: iterator of tuples of (name, mode, sha)

Parameters
textSerialized text to parse
strictUndocumented
Raises
ObjectFormatExceptionif the object was malformed in some way
def pretty_format_tree_entry(name, mode, hexsha, encoding='utf-8'):

Pretty format tree entry.

Returns: string describing the tree entry

Parameters
nameName of the directory entry
modeMode of entry
hexshaHexsha of the referenced object
encodingUndocumented
def S_ISGITLINK(m):

Check if a mode indicates a submodule.

Returns: a boolean

Parameters
mMode to check
def serializable_property(name, docstring=None):

A property that helps tracking whether serialization is necessary.

Parameters
name:strUndocumented
docstring:Optional[str]Undocumented
def serialize_tree(items):

Serialize the items in a tree to a text.

Returns: Serialized tree text as chunks

Parameters
itemsSorted iterable over (name, mode, sha) tuples
def sha_to_hex(sha):

Takes a string and returns the hex of the sha within

def sorted_tree_items(entries, name_order):

Iterate over a tree entries dictionary.

Returns: Iterator over (name, mode, hexsha)

Parameters
entriesDictionary mapping names to (mode, sha) tuples
name_order:boolIf True, iterate entries in order of their name. If False, iterate entries in tree order, that is, treat subtree entries as having '/' appended.
def valid_hexsha(hex):

Undocumented

BEGIN_PGP_SIGNATURE: bytes =

Undocumented

Value
b'-----BEGIN PGP SIGNATURE-----'
MAX_TIME: int =

Undocumented

Value
9223372036854775807
OBJECT_CLASSES =

Undocumented

Value
(Commit, Tree, Blob, Tag)
S_IFGITLINK: int =

Undocumented

Value
57344
ZERO_SHA =

Undocumented

Value
b'0'*40
def _decompress(string):

Undocumented

def _parse_message(chunks):

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[bytes]the raw chunks of the tag or commit object.
_AUTHOR_HEADER: bytes =

Undocumented

Value
b'author'
_COMMITTER_HEADER: bytes =

Undocumented

Value
b'committer'
_ENCODING_HEADER: bytes =

Undocumented

Value
b'encoding'
_GPGSIG_HEADER: bytes =

Undocumented

Value
b'gpgsig'
_MERGETAG_HEADER: bytes =

Undocumented

Value
b'mergetag'
_OBJECT_HEADER: bytes =

Undocumented

Value
b'object'
_PARENT_HEADER: bytes =

Undocumented

Value
b'parent'
_TAG_HEADER: bytes =

Undocumented

Value
b'tag'
_TAGGER_HEADER: bytes =

Undocumented

Value
b'tagger'
_TREE_HEADER: bytes =

Undocumented

Value
b'tree'
_TYPE_HEADER: bytes =

Undocumented

Value
b'type'
_TYPE_MAP: Dict[Union[bytes, int], Type[ShaFile]] =

Undocumented

Value
{}