module documentation

Repository access.

This module contains the base class for git repositories (BaseRepo) and an implementation which uses a repository on local disk (Repo).

Class BaseRepo Base class for a git repository.
Class MemoryRepo Repo that stores refs, objects, and named files in memory.
Class ParentsProvider Undocumented
Class Repo A git repository backed by local disk.
Exception InvalidUserIdentity User identity is not of the format 'user <email>'
Exception UnsupportedExtension Unsupported repository extension.
Exception UnsupportedVersion Unsupported repository version.
Function check_user_identity Verify that a user identity is formatted correctly.
Function get_user_identity Determine the identity to use for new commits.
Function parse_graftpoints Convert a list of graftpoints into a dict
Function read_gitfile Read a .git file.
Function serialize_graftpoints Convert a dictionary of grafts into string
Constant BASE_DIRECTORIES Undocumented
Constant COMMONDIR Undocumented
Constant CONTROLDIR Undocumented
Constant DEFAULT_REF Undocumented
Constant GITDIR Undocumented
Constant INDEX_FILENAME Undocumented
Constant OBJECTDIR Undocumented
Constant REFSDIR Undocumented
Constant REFSDIR_HEADS Undocumented
Constant REFSDIR_TAGS Undocumented
Constant WORKTREES Undocumented
Function _get_default_identity Undocumented
Function _set_filesystem_hidden Mark path as to be hidden if supported by platform and filesystem.
def check_user_identity(identity):

Verify that a user identity is formatted correctly.

Parameters
identityUser identity bytestring
Raises
InvalidUserIdentityRaised when identity is invalid
def get_user_identity(config, kind=None):

Determine the identity to use for new commits.

If kind is set, this first checks GIT_${KIND}_NAME and GIT_${KIND}_EMAIL.

If those variables are not set, then it will fall back to reading the user.name and user.email settings from the specified configuration.

If that also fails, then it will fall back to using the current users' identity as obtained from the host system (e.g. the gecos field, $EMAIL, $USER@$(hostname -f).

Parameters
config:StackedConfigUndocumented
kind:Optional[str]Optional kind to return identity for, usually either "AUTHOR" or "COMMITTER".
Returns
bytesA user identity
def parse_graftpoints(graftpoints):

Convert a list of graftpoints into a dict

Each line is formatted as:
<commit sha1> <parent sha1> [<parent sha1>]*
Resulting dictionary is:
<commit sha1>: [<parent sha1>*]

https://git.wiki.kernel.org/index.php/GraftPoint

Parameters
graftpoints:Iterable[bytes]Iterator of graftpoint lines
Returns
Dict[bytes, List[bytes]]Undocumented
def read_gitfile(f):

Read a .git file.

The first line of the file should start with "gitdir: "

Returns: A path

Parameters
fFile-like object to read from
def serialize_graftpoints(graftpoints):

Convert a dictionary of grafts into string

The graft dictionary is:
<commit sha1>: [<parent sha1>*]
Each line is formatted as:
<commit sha1> <parent sha1> [<parent sha1>]*

https://git.wiki.kernel.org/index.php/GraftPoint

Parameters
graftpoints:Dict[bytes, List[bytes]]Undocumented
Returns
bytesUndocumented
BASE_DIRECTORIES =

Undocumented

Value
[['branches'],
 [REFSDIR],
 [REFSDIR, REFSDIR_TAGS],
 [REFSDIR, REFSDIR_HEADS],
 ['hooks'],
 ['info']]
COMMONDIR: str =

Undocumented

Value
'commondir'
CONTROLDIR: str =

Undocumented

Value
'.git'
DEFAULT_REF: bytes =

Undocumented

Value
b'refs/heads/master'
GITDIR: str =

Undocumented

Value
'gitdir'
INDEX_FILENAME: str =

Undocumented

Value
'index'
OBJECTDIR: str =

Undocumented

Value
'objects'
REFSDIR: str =

Undocumented

Value
'refs'
REFSDIR_HEADS: str =

Undocumented

Value
'heads'
REFSDIR_TAGS: str =

Undocumented

Value
'tags'
WORKTREES: str =

Undocumented

Value
'worktrees'
def _get_default_identity():

Undocumented

Returns
Tuple[str, str]Undocumented
def _set_filesystem_hidden(path):

Mark path as to be hidden if supported by platform and filesystem.

On win32 uses SetFileAttributesW api: <https://docs.microsoft.com/windows/desktop/api/fileapi/nf-fileapi-setfileattributesw>