Ggit.Repository

g GObject.GInterface GObject.GInterface Gio.Initable Gio.Initable GObject.GInterface->Gio.Initable GObject.Object GObject.Object Ggit.ObjectFactoryBase Ggit.ObjectFactoryBase GObject.Object->Ggit.ObjectFactoryBase Ggit.Native Ggit.Native Ggit.Repository Ggit.Repository Ggit.Native->Ggit.Repository Ggit.ObjectFactoryBase->Ggit.Native Gio.Initable->Ggit.Repository

Subclasses:

None

Methods

Inherited:

GObject.Object (37), Gio.Initable (2)

Structs:

GObject.ObjectClass (5)

class

clone (url, location, options)

class

discover (location)

class

discover_full (location, across_fs, ceiling_dirs)

class

init_repository (location, is_bare)

class

open (location)

add_remote_fetch (remote, refspec)

add_remote_push (remote, refspec)

blame_file (file, blame_options)

checkout_head (options)

checkout_index (index, options)

checkout_tree (tree, options)

cherry_pick (commit, options)

cherry_pick_commit (commit, our_commit, mainline, merge_options)

create_blob ()

create_blob_from_buffer (buffer)

create_blob_from_file (file)

create_blob_from_path (path)

create_branch (branch_name, target, flags)

create_commit (update_ref, author, committer, message_encoding, message, tree, parents)

create_commit_buffer (author, committer, message_encoding, message, tree, parents)

create_commit_from_ids (update_ref, author, committer, message_encoding, message, tree, parents)

create_commit_with_signature (commit_content, signature, signature_field)

create_index_entry_for_file (file, id)

create_index_entry_for_path (path, id)

create_note (notes_ref, author, committer, id, note, force)

create_reference (name, oid, log_message)

create_remote (name, url)

create_symbolic_reference (name, target, log_message)

create_tag (tag_name, target, tagger, message, flags)

create_tag_annotation (tag_name, target, signature, message)

create_tag_from_buffer (tag, flags)

create_tag_lightweight (tag_name, target, flags)

create_tree_builder ()

create_tree_builder_from_tree (tree)

delete_tag (name)

drop_stash (index)

enumerate_branches (list_type)

file_status (location)

file_status_foreach (options, callback, *user_data)

get_ahead_behind (local, upstream)

get_attribute (path, name, flags)

get_config ()

get_default_notes_ref ()

get_descendant_of (commit, ancestor)

get_head ()

get_index ()

get_location ()

get_submodule_status (name, ignore)

get_workdir ()

is_bare ()

is_empty ()

is_head_detached ()

is_head_unborn ()

list_remotes ()

list_tags ()

list_tags_match (pattern)

lookup (oid, gtype)

lookup_blob (oid)

lookup_branch (branch_name, branch_type)

lookup_commit (oid)

lookup_reference (name)

lookup_reference_dwim (short_name)

lookup_remote (name)

lookup_submodule (name)

lookup_tag (oid)

lookup_tree (oid)

merge (their_heads, merge_opts, checkout_opts)

merge_base (oid_one, oid_two)

merge_commits (our_commit, their_commit, merge_options)

merge_trees (ancestor_tree, our_tree, their_tree, merge_options)

note_foreach (notes_ref, callback, *user_data)

path_is_ignored (path)

read_note (notes_ref, id)

rebase_init (branch, upstream, onto, options)

rebase_open (options)

references_foreach (callback, *user_data)

references_foreach_name (callback, *user_data)

remove_note (notes_ref, author, committer, id)

remove_remote (name)

rename_remote (name, new_name)

reset (target, reset_type, checkout_options)

reset_default (target, pathspecs)

revert (commit, options)

revparse (spec)

save_stash (stasher, message, flags)

set_head (ref_name)

set_head_detached (oid)

set_remote_url (remote, url)

set_submodule_fetch_recurse (name, fetch_recurse_submodules)

set_submodule_ignore (name, ignore)

set_submodule_update (name, update)

set_submodule_url (name, url)

set_workdir (workdir, update_gitlink)

stash_foreach (callback, *user_data)

submodule_foreach (callback, *user_data)

tag_foreach (callback, *user_data)

Virtual Methods

Inherited:

GObject.Object (7), Gio.Initable (1)

Properties

Inherited:

Ggit.Native (1)

Name

Type

Flags

Short Description

clone-options

Ggit.CloneOptions

r/w/co

Clone options

head

Ggit.Ref

r

Head

init

bool

r/w/co

Whether to initialize a repository

is-bare

bool

r/w/co

Is a bare repository

location

Gio.File

r/w/co

The location of the repository

url

str

r/w/co

The URL for cloning a repository

workdir

Gio.File

r/w/c

The path to the repository working directory

Signals

Inherited:

GObject.Object (1)

Fields

Inherited:

GObject.Object (1)

Name

Type

Access

Description

parent

Ggit.Native

r

Class Details

class Ggit.Repository(**kwargs)
Bases:

Ggit.Native, Gio.Initable

Abstract:

No

Structure:

Ggit.RepositoryClass

Represents an existing git repository including all of it’s object contents.

classmethod clone(url, location, options)
Parameters:
Raises:

GLib.Error

Returns:

a newly created Ggit.Repository.

Return type:

Ggit.Repository or None

Clones a new git repository in the given folder.

classmethod discover(location)
Parameters:

location (Gio.File) – the base location where the lookup starts.

Raises:

GLib.Error

Returns:

the repository location.

Return type:

Gio.File or None

Looks for a git repository.

The lookup starts from path and walks up the parent directories and stops when a repository is found.

classmethod discover_full(location, across_fs, ceiling_dirs)
Parameters:
  • location (Gio.File) – the base location where the lookup starts.

  • across_fs (bool) – indictaes whether lookup will work across filesystem devices.

  • ceiling_dirs ([str] or None) – a list of absolute paths at which lookup will stop when reached, or None.

Raises:

GLib.Error

Returns:

the repository location.

Return type:

Gio.File or None

Looks for a git repository.

The lookup starts from path and walks up the parent directories and stops when a repository is found.

classmethod init_repository(location, is_bare)
Parameters:
  • location (Gio.File) – the location of the repository.

  • is_bare (bool) – if True, a git repository without a working directory is created at the pointed path. If False, provided path will be considered as the working directory into which the .git directory will be created.

Raises:

GLib.Error

Returns:

a newly created Ggit.Repository.

Return type:

Ggit.Repository or None

Creates a new git repository in the given folder.

classmethod open(location)
Parameters:

location (Gio.File) – the location of the repository.

Raises:

GLib.Error

Returns:

a newly created Ggit.Repository.

Return type:

Ggit.Repository or None

Open a git repository.

The path must point to an existing git repository folder, e.g.

/path/to/my_repo/.git/ (normal repository) objects/ index HEAD

/path/to/bare_repo/ (bare repository) objects/ index HEAD

The method will automatically detect if path is a normal or bare repository or fail if it is neither.

add_remote_fetch(remote, refspec)
Parameters:
Raises:

GLib.Error

Adds a fetch refspec to the remote's configuration. Adds refspec to the fetch list in the configuration. No loaded remote instances will be affected.

add_remote_push(remote, refspec)
Parameters:
Raises:

GLib.Error

Adds a push refspec to remote's configuration. Adds the given refspec to the push list in the configuration. No loaded remote instances will be affected.

blame_file(file, blame_options)
Parameters:
Raises:

GLib.Error

Returns:

a Ggit.Blame.

Return type:

Ggit.Blame or None

Get a blame for a single file.

checkout_head(options)
Parameters:

options (Ggit.CheckoutOptions or None) – a Ggit.CheckoutOptions or None.

Raises:

GLib.Error

Returns:

True if the checkout was successfull, False otherwise.

Return type:

bool

Update files in the working tree to reflect the contents of current HEAD. If options is None, then the default checkout options will be used.

If the checkout was not successfull, then error will be set.

checkout_index(index, options)
Parameters:
Raises:

GLib.Error

Returns:

True if the checkout was successfull, False otherwise.

Return type:

bool

Update files in the working tree to reflect the contents of the index. If index is None, then the current index of the repository will be used. If options is None, then the default checkout options will be used.

If the checkout was not successfull, then error will be set.

checkout_tree(tree, options)
Parameters:
Raises:

GLib.Error

Returns:

True if the checkout was successfull, False otherwise.

Return type:

bool

Update files in the working tree to reflect the contents of the specified commit, tag or tree object. If tree is None, then the current HEAD of the repository will be used. If options is None, then the default checkout options will be used.

If the checkout was not successfull, then error will be set.

cherry_pick(commit, options)
Parameters:
Raises:

GLib.Error

Returns:

True if the commit was cherry-picked successfully, False otherwise.

Return type:

bool

Cherry pick the specified commit, making changes in the index and the working directory.

cherry_pick_commit(commit, our_commit, mainline, merge_options)
Parameters:
Raises:

GLib.Error

Returns:

a Ggit.Index.

Return type:

Ggit.Index or None

Cherry-picks the given commit against the provided our_commit, producing and index that reflects the result of the cherry-pick.

create_blob()
Returns:

a Ggit.BlobOutputStream.

Return type:

Ggit.BlobOutputStream or None

Create a new blob and return a Gio.OutputStream to write contents to the blob. This is an efficient way to create new blobs without copying data. The blob id can be obtained from the blob output stream using Ggit.BlobOutputStream.get_id, after you close the stream.

create_blob_from_buffer(buffer)
Parameters:

buffer (bytes) – the data.

Raises:

GLib.Error

Returns:

the new #GgitOid of the written blob, or None if writing the blob failed.

Return type:

Ggit.OId or None

Write an in-memory buffer to the object database as a blob.

create_blob_from_file(file)
Parameters:

file (Gio.File) – a Gio.File.

Raises:

GLib.Error

Return type:

Ggit.OId

Write a file to the object database as a blob.

Returns (transfer full) (nullable): the new #GgitOid of the written blob, or None if writing the blob failed.

create_blob_from_path(path)
Parameters:

path (str) – the file path.

Raises:

GLib.Error

Returns:

the new #GgitOid of the written blob, or None if writing the blob failed.

Return type:

Ggit.OId or None

Write a path relative to the repository working directory to the object database as a blob.

create_branch(branch_name, target, flags)
Parameters:
Raises:

GLib.Error

Returns:

the reference to which the branch points, or None in case of an error.

Return type:

Ggit.Branch or None

Creates a new branch pointing at a target commit.

create_commit(update_ref, author, committer, message_encoding, message, tree, parents)
Parameters:
  • update_ref (str or None) – name of the reference to update.

  • author (Ggit.Signature) – author signature.

  • committer (Ggit.Signature) – committer signature (and time of commit).

  • message_encoding (str or None) – message encoding.

  • message (str) – commit message.

  • tree (Ggit.Tree) – the tree of objects to commit.

  • parents ([Ggit.Commit]) – parent commits.

Raises:

GLib.Error

Returns:

the Ggit.OId of the created commit object, or None in case of an error.

Return type:

Ggit.OId or None

Create a new commit. If update_ref is not None, the given reference will be updated to point to the newly created commit. Use “HEAD” to update the HEAD of the current branch and make it point to this commit.

If message_encoding is set to None, “UTF-8” encoding is assumed for the provided message. Note that message will not be cleaned up automatically. You can use Ggit.message_prettify to do this yourself if needed.

create_commit_buffer(author, committer, message_encoding, message, tree, parents)
Parameters:
  • author (Ggit.Signature) – author signature.

  • committer (Ggit.Signature) – committer signature (and time of commit).

  • message_encoding (str or None) – message encoding.

  • message (str) – commit message.

  • tree (Ggit.Tree) – the tree of objects to commit.

  • parents ([Ggit.Commit]) – parent commits.

Raises:

GLib.Error

Returns:

the commit object content or None in case of an error.

Return type:

str or None

Create a commit as with git_commit_create() but instead of writing it to the objectdb, write the contents of the object into a buffer.

create_commit_from_ids(update_ref, author, committer, message_encoding, message, tree, parents)
Parameters:
  • update_ref (str or None) – name of the reference to update.

  • author (Ggit.Signature) – author signature.

  • committer (Ggit.Signature) – committer signature (and time of commit).

  • message_encoding (str or None) – message encoding.

  • message (str) – commit message.

  • tree (Ggit.OId) – the tree of objects to commit.

  • parents ([Ggit.OId]) – parent commits.

Raises:

GLib.Error

Returns:

the Ggit.OId of the created commit object, or None in case of an error.

Return type:

Ggit.OId or None

Create a new commit. If update_ref is not None, the given reference will be updated to point to the newly created commit. Use “HEAD” to update the HEAD of the current branch and make it point to this commit.

If message_encoding is set to None, “UTF-8” encoding is assumed for the provided message. Note that message will not be cleaned up automatically. You can use Ggit.message_prettify to do this yourself if needed.

create_commit_with_signature(commit_content, signature, signature_field)
Parameters:
  • commit_content (str) – the content of the unsigned commit.

  • signature (str or None) – the signature to add to the commit.

  • signature_field (str or None) – which header field should contain this signature. Leave NULL for the default of “gpgsig”.

Raises:

GLib.Error

Returns:

the Ggit.OId of the created commit object, or None in case of an error.

Return type:

Ggit.OId or None

Given the unsigned commit object’s contents, its signature and the header field in which to store the signature, attach the signature to the commit and write it into the given repositoryCreate a new commit using the (if not None) signature key and type of key provided.

create_index_entry_for_file(file, id)
Parameters:
Raises:

GLib.Error

Returns:

a Ggit.IndexEntry or None when an error occurred.

Return type:

Ggit.IndexEntry or None

Create a new index entry. When file is not None, the path of the returned entry (Ggit.IndexEntry.get_path) is set to the path of file relative to the working directory of self. The file must reside in the working directory of self. The file related fields of the returned entry are also queried from this file (if the file exists).

If id is not None, then the id of the returned entry is set to id (see Ggit.IndexEntry.get_id) which could point to a blob (for a file) or a tree (for a directory).

create_index_entry_for_path(path, id)
Parameters:
Raises:

GLib.Error

Returns:

a Ggit.IndexEntry or None when an error occurred.

Return type:

Ggit.IndexEntry or None

Create a new index entry. When path is not None, the path of the returned entry (Ggit.IndexEntry.get_path) is set to path. The specified path can be either absolute or relative. In the case of an absolute path, the path must reside within the working directory of self. The file related fields of the returned entry are also queried from this path (if the file exists).

If id is not None, then the id of the returned entry is set to id (see Ggit.IndexEntry.get_id) which could point to a blob (for a file) or a tree (for a directory).

create_note(notes_ref, author, committer, id, note, force)
Parameters:
  • notes_ref (str or None) – canonical name of the reference to use, or None to use the default ref.

  • author (Ggit.Signature) – author signature.

  • committer (Ggit.Signature) – committer signature.

  • id (Ggit.OId) – OID of the git object to decorate.

  • note (str) – content of the note to add for object oid.

  • force (bool) – whether to overwrite existing note.

Raises:

GLib.Error

Returns:

the OID for the note or None in case of error.

Return type:

Ggit.OId or None

Adds a note for an object.

create_reference(name, oid, log_message)
Parameters:
  • name (str) – the name for the new Ggit.Ref.

  • oid (Ggit.OId) – the Ggit.OId pointed to by the reference.

  • log_message (str) – The one line long message to be appended to the reflog.

Raises:

GLib.Error

Returns:

the newly created reference.

Return type:

Ggit.Ref or None

Creates a new object id reference.

The reference will be created in the repository and written to the disk. The returned value must be freed with GObject.Object.unref().

create_remote(name, url)
Parameters:
  • name (str) – the name of the new remote.

  • url (str) – the url of the remote.

Raises:

GLib.Error

Returns:

a new Ggit.Remote or None if there is an error.

Return type:

Ggit.Remote or None

Adds a remote with the default fetch refspec to the repository’s configuration.

create_symbolic_reference(name, target, log_message)
Parameters:
  • name (str) – the name for the new Ggit.Ref.

  • target (str) – the full name to the reference.

  • log_message (str) – The one line long message to be appended to the reflog.

Raises:

GLib.Error

Returns:

the newly created reference.

Return type:

Ggit.Ref or None

Creates a new symbolic reference.

The reference will be created in the repository and written to the disk. The returned value must be freed with GObject.Object.unref().

create_tag(tag_name, target, tagger, message, flags)
Parameters:
Raises:

GLib.Error

Returns:

the id to which the tag points, or None in case of an error.

Return type:

Ggit.OId or None

Create a new tag object.

create_tag_annotation(tag_name, target, signature, message)
Parameters:
Raises:

GLib.Error

Returns:

the id to which the tag points, or None in case of an error.

Return type:

Ggit.OId or None

Creates a new annotated tag.

create_tag_from_buffer(tag, flags)
Parameters:
Raises:

GLib.Error

Returns:

the id to which the tag points, or None in case of an error.

Return type:

Ggit.OId or None

Create a new tag from a buffer describing the tag object. The buffer must be correctly formatted.

create_tag_lightweight(tag_name, target, flags)
Parameters:
Raises:

GLib.Error

Returns:

the id to which the tag points, or None in case of an error.

Return type:

Ggit.OId or None

Creates a new lightweight tag.

create_tree_builder()
Raises:

GLib.Error

Returns:

a new Ggit.TreeBuilder, or None if there was an error.

Return type:

Ggit.TreeBuilder or None

Create a new tree builder.

create_tree_builder_from_tree(tree)
Parameters:

tree (Ggit.Tree) – a Ggit.Tree.

Raises:

GLib.Error

Returns:

a new Ggit.TreeBuilder object, or None if there was an error.

Return type:

Ggit.TreeBuilder or None

Create a tree builder for initialized with tree. To create an empty tree builder, use Ggit.Repository.create_tree_builder instead.

delete_tag(name)
Parameters:

name (str) – the name of the tag.

Raises:

GLib.Error

Returns:

True if the tag was deleted successfully, False otherwise.

Return type:

bool

Delete an existing tag reference by name.

drop_stash(index)
Parameters:

index (int) – the position within the stash list. 0 points to the. most recent stashed state.

Raises:

GLib.Error

Removes a single stashed state from the stash list.

enumerate_branches(list_type)
Parameters:

list_type (Ggit.BranchType) – a Ggit.BranchType.

Raises:

GLib.Error

Returns:

a branch enumerator.

Return type:

Ggit.BranchEnumerator or None

Get a branch enumerator to enumerate over all branches of the specified list_type in self.

file_status(location)
Parameters:

location (Gio.File) – the file to retrieve status for, rooted at the repository working dir.

Raises:

GLib.Error

Returns:

the status for a single file.

Return type:

Ggit.StatusFlags

Gets the file status for a single file.

file_status_foreach(options, callback, *user_data)
Parameters:
Raises:

GLib.Error

Returns:

True if there was no error, False otherwise

Return type:

bool

Gathers file statuses and run a callback for each one.

To the callback is passed the path of the file, the status and the data pointer passed to this function. If the callback returns something other than 0, the iteration will stop and error will be set.

Set options to None to get the default status options.

get_ahead_behind(local, upstream)
Parameters:
  • local (Ggit.OId) – the commit for local.

  • upstream (Ggit.OId) – the commit for upstream.

Raises:

GLib.Error

Returns:

ahead:

number of unique from commits in upstream.

behind:

number of unique from commits in local.

Return type:

(ahead: int, behind: int)

Count the number of unique commits between two commit objects.

There is no need for branches containing the commits to have any upstream relationship, but it helps to think of one as a branch and the other as its upstream, the ahead and behind values will be what git would report for the branches.

get_attribute(path, name, flags)
Parameters:
Raises:

GLib.Error

Returns:

the attribute value, or None.

Return type:

str or None

Get the attribute value of the specified attribute for the given file.

get_config()
Raises:

GLib.Error

Returns:

a Ggit.Config.

Return type:

Ggit.Config or None

Get the config for a specific repository.

get_default_notes_ref()
Raises:

GLib.Error

Returns:

the default notes reference for self.

Return type:

str or None

Gets the default notes reference for self. It defaults to “refs/notes/commits”.

get_descendant_of(commit, ancestor)
Parameters:
Raises:

GLib.Error

Returns:

True if commit is a descendant of ancestor, or False otherwise.

Return type:

bool

Check whether com mit is a descendant of ancestor. Note that if this function returns False, an error might have occurred. If so, error will be set appropriately.

get_head()
Raises:

GLib.Error

Returns:

a Ggit.Ref

Return type:

Ggit.Ref or None

Get and resolves the current HEAD reference of the repository. Note that the returned ref is already resolved (if HEAD is symbolic). If you want to retrieve the symbolic ref called HEAD, then use Ggit.Repository.lookup_reference instead.

get_index()
Raises:

GLib.Error

Returns:

a Ggit.Index.

Return type:

Ggit.Index or None

Get the index for a specific repository.

get_location()
Returns:

the location of the gitdir of the repository.

Return type:

Gio.File or None

Get the gitdir location of the repository.

get_submodule_status(name, ignore)
Parameters:
Raises:

GLib.Error

Returns:

the Ggit.SubmoduleStatus for submodule.

Return type:

Ggit.SubmoduleStatus

Gets the status for a submodule. This looks at a submodule and tries to determine the status. It will return a combination of the %GGIT_SUBMODULE_STATUS values. How deeply it examines the working directory to do this will depend on ignore.

get_workdir()
Returns:

the location of the working directory of the repository.

Return type:

Gio.File or None

Gets the working directory of the repository.

is_bare()
Returns:

True if the repository is empty.

Return type:

bool

Checks if self is bare.

is_empty()
Raises:

GLib.Error

Returns:

True if the repository is empty.

Return type:

bool

Checks if self is empty.

An empty repository has just been initialized and contains no commits.

is_head_detached()
Raises:

GLib.Error

Returns:

True if HEAD is detached.

Return type:

bool

Checks if self's HEAD is detached.

A repository’s HEAD is detached when it points directly to a commit instead of a branch.

is_head_unborn()
Raises:

GLib.Error

Returns:

True if the current branch is an orphan.

Return type:

bool

Checks if self's HEAD is an orphan.

An orphan branch is one named from HEAD but doesn’t exist in the refs namespace, because it doesn’t have any commit to point to.

list_remotes()
Raises:

GLib.Error

Returns:

a list with the remotes.

Return type:

[str] or None

Fill a list with all the remotes in self.

list_tags()
Raises:

GLib.Error

Returns:

a list with the tags in self.

Return type:

[str] or None

Fill a list with all the tags in the self.

list_tags_match(pattern)
Parameters:

pattern (str or None) – a pattern to match.

Raises:

GLib.Error

Returns:

a list with matching tags in self.

Return type:

[str] or None

Fill a list with all the tags in the self matching the provided pattern. The pattern can use standard fnmatch syntax.

lookup(oid, gtype)
Parameters:
Raises:

GLib.Error

Returns:

the found Ggit.Object, or None on error.

Return type:

Ggit.Object or None

Lookups a reference to one of the objects in the self.

The generated reference must be freed with GObject.Object.unref().

The gtype must match the type of the object in the odb; the method will fail otherwise. The special value GObject.TYPE_NONE may be passed to let the method guess the object’s type.

lookup_blob(oid)
Parameters:

oid (Ggit.OId) – a Ggit.OId.

Raises:

GLib.Error

Returns:

a #GgitBlog pointer.

Return type:

Ggit.Blob or None

Lookups a branch by its name in a repository.

lookup_branch(branch_name, branch_type)
Parameters:
Raises:

GLib.Error

Returns:

a branch by its name in a repository.

Return type:

Ggit.Branch or None

Lookups a branch by its name in a repository.

lookup_commit(oid)
Parameters:

oid (Ggit.OId) – a Ggit.OId.

Raises:

GLib.Error

Returns:

a Ggit.Commit pointer.

Return type:

Ggit.Commit or None

Lookups a branch by its name in a repository.

lookup_reference(name)
Parameters:

name (str) – the long name for the reference (e.g. HEAD, ref/heads/master, refs/tags/v0.1.0, …).

Raises:

GLib.Error

Returns:

the searched reference.

Return type:

Ggit.Ref or None

Lookups a reference by its name in self. The returned Ggit.Ref must be freed with GObject.Object.unref().

lookup_reference_dwim(short_name)
Parameters:

short_name (str) – the short name for the reference (e.g. master, v0.1.0, …).

Raises:

GLib.Error

Returns:

the searched reference.

Return type:

Ggit.Ref or None

Lookups a reference by its short name in self applying the git precendence rules to the given shorthand to determine which reference the user is referring to. The returned Ggit.Ref must be freed with GObject.Object.unref().

lookup_remote(name)
Parameters:

name (str) – the remote’s name.

Raises:

GLib.Error

Returns:

a new Ggit.Remote or None if there is an error.

Return type:

Ggit.Remote or None

Gets the remote called name.

lookup_submodule(name)
Parameters:

name (str) – the name of the submodule.

Raises:

GLib.Error

Returns:

a newly-allocated Ggit.Submodule.

Return type:

Ggit.Submodule or None

Lookups a submodule information by name or path. If the submodule does not exist, None is returned and a Ggit.Error.NOTFOUND error set.

lookup_tag(oid)
Parameters:

oid (Ggit.OId) – a Ggit.OId.

Raises:

GLib.Error

Returns:

a Ggit.Tag pointer.

Return type:

Ggit.Tag or None

Lookups a branch by its name in a repository.

lookup_tree(oid)
Parameters:

oid (Ggit.OId) – a Ggit.OId.

Raises:

GLib.Error

Returns:

a Ggit.Tree pointer.

Return type:

Ggit.Tree or None

Lookups a branch by its name in a repository.

merge(their_heads, merge_opts, checkout_opts)
Parameters:
Raises:

GLib.Error

Merges the given commit(s) into HEAD, writing the results into the working directory. Any changes are staged for commit and any conflicts are written to the index.

Callers should inspect the repository’s index after this completes, resolve any conflicts and prepare a commit.

merge_base(oid_one, oid_two)
Parameters:
  • oid_one (Ggit.OId) – the oid of one of the commits.

  • oid_two (Ggit.OId) – the oid of the second of the commits

Raises:

GLib.Error

Returns:

a new Ggit.OId or None if an error occurred.

Return type:

Ggit.OId or None

Find the merge base between two commits

merge_commits(our_commit, their_commit, merge_options)
Parameters:
  • our_commit (Ggit.Commit) – the commit that reflects the destination tree.

  • their_commit (Ggit.Commit) – the commit that reflects the source tree.

  • merge_options (Ggit.MergeOptions) – the merge options.

Raises:

GLib.Error

Returns:

a new Ggit.Index or None if an error occurred.

Return type:

Ggit.Index or None

Merge two commits creating a Ggit.Index reflecting the result of the merge.

merge_trees(ancestor_tree, our_tree, their_tree, merge_options)
Parameters:
  • ancestor_tree (Ggit.Tree) – the common ancestor between the trees, or None.

  • our_tree (Ggit.Tree) – the tree that reflects the destination tree.

  • their_tree (Ggit.Tree) – the tree that reflects the source tree.

  • merge_options (Ggit.MergeOptions) – the merge options.

Raises:

GLib.Error

Returns:

a new Ggit.Index or None if an error occurred.

Return type:

Ggit.Index or None

Merge two trees creating a Ggit.Index reflecting the result of the merge.

note_foreach(notes_ref, callback, *user_data)
Parameters:
Raises:

GLib.Error

Returns:

True if there was no error, False otherwise.

Return type:

bool

Loop over all the notes within a specified namespace and issue a callback for each one. If callback returns a non-zero value, this will stop looping.

path_is_ignored(path)
Parameters:

path (str) – A path within the repository.

Raises:

GLib.Error

Returns:

True if path should be ignored.

Return type:

bool

Tests if the ignore rules apply to the path provided.

This acts similar to filtering performed when calling “git add .” on the command line.

read_note(notes_ref, id)
Parameters:
  • notes_ref (str or None) – canonical name of the reference to use, or None to use the default ref.

  • id (Ggit.OId) – OID of the git object to decorate.

Raises:

GLib.Error

Returns:

the read note or None in case of an error.

Return type:

Ggit.Note or None

Reads the note for an object.

rebase_init(branch, upstream, onto, options)
Parameters:
Raises:

GLib.Error

Returns:

a newly allocated Ggit.Rebase.

Return type:

Ggit.Rebase or None

Initializes a rebase operation to rebase the changes in branch relative to upstream onto another branch. To begin the rebase process, call git_rebase_next(). When you have finished with this object, call GObject.Object.unref().

rebase_open(options)
Parameters:

options (Ggit.RebaseOptions) – a Ggit.RebaseOptions to specify how rebase is performed, or None.

Raises:

GLib.Error

Returns:

a newly allocated Ggit.Rebase.

Return type:

Ggit.Rebase or None

Opens an existing rebase that was previously started by either an invocation of ggit_rebase_init() or by another client.

references_foreach(callback, *user_data)
Parameters:
Raises:

GLib.Error

Returns:

True if there was no error, False otherwise

Return type:

bool

Gathers references and run a callback for each one.

To the callback is passed the reference and the data pointer passed to this function. If the callback returns something other than 0, the iteration will stop and error will be set.

references_foreach_name(callback, *user_data)
Parameters:
Raises:

GLib.Error

Returns:

True if there was no error, False otherwise

Return type:

bool

Gathers reference names and run a callback for each one.

To the callback is passed the name of the reference and the data pointer passed to this function. If the callback returns something other than 0, the iteration will stop and error will be set.

remove_note(notes_ref, author, committer, id)
Parameters:
  • notes_ref (str or None) – canonical name of the reference to use, or None to use the default ref.

  • author (Ggit.Signature) – author signature.

  • committer (Ggit.Signature) – committer signature.

  • id (Ggit.OId) – OID of the git object to decorate.

Raises:

GLib.Error

Returns:

True if the note was removed from id.

Return type:

bool

Removes the note for an object.

remove_remote(name)
Parameters:

name (str) – the remote’s name.

Raises:

GLib.Error

Returns:

True if there was no error, False otherwise

Return type:

bool

Removes remote from the self.

rename_remote(name, new_name)
Parameters:
  • name (str) – the remote name to be renamed.

  • new_name (str) – new name of the remote.

Raises:

GLib.Error

Returns:

non-default refspecs that cannot be renamed.

Return type:

[str] or None

Rename the remote of self from name to new_name.

reset(target, reset_type, checkout_options)
Parameters:
Raises:

GLib.Error

Performs a reset of type reset_type on self to target, or error will be set.

reset_default(target, pathspecs)
Parameters:
Raises:

GLib.Error

Update some entries in the index from the target commit tree. The scope of the updated entries is determined by the paths specified in pathspecs. Passing None in target will result in removing entries in the index matching the provided pathspecs.

revert(commit, options)
Parameters:
Raises:

GLib.Error

Returns:

True if the revert was successfull, False otherwise.

Return type:

bool

Revert the given commit on top of the current working directory.

revparse(spec)
Parameters:

spec (str) – the revision specification.

Raises:

GLib.Error

Returns:

a Ggit.Object or None if the revision could not be found.

Return type:

Ggit.Object or None

Find an object, as specified by a revision string. See man gitrevisions, or the documentation for git rev-parse for information on the syntax accepted.

save_stash(stasher, message, flags)
Parameters:
Raises:

GLib.Error

Returns:

a new object id of the commit containing the stashed state.

Return type:

Ggit.OId or None

Saves the local modifications to a new stash. It returns the commit containing the stashed state. This commit is also the target of the direct reference refs/stash.

set_head(ref_name)
Parameters:

ref_name (str) – canonical name of the reference HEAD should point to.

Raises:

GLib.Error

Returns:

True if head was successfully set, False otherwise.

Return type:

bool

set_head_detached(oid)
Parameters:

oid (Ggit.OId) – canonical Object id of the Commit the HEAD should point to.

Raises:

GLib.Error

Returns:

True if head was successfully set, False otherwise.

Return type:

bool

set_remote_url(remote, url)
Parameters:
  • remote (str) – the remote name who’s url is to be set.

  • url (str) – url of the remote.

Raises:

GLib.Error

Returns:

True if there was no error, False otherwise

Return type:

bool

Sets url for the remote from the self.

set_submodule_fetch_recurse(name, fetch_recurse_submodules)
Parameters:
Raises:

GLib.Error

Sets the submodule.’name’.fetchRecurseSubmodules value for the submodule. This setting won’t affect any existing instances..

set_submodule_ignore(name, ignore)
Parameters:
Raises:

GLib.Error

Sets the ignore rule for the submodule in the configuration. This does not affect any currently-loaded instances..

set_submodule_update(name, update)
Parameters:
Raises:

GLib.Error

Sets the update rule for the submodule in the configuration. This setting won’t affect any existing instances.

set_submodule_url(name, url)
Parameters:
  • name (str) – the name of the submodule to configure.

  • url (str) – URL that should be used for the submodule.

Raises:

GLib.Error

Sets the URL for the submodule in the configuration.

After calling this, you may wish to call Ggit.Submodule.sync() to write the changes to the checked out submodule repository.

set_workdir(workdir, update_gitlink)
Parameters:
  • workdir (Gio.File) – the working directory.

  • update_gitlink (bool) – create/update gitlink in workdir.

Sets the working directory of the repository. If update_gitlink is set to True “core.worktree” will be set in the config if workdir is not the parent of the .git directory).

stash_foreach(callback, *user_data)
Parameters:
Raises:

GLib.Error

Returns:

True if there was no error, False otherwise.

Return type:

bool

Loops over all the stashed states and issue a callback for each one. If callback returns a non-zero value, this will stop looping.

submodule_foreach(callback, *user_data)
Parameters:
Raises:

GLib.Error

Returns:

True if there was no error, False otherwise

Return type:

bool

Gathers submodules and run a callback for each one.

To the callback is passed the submodule instance and name. If the callback returns something other than 0, the iteration will stop and error will be set.

NOTE: the submodule instance passed to the callback is only valid during the call to Ggit.Repository.submodule_foreach and may not be used after the call has finished.

tag_foreach(callback, *user_data)
Parameters:
Raises:

GLib.Error

Returns:

True if there was no error, False otherwise

Return type:

bool

Get all the tags in the repository and run the provided callback on each. If the callback returns something other than 0, the iteration will stop and error will be set.

Property Details

Ggit.Repository.props.clone_options
Name:

clone-options

Type:

Ggit.CloneOptions

Default Value:

None

Flags:

READABLE, WRITABLE, CONSTRUCT_ONLY

Clone options

Ggit.Repository.props.head
Name:

head

Type:

Ggit.Ref

Default Value:

None

Flags:

READABLE

Head

Ggit.Repository.props.init
Name:

init

Type:

bool

Default Value:

False

Flags:

READABLE, WRITABLE, CONSTRUCT_ONLY

Whether to initialize a repository

Ggit.Repository.props.is_bare
Name:

is-bare

Type:

bool

Default Value:

False

Flags:

READABLE, WRITABLE, CONSTRUCT_ONLY

Is a bare repository

Ggit.Repository.props.location
Name:

location

Type:

Gio.File

Default Value:

None

Flags:

READABLE, WRITABLE, CONSTRUCT_ONLY

The location of the repository

Ggit.Repository.props.url
Name:

url

Type:

str

Default Value:

None

Flags:

READABLE, WRITABLE, CONSTRUCT_ONLY

The URL for cloning a repository

Ggit.Repository.props.workdir
Name:

workdir

Type:

Gio.File

Default Value:

None

Flags:

READABLE, WRITABLE, CONSTRUCT

The path to the repository working directory