Known subclasses: gbp.pkg.git.PkgGitRepository

Represents a git repository at I{path}. It's currently assumed that the git
repository is stored in a directory named I{.git/} below I{path}.

@ivar _path: The path to the working tree
@type _path: C{str}
@ivar _bare: Whether this is a bare repository
@type _bare: C{bool}
@raises GitRepositoryError: on git errors GitRepositoryError is raised by
    all methods.
Method __init__ No summary
Class Method git_inout As _git_inout but can be used without an instance
Method path The absolute path to the repository
Method git_dir The absolute path to git's metadata
Method bare Whether this is a bare repository
Method tags List of all tags in the repository
Method branch The currently checked out branch
Method head SHA1 of the current HEAD
Method rename_branch Rename branch
Method create_branch Create a new branch
Method delete_branch Delete branch I{branch}
Method get_branch On what branch is the current working copy
Method has_branch Check if the repository has branch named I{branch}.
Method set_branch Switch to branch I{branch}
Method get_merge_branch Get the branch we'd merge from
Method get_merge_base Get the common ancestor between two commits
Method merge Merge changes from the named commit into the current branch
Method abort_merge Abort a merge
Method is_in_merge Undocumented
Method is_fast_forward Check if an update I{from from_branch} to I{to_branch} would be a fast forward or if the branch is up to date already.
Method get_local_branches Get a list of local branches
Method get_remote_branches Get a list of remote branches
Method update_ref Update ref I{ref} to commit I{new} if I{ref} currently points to I{old}
Method branch_contains Check if branch I{branch} contains commit I{commit}
Method set_upstream_branch Set upstream branches for local branch
Method get_upstream_branch Get upstream branch for the local branch
Method create_tag Create a new tag.
Method delete_tag Delete a tag named I{tag}
Method move_tag Undocumented
Method has_tag Check if the repository has a tag named I{tag}.
Method describe Describe commit, relative to the latest tag reachable from it.
Method find_tag Find the closest tag to a given commit
Method find_branch_tag Find the closest tag on a certain branch to a given commit
Method get_tags List tags
Method verify_tag Verify a signed tag
Method force_head Force HEAD to a specific commit
Method is_clean Does the repository contain any uncommitted modifications?
Method clean Remove untracked files from the working tree.
Method status Check status of repository.
Method is_empty Is the repository empty?
Method rev_parse Find the SHA1 of a given name
Static Method strip_sha1 Strip a given sha1 and check if the resulting hash has the expected length.
Method checkout Checkout treeish
Method has_treeish Check if the repository has the treeish object I{treeish}.
Method write_tree Create a tree object from the current index
Method make_tree Create a tree based on contents.
Method get_obj_type Get type of a git repository object
Method list_tree Get a trees content. It returns a list of objects that match the 'ls-tree' output: [mode, type, sha1, path].
Method get_config Gets the config value associated with I{name}
Method set_config Set a git config value in this repository
Method set_user_name Sets the full name to use for git commits.
Method set_user_email Sets the email address to use for git commits.
Method get_author_info Determine a sane values for author name and author email from git's config and environment variables.
Method get_remotes Get a list of remote repositories
Method get_remote_repos Get all remote repositories
Method has_remote_repo Do we know about a remote named I{name}?
Method add_remote_repo Add a tracked remote repository
Method remove_remote_repo Undocumented
Method fetch Download objects and refs from another repository.
Method pull Fetch and merge from another repository
Method push Push changes to the remote repo
Method push_tag Push a tag to the remote repo
Method add_files Add files to a the repository
Method remove_files Remove files from the repository
Method list_files List files in index and working tree
Method write_file Hash a single file and write it into the object database
Method rename_file Rename file, directory, or symlink
Method commit_staged Commit currently staged files to the repository
Method commit_all No summary
Method commit_files Commit the given files to the repository
Method commit_dir Replace the current tip of branch I{branch} with the contents from I{unpack_dir}
Method commit_tree Commit a tree with commit msg I{msg} and parents I{parents}
Method get_commits Get commits from since to until touching paths
Method show Show a git object
Method grep_log Get commmits matching I{regex}
Method get_subject Gets the subject of a commit.
Method get_commit_info Look up data of a specific commit-ish. Dereferences given commit-ish to the commit it points to.
Method format_patches Output the commits between start and end as patches in output_dir.
Method apply_patch Apply a patch using git apply
Method diff Diff two git repository objects
Method diff_status Get file-status of two git repository objects
Method archive Create an archive from a treeish
Method collect_garbage Cleanup unnecessary files and optimize the local repository
Method has_submodules Does the repo have any submodules?
Method add_submodule Add a submodule
Method update_submodules Update all submodules
Method get_submodules List the submodules of treeish
Class Method create Create a repository at path
Class Method clone Clone a git repository at I{remote} to I{path}.
Method _check_bare Check whether this is a bare repository
Method _get_git_dir Undocumented
Method _check_repo Undocumented
Static Method __build_env Prepare environment for subprocess calls
Method _git_getoutput Run a git command and return the output
Method _git_inout Run a git command with input and return output
Method _git_command Execute git command with arguments args and environment env at path.
Method _cmd_has_feature Check if the git command has certain feature enabled.
Method _get_branches Get a list of branches
Method _status Undocumented
Method _commit Undocumented
def _check_bare(self):
Check whether this is a bare repository
def _get_git_dir(self):
Undocumented
def _check_repo(self, path, toplevel):
Undocumented
def __init__(self, path, toplevel=True):
@param path: path to git repo (or subdir)
@type path: C{str}
@param toplevel: whether path points to the toplevel dir of
    git repository
@type toplevel: C{bool}
@staticmethod
def __build_env(extra_env):
Prepare environment for subprocess calls
def _git_getoutput(self, command, args=[], extra_env=None, cwd=None):
Run a git command and return the output

@param command: git command to run
@type command: C{str}
@param args: list of arguments
@type args: C{list}
@param extra_env: extra environment variables to pass
@type extra_env: C{dict}
@param cwd: directory to switch to when running the command, defaults to I{self.path}
@type cwd: C{str}
@return: stdout, return code
@rtype: C{tuple} of C{list} of C{bytestr} and C{int}

@deprecated: use L{gbp.git.repository.GitRepository._git_inout} instead.
def _git_inout(self, command, args, input=None, extra_env=None, cwd=None, capture_stderr=False, config_args=None):
Run a git command with input and return output

@param command: git command to run
@type command: C{str}
@param input: input to pipe to command
@type input: C{str}
@param args: list of arguments
@type args: C{list}
@param extra_env: extra environment variables to pass
@type extra_env: C{dict}
@param cwd: directory to switch to when running the command, defaults to I{self.path}
@type cwd: C{str}
@param capture_stderr: whether to capture stderr
@type capture_stderr: C{bool}
@return: stdout, stderr, return code
@rtype: C{tuple} of C{bytestr}, C{bytestr}, C{int}
@classmethod
def git_inout(cls, command, args, input, extra_env, cwd, capture_stderr, config_args=None):
As _git_inout but can be used without an instance
def _git_command(self, command, args=[], extra_env=None):
Execute git command with arguments args and environment env
at path.

@param command: git command
@type command: C{str}
@param args: command line arguments
@type args: C{list}
@param extra_env: extra environment variables to set when running command
@type extra_env: C{dict}
def _cmd_has_feature(self, command, feature):
Check if the git command has certain feature enabled.

@param command: git command
@type command: C{str}
@param feature: feature / command option to check
@type feature: C{str}
@return: True if feature is supported
@rtype: C{bool}
@property
def path(self):
The absolute path to the repository
@property
def git_dir(self):
The absolute path to git's metadata
@property
def bare(self):
Whether this is a bare repository
@property
def tags(self):
List of all tags in the repository
@property
def branch(self):
The currently checked out branch
@property
def head(self):
SHA1 of the current HEAD
def rename_branch(self, branch, newbranch):
Rename branch

@param branch: name of the branch to be renamed
@param newbranch: new name of the branch
def create_branch(self, branch, rev=None, force=False):
Create a new branch

@param branch: the branch's name
@param rev: where to start the branch from
@param force: reset branch HEAD to start point, if it already exists

If rev is None the branch starts from the current HEAD.
def delete_branch(self, branch, remote=False):
Delete branch I{branch}

@param branch: name of the branch to delete
@type branch: C{str}
@param remote: delete a remote branch
@param remote: C{bool}
def get_branch(self):
On what branch is the current working copy

@return: current branch or C{None} in an empty repo
@rtype: C{str}
@raises GitRepositoryError: if HEAD is not a symbolic ref
  (e.g. when in detached HEAD state)
def has_branch(self, branch, remote=False):
Check if the repository has branch named I{branch}.

@param branch: branch to look for
@param remote: only look for remote branches
@type remote: C{bool}
@return: C{True} if the repository has this branch, C{False} otherwise
@rtype: C{bool}
def set_branch(self, branch):
Switch to branch I{branch}

@param branch: name of the branch to switch to
@type branch: C{str}
def get_merge_branch(self, branch):
Get the branch we'd merge from

@return: repo and branch we would merge from
@rtype: C{str}
def get_merge_base(self, commit1, commit2):
Get the common ancestor between two commits

@param commit1: commit SHA1 or name of a branch or tag
@type commit1: C{str}
@param commit2: commit SHA1 or name of a branch or tag
@type commit2: C{str}
@return: SHA1 of the common ancestor
@rtype: C{str}
def merge(self, commit, verbose=False, edit=False):
Merge changes from the named commit into the current branch

@param commit: the commit to merge from (usually a branch name or tag)
@type commit: C{str}
@param verbose: whether to print a summary after the merge
@type verbose: C{bool}
@param edit: whether to invoke an editor to edit the merge message
@type edit: C{bool}
def abort_merge(self):
Abort a merge
def is_in_merge(self):
Undocumented
def is_fast_forward(self, from_branch, to_branch):
Check if an update I{from from_branch} to I{to_branch} would be a fast
forward or if the branch is up to date already.

@return: can_fast_forward, up_to_date
@rtype: C{tuple}
def _get_branches(self, remote=False):
Get a list of branches

@param remote: whether to list local or remote branches
@type remote: C{bool}
@return: local or remote branches
@rtype: C{list}
def get_local_branches(self):
Get a list of local branches

@return: local branches
@rtype: C{list}
def get_remote_branches(self):
Get a list of remote branches

@return: remote branches
@rtype: C{list}
def update_ref(self, ref, new, old=None, msg=None):
Update ref I{ref} to commit I{new} if I{ref} currently points to
I{old}

@param ref: the ref to update
@type ref: C{str}
@param new: the new value for ref
@type new: C{str}
@param old: the old value of ref
@type old: C{str}
@param msg: the reason for the update
@type msg: C{str}
def branch_contains(self, branch, commit, remote=False):
Check if branch I{branch} contains commit I{commit}

@param branch: the branch the commit should be on
@type branch: C{str}
@param commit: the C{str} commit to check
@type commit: C{str}
@param remote: whether to check remote instead of local branches
@type remote: C{bool}
def set_upstream_branch(self, local_branch, upstream):
Set upstream branches for local branch

@param local_branch: name of the local branch
@type local_branch: C{str}
@param upstream: Remote branch in the form remote/branch, e.g. origin/master
@type upstream: C{str}
def get_upstream_branch(self, local_branch):
Get upstream branch for the local branch

@param local_branch: name fo the local branch
@type local_branch: C{str}
@return: upstream (remote/branch) or  '' if no upstream found
@rtype: C{str}
def create_tag(self, name, msg=None, commit=None, sign=False, keyid=None):
Create a new tag.

@param name: the tag's name
@type name: C{str}
@param msg: The tag message.
@type msg: C{str}
@param commit: the commit or object to create the tag at, default
    is I{HEAD}
@type commit: C{str}
@param sign: Whether to sing the tag
@type sign: C{bool}
@param keyid: the GPG keyid used to sign the tag
@type keyid: C{str}
def delete_tag(self, tag):
Delete a tag named I{tag}

@param tag: the tag to delete
@type tag: C{str}
def move_tag(self, old, new):
Undocumented
def has_tag(self, tag):
Check if the repository has a tag named I{tag}.

@param tag: tag to look for
@type tag: C{str}
@return: C{True} if the repository has that tag, C{False} otherwise
@rtype: C{bool}
def describe(self, commitish, pattern=None, longfmt=False, always=False, abbrev=None, tags=False, exact_match=False):
Describe commit, relative to the latest tag reachable from it.

@param commitish: the commit-ish to describe
@type commitish: C{str}
@param pattern: only look for tags matching I{pattern}
@type pattern: C{str}
@param longfmt: describe the commit in the long format
@type longfmt: C{bool}
@param always: return commit sha1 as fallback if no tag is found
@type always: C{bool}
@param abbrev: abbreviate sha1 to given length instead of the default
@type abbrev: None or C{long}
@param tags: enable matching a lightweight (non-annotated) tag
@type tags: C{bool}
@param exact_match: only output exact matches (a tag directly
references the supplied commit)
@type exact_match: C{bool}
@return: tag name plus/or the abbreviated sha1
@rtype: C{str}
def find_tag(self, commit, pattern=None):
Find the closest tag to a given commit

@param commit: the commit to describe
@type commit: C{str}
@param pattern: only look for tags matching I{pattern}
@type pattern: C{str}
@return: the found tag
@rtype: C{str}
def find_branch_tag(self, commit, branch, pattern=None):
Find the closest tag on a certain branch to a given commit

@param commit: the commit to describe
@type commit: C{str}
@type branch: C{str}
@param pattern: only look for tags matching I{pattern}
@type pattern: C{str}
@return: the found tag
@rtype: C{str}
def get_tags(self, pattern=None):
List tags

@param pattern: only list tags matching I{pattern}
@type pattern: C{str}
@return: tags
@rtype: C{list} of C{str}
def verify_tag(self, tag):
Verify a signed tag

@param tag: the tag's name
@type tag: C{str}
@return: Whether the signature on the tag could be verified
@rtype: C{bool}
def force_head(self, commit, hard=False):
Force HEAD to a specific commit

@param commit: commit to move HEAD to
@param hard: also update the working copy
@type hard: C{bool}
def _status(self, porcelain, ignore_untracked, paths):
Undocumented
def is_clean(self, ignore_untracked=False, paths=None):
Does the repository contain any uncommitted modifications?

@param ignore_untracked: whether to ignore untracked files when
    checking the repository status
@type ignore_untracked: C{bool}
@param paths: only check changes on paths
@type paths: C{list} of C{stings}
@return: C{True} if the repository is clean, C{False} otherwise
    and Git's status message
@rtype: C{tuple}
def clean(self, directories=False, force=False, dry_run=False):
Remove untracked files from the working tree.

@param directories: remove untracked directories, too
@type directories: C{bool}
@param force: satisfy git configuration variable clean.requireForce
@type force: C{bool}
@param dry_run: don’t actually remove anything
@type dry_run: C{bool}
def status(self, pathlist=None):
Check status of repository.

@param pathlist: List of paths to check status for
@type pathlist: C{list}
@return C{dict} of C{lists} of paths, where key is a git status flag.
@rtype C{dict}
def is_empty(self):
Is the repository empty?

@return: True if the repositorydoesn't have any commits,
    False otherwise
@rtype: C{bool}
def rev_parse(self, name, short=0):
Find the SHA1 of a given name

@param name: the name to look for
@type name: C{str}
@param short:  try to abbreviate SHA1 to given length
@type short: C{int}
@return: the name's sha1
@rtype: C{str}
@staticmethod
def strip_sha1(sha1, length=0):
Strip a given sha1 and check if the resulting
hash has the expected length.

>>> GitRepository.strip_sha1('  58ef37dbeb12c44b206b92f746385a6f61253c0a\n')
'58ef37dbeb12c44b206b92f746385a6f61253c0a'
>>> GitRepository.strip_sha1('58ef37d', 10)
Traceback (most recent call last):
...
gbp.git.repository.GitRepositoryError: '58ef37d' is not a valid sha1 of length 10
>>> GitRepository.strip_sha1('58ef37d', 7)
'58ef37d'
>>> GitRepository.strip_sha1('123456789', 7)
'123456789'
>>> GitRepository.strip_sha1('foobar')
Traceback (most recent call last):
...
gbp.git.repository.GitRepositoryError: 'foobar' is not a valid sha1
def checkout(self, treeish):
Checkout treeish

@param treeish: the treeish to check out
@type treeish: C{str}
def has_treeish(self, treeish):
Check if the repository has the treeish object I{treeish}.

@param treeish: treeish object to look for
@type treeish: C{str}
@return: C{True} if the repository has that tree, C{False} otherwise
@rtype: C{bool}
def write_tree(self, index_file=None):
Create a tree object from the current index

@param index_file: alternate index file to read changes from
@type index_file: C{str}
@return: the new tree object's sha1
@rtype: C{str}
def make_tree(self, contents):
Create a tree based on contents.

@param contents: same format as I{GitRepository.list_tree} output.
@type contents: C{list} of C{str}
def get_obj_type(self, obj):
Get type of a git repository object

@param obj: repository object
@type obj: C{str}
@return: type of the repository object
@rtype: C{str}
def list_tree(self, treeish, recurse=False, paths=None):
Get a trees content. It returns a list of objects that match the
'ls-tree' output: [mode, type, sha1, path].

@param treeish: the treeish object to list
@type treeish: C{str}
@param recurse: whether to list the tree recursively
@type recurse: C{bool}
@return: the tree
@rtype: C{list} of objects. See above.
def get_config(self, name):
Gets the config value associated with I{name}

@param name: config value to get
@return: fetched config value
@rtype: C{str}
def set_config(self, name, value):
Set a git config value in this repository
def set_user_name(self, name):
Sets the full name to use for git commits.

@param name: full name to use
def set_user_email(self, email):
Sets the email address to use for git commits.

@param email: email address to use
def get_author_info(self):
Determine a sane values for author name and author email from git's
config and environment variables.

@return: name and email
@rtype: L{GitModifier}
def get_remotes(self):
Get a list of remote repositories

@return: remote repositories
@rtype: C{dict} of C{GitRemote}
def get_remote_repos(self):
Get all remote repositories

@deprecated: Use get_remotes() instead

@return: remote repositories
@rtype: C{list} of C{str}
def has_remote_repo(self, name):
Do we know about a remote named I{name}?

@param name: name of the remote repository
@type name: C{str}
@return: C{True} if the remote repositore is known, C{False} otherwise
@rtype: C{bool}
def add_remote_repo(self, name, url, tags=True, fetch=False):
Add a tracked remote repository

@param name: the name to use for the remote
@type name: C{str}
@param url: the url to add
@type url: C{str}
@param tags: whether to fetch tags
@type tags: C{bool}
@param fetch: whether to fetch immediately from the remote side
@type fetch: C{bool}
def remove_remote_repo(self, name):
Undocumented
def fetch(self, repo=None, tags=False, depth=0, refspec=None, all_remotes=False):
Download objects and refs from another repository.

@param repo: repository to fetch from
@type repo: C{str}
@param tags: whether to fetch all tag objects
@type tags: C{bool}
@param depth: deepen the history of (shallow) repository to depth I{depth}
@type depth: C{int}
@param refspec: refspec to use instead of the default from git config
@type refspec: C{str}
@param all_remotes: fetch all remotes
@type all_remotes: C{bool}
def pull(self, repo=None, ff_only=False, all_remotes=False):
Fetch and merge from another repository

@param repo: repository to fetch from
@type repo: C{str}
@param ff_only: only merge if this results in a fast forward merge
@type ff_only: C{bool}
@param all_remotes: fetch all remotes
@type all_remotes: C{bool}
def push(self, repo=None, src=None, dst=None, ff_only=True, force=False, tags=False, dry_run=False):
Push changes to the remote repo

@param repo: repository to push to
@type repo: C{str}
@param src: the source ref to push
@type src: C{str}
@param dst: the name of the destination ref to push to
@type dst: C{str}
@param ff_only: only push if it's a fast forward update
@type ff_only: C{bool}
@param force: force push, can cause the remote repository to lose
commits; use it with care
@type force: C{bool}
@param tags: push all refs under refs/tags, in addition to other refs
@type tags: C{bool}
@param dry_run: dry run
@type dry_run: C{bool}
def push_tag(self, repo, tag, dry_run=False):
Push a tag to the remote repo

@param repo: repository to push to
@type repo: C{str}
@param tag: the name of the tag
@type tag: C{str}
@param dry_run: dry run
@type dry_run: C{bool}
def add_files(self, paths, force=False, index_file=None, work_tree=None):
Add files to a the repository

@param paths: list of files to add
@type paths: list or C{str}
@param force: add files even if they would be ignored by .gitignore
@type force: C{bool}
@param index_file: alternative index file to use
@param work_tree: alternative working tree to use
def remove_files(self, paths, verbose=False):
Remove files from the repository

@param paths: list of files to remove
@param paths: C{list} or C{str}
@param verbose: be verbose
@type verbose: C{bool}
def list_files(self, types=['cached']):
List files in index and working tree

@param types: list of types to show
@type types: C{list}
@return: list of files as byte string
@rtype: C{list} of C{str}
def write_file(self, filename, filters=True):
Hash a single file and write it into the object database

@param filename: the filename to the content of the file to hash
@type filename: C{bytestr}
@param filters: whether to run filters
@type filters: C{bool}
@return: the hash of the file
@rtype: C{str}
def rename_file(self, old, new):
Rename file, directory, or symlink
def _commit(self, msg, args=[], author_info=None):
Undocumented
def commit_staged(self, msg, author_info=None, edit=False):
Commit currently staged files to the repository

@param msg: commit message
@type msg: C{str}
@param author_info: authorship information
@type author_info: L{GitModifier}
@param edit: whether to spawn an editor to edit the commit info
@type edit: C{bool}
def commit_all(self, msg, author_info=None, edit=False):
Commit all changes to the repository
@param msg: commit message
@type msg: C{str}
@param author_info: authorship information
@type author_info: L{GitModifier}
def commit_files(self, files, msg, author_info=None):
Commit the given files to the repository

@param files: file or files to commit
@type files: C{str} or C{list}
@param msg: commit message
@type msg: C{str}
@param author_info: authorship information
@type author_info: L{GitModifier}
def commit_dir(self, unpack_dir, msg, branch, other_parents=None, author={}, committer={}, create_missing_branch=False):
Replace the current tip of branch I{branch} with the contents from I{unpack_dir}

@param unpack_dir: content to add
@type unpack_dir: C{str}
@param msg: commit message to use
@type msg: C{str}
@param branch: branch to add the contents of unpack_dir to
@type branch: C{str}
@param other_parents: additional parents of this commit
@type other_parents: C{list} of C{str}
@param author: author information to use for commit
@type author: C{dict} with keys I{name}, I{email}, I{date}
@param committer: committer information to use for commit
@type committer: C{dict} with keys I{name}, I{email}, I{date}
    or L{GitModifier}
@param create_missing_branch: create I{branch} as detached branch if it
    doesn't already exist.
@type create_missing_branch: C{bool}
def commit_tree(self, tree, msg, parents, author={}, committer={}):
Commit a tree with commit msg I{msg} and parents I{parents}

@param tree: tree to commit
@param msg: commit message
@param parents: parents of this commit
@param author: authorship information
@type author: C{dict} with keys 'name' and 'email' or L{GitModifier}
@param committer: committer information
@type committer: C{dict} with keys 'name' and 'email'
def get_commits(self, since=None, until=None, paths=None, num=0, first_parent=False, options=None):
Get commits from since to until touching paths

@param since: commit to start from
@type since: C{str}
@param until: last commit to get
@type until: C{str}
@param paths: only list commits touching paths
@type paths: C{list} of C{str}
@param num: maximum number of commits to fetch
@type num: C{int}
@param options: list of additional options passed to git log
@type  options: C{list} of C{str}ings
@param first_parent: only follow first parent when seeing a
                     merge commit
@type first_parent: C{bool}
def show(self, id):
Show a git object

@rtype: C{bytestr}
def grep_log(self, regex, since=None, merges=True):
Get commmits matching I{regex}

@param regex: regular expression
@type regex: C{str}
@param since: where to start grepping (e.g. a branch)
@type since: C{str}
def get_subject(self, commit):
Gets the subject of a commit.

@deprecated: Use get_commit_info directly

@param commit: the commit to get the subject from
@return: the commit's subject
@rtype: C{str}
def get_commit_info(self, commitish):
Look up data of a specific commit-ish. Dereferences given commit-ish
to the commit it points to.

@param commitish: the commit-ish to inspect
@return: the commit's including id, author, email, subject and body
@rtype: dict
def format_patches(self, start, end, output_dir, signature=True, thread=None, symmetric=True):
Output the commits between start and end as patches in output_dir.

This outputs the revisions I{start...end} by default. When using
I{symmetric} to C{false} it uses I{start..end} instead.

@param start: the commit on the left side of the revision range
@param end: the commit on the right hand side of the revisino range
@param output_dir: directory to write the patches to
@param signature: whether to output a signature
@param thread: whether to include In-Reply-To references
@param symmetric: whether to use the symmetric difference (see above)
def apply_patch(self, patch, index=True, context=None, strip=None, fix_ws=False):
Apply a patch using git apply
def diff(self, obj1, obj2=None, paths=None, stat=False, summary=False, text=False, ignore_submodules=True, abbrev=None, renames=False):
Diff two git repository objects

@param obj1: first object
@type obj1: C{str}
@param obj2: second object
@type obj2: C{str}
@param paths: List of paths to diff
@type paths: C{list}
@param stat: Show diffstat
@type stat: C{bool} or C{int} or C{str}
@param summary: Show diffstat
@type summary: C{bool}
@param text: Generate textual diffs, treat all files as text
@type text: C{bool}
@param ignore_submodules: ignore changes to submodules
@type ignore_submodules: C{bool}
@return: diff
@rtype: C{binary}
def diff_status(self, obj1, obj2):
Get file-status of two git repository objects

@param obj1: first object
@type obj1: C{str}
@param obj2: second object
@type obj2: C{str}
@return: name-status
@rtype: C{defaultdict} of C{str}
def archive(self, format, prefix, output, treeish, cwd=None):
Create an archive from a treeish

@param format: the type of archive to create, e.g. 'tar.gz'
@type format: C{str}
@param prefix: prefix to prepend to each filename in the archive
@type prefix: C{str}
@param output: the name of the archive to create
@type output: C{str}
@param treeish: the treeish to create the archive from
@type treeish: C{str}
@param cwd: The directory to run in. Defaults to the current dir
@type cwd: C{str}
def collect_garbage(self, auto=False, prune=False, aggressive=False):
Cleanup unnecessary files and optimize the local repository

param auto: only cleanup if required
param auto: C{bool}
def has_submodules(self, treeish=None):
Does the repo have any submodules?

@param treeish: look into treeish
@type treeish: C{str}
@return: C{True} if the repository has any submodules, C{False}
    otherwise
@rtype: C{bool}
def add_submodule(self, repo_path):
Add a submodule

@param repo_path: path to submodule
@type repo_path: C{str}
def update_submodules(self, init=True, recursive=True, fetch=False):
Update all submodules

@param init: whether to initialize the submodule if necessary
@type init: C{bool}
@param recursive: whether to update submodules recursively
@type recursive: C{bool}
@param fetch: whether to fetch new objects
@type fetch: C{bool}
def get_submodules(self, treeish, path=None, recursive=True):
List the submodules of treeish

@return: a list of submodule/commit-id tuples
@rtype: list of tuples
@classmethod
def create(cls, path, description=None, bare=False):
Create a repository at path

@param path: where to create the repository
@type path: C{str}
@param bare: whether to create a bare repository
@type bare: C{bool}
@return: git repository object
@rtype: L{GitRepository}
@classmethod
def clone(cls, path, remote, depth=0, recursive=False, mirror=False, bare=False, auto_name=True, reference=None):
Clone a git repository at I{remote} to I{path}.

@param path: where to clone the repository to
@type path: C{str}
@param remote: URL to clone
@type remote: C{str}
@param depth: create a shallow clone of depth I{depth}
@type depth: C{int}
@param recursive: whether to clone submodules
@type recursive: C{bool}
@param mirror: whether to pass --mirror to git-clone
@type mirror: C{bool}
@param bare: whether to create a bare repository
@type bare: C{bool}
@param auto_name: If I{True} create a directory below I{path} based on
    the I{remote}s name. Otherwise create the repo directly at I{path}.
@type auto_name: C{bool}
@param reference: create a clone using local objects from I{reference} repository
@type reference: C{str}
@return: git repository object
@rtype: L{GitRepository}
API Documentation for git-buildpackage, generated by pydoctor at 2019-10-31 18:15:14.