Top |
Functions
Properties
GgitCloneOptions * | clone-options | Read / Write / Construct Only |
GgitRef * | head | Read |
gboolean | init | Read / Write / Construct Only |
gboolean | is-bare | Read / Write / Construct Only |
GFile * | location | Read / Write / Construct Only |
gchar * | url | Read / Write / Construct Only |
GFile * | workdir | Read / Write / Construct |
Types and Values
GgitRepository | |
struct | GgitRepositoryClass |
enum | GgitCreateFlags |
enum | GgitResetType |
enum | GgitStashFlags |
enum | GgitStatusFlags |
Functions
GgitReferencesNameCallback ()
gint (*GgitReferencesNameCallback) (const gchar *name
,gpointer user_data
);
The type of the callback functions for retrieving the references
in a GgitRepository. See ggit_repository_references_foreach_name()
.
GgitStashCallback ()
gint (*GgitStashCallback) (gsize index
,const gchar *message
,GgitOId *stash_oid
,gpointer user_data
);
When iterating over all the stashed states, callback that will be
issued per entry. See ggit_repository_stash_foreach()
.
GgitStatusCallback ()
gint (*GgitStatusCallback) (const gchar *path
,GgitStatusFlags status_flags
,gpointer user_data
);
The type of the callback functions for retrieving the status of the files
in a GgitRepository. See ggit_repository_file_status_foreach()
.
ggit_repository_open ()
GgitRepository * ggit_repository_open (GFile *location
,GError **error
);
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.
ggit_repository_init_repository ()
GgitRepository * ggit_repository_init_repository (GFile *location
,gboolean is_bare
,GError **error
);
Creates a new git repository in the given folder.
Parameters
location |
the location of the repository. |
|
is_bare |
if |
|
error |
a GError for error reporting, or |
ggit_repository_clone ()
GgitRepository * ggit_repository_clone (const gchar *url
,GFile *location
,GgitCloneOptions *options
,GError **error
);
Clones a new git repository in the given folder.
ggit_repository_lookup ()
GgitObject * ggit_repository_lookup (GgitRepository *repository
,GgitOId *oid
,GType gtype
,GError **error
);
Lookups a reference to one of the objects in the repository
.
The generated reference must be freed with g_object_unref()
.
The gtype
must match the type of the object
in the odb; the method will fail otherwise.
The special value G_TYPE_NONE
may be passed to let
the method guess the object's type.
ggit_repository_lookup_reference ()
GgitRef * ggit_repository_lookup_reference (GgitRepository *repository
,const gchar *name
,GError **error
);
Lookups a reference by its name in repository
. The returned GgitRef must
be freed with g_object_unref()
.
ggit_repository_create_reference ()
GgitRef * ggit_repository_create_reference (GgitRepository *repository
,const gchar *name
,GgitOId *oid
,const gchar *log_message
,GError **error
);
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 g_object_unref()
.
ggit_repository_create_symbolic_reference ()
GgitRef * ggit_repository_create_symbolic_reference (GgitRepository *repository
,const gchar *name
,const gchar *target
,const gchar *log_message
,GError **error
);
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 g_object_unref()
.
Parameters
repository |
||
name |
the name for the new GgitRef. |
|
target |
the full name to the reference. |
|
log_message |
The one line long message to be appended to the reflog. |
|
error |
a GError for error reporting, or |
ggit_repository_create_blob ()
GgitBlobOutputStream *
ggit_repository_create_blob (GgitRepository *repository
);
Create a new blob and return a GOutputStream 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_blob_output_stream_get_id, after you close the stream.
ggit_repository_create_blob_from_buffer ()
GgitOId * ggit_repository_create_blob_from_buffer (GgitRepository *repository
,gconstpointer buffer
,gsize size
,GError **error
);
Write an in-memory buffer to the object database as a blob.
ggit_repository_create_blob_from_file ()
GgitOId * ggit_repository_create_blob_from_file (GgitRepository *repository
,GFile *file
,GError **error
);
Write a file to the object database as a blob.
ggit_repository_create_blob_from_path ()
GgitOId * ggit_repository_create_blob_from_path (GgitRepository *repository
,const gchar *path
,GError **error
);
Write a path relative to the repository working directory to the object database as a blob.
ggit_repository_create_commit ()
GgitOId * ggit_repository_create_commit (GgitRepository *repository
,const gchar *update_ref
,GgitSignature *author
,GgitSignature *committer
,const gchar *message_encoding
,const gchar *message
,GgitTree *tree
,GgitCommit **parents
,gint parent_count
,GError **error
);
Create a new commit. If update_ref
is not NULL
, 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 NULL
, "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.
Parameters
repository |
||
update_ref |
name of the reference to update. |
[allow-none] |
author |
author signature. |
|
committer |
committer signature (and time of commit). |
|
message_encoding |
message encoding. |
[allow-none] |
message |
commit message. |
|
tree |
the tree of objects to commit. |
|
parents |
parent commits. |
[array length=parent_count] |
parent_count |
number of parent commits in |
|
error |
a GError for error reporting, or |
ggit_repository_create_tag ()
GgitOId * ggit_repository_create_tag (GgitRepository *repository
,const gchar *tag_name
,GgitObject *target
,GgitSignature *tagger
,const gchar *message
,GgitCreateFlags flags
,GError **error
);
Create a new tag object.
Parameters
repository |
||
tag_name |
the tag name. |
|
target |
a GgitObject. |
|
tagger |
||
message |
the tag message. |
|
flags |
||
error |
a GError for error reporting, or |
ggit_repository_create_tag_from_buffer ()
GgitOId * ggit_repository_create_tag_from_buffer (GgitRepository *repository
,const gchar *tag
,GgitCreateFlags flags
,GError **error
);
Create a new tag from a buffer describing the tag object. The buffer must be correctly formatted.
ggit_repository_create_tag_lightweight ()
GgitOId * ggit_repository_create_tag_lightweight (GgitRepository *repository
,const gchar *tag_name
,GgitObject *target
,GgitCreateFlags flags
,GError **error
);
Creates a new lightweight tag.
Parameters
repository |
||
tag_name |
the name of the tag. |
|
target |
a GgitObject. |
|
flags |
||
error |
a GError for error reporting, or |
ggit_repository_create_tree_builder ()
GgitTreeBuilder * ggit_repository_create_tree_builder (GgitRepository *repository
,GError **error
);
Create a new tree builder.
ggit_repository_create_tree_builder_from_tree ()
GgitTreeBuilder * ggit_repository_create_tree_builder_from_tree (GgitRepository *repository
,GgitTree *tree
,GError **error
);
Create a tree builder for initialized with tree
. To create an empty
tree builder, use ggit_repository_create_tree_builder instead.
ggit_repository_create_index_entry_for_file ()
GgitIndexEntry * ggit_repository_create_index_entry_for_file (GgitRepository *repository
,GFile *file
,GgitOId *id
,GError **error
);
Create a new index entry. When file
is not NULL
, the path of the returned
entry (ggit_index_entry_get_path) is set to the path of file
relative to
the working directory of repository
. The file must reside in the working
directory of repository
. The file related
fields of the returned entry are also queried from this file (if the file exists).
If id
is not NULL
, then the id of the returned entry is set to id
(see ggit_index_entry_get_id) which could point to a blob (for a file)
or a tree (for a directory).
Parameters
repository |
||
file |
a GFile. |
[allow-none] |
id |
a GgitOId. |
[allow-none] |
error |
a GError for error reporting, or |
ggit_repository_create_index_entry_for_path ()
GgitIndexEntry * ggit_repository_create_index_entry_for_path (GgitRepository *repository
,const gchar *path
,GgitOId *id
,GError **error
);
Create a new index entry. When path
is not NULL
, the path of the returned
entry (ggit_index_entry_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
repository
. The file related fields of the returned entry are also queried
from this path (if the file exists).
If id
is not NULL
, then the id of the returned entry is set to id
(see ggit_index_entry_get_id) which could point to a blob (for a file)
or a tree (for a directory).
Parameters
repository |
||
path |
a path. |
[allow-none] |
id |
a GgitOId. |
[allow-none] |
error |
a GError for error reporting, or |
ggit_repository_list_tags ()
gchar ** ggit_repository_list_tags (GgitRepository *repository
,GError **error
);
Fill a list with all the tags in the repository
.
ggit_repository_create_branch ()
GgitBranch * ggit_repository_create_branch (GgitRepository *repository
,const gchar *branch_name
,GgitObject *target
,GgitCreateFlags flags
,GError **error
);
Creates a new branch pointing at a target commit.
Parameters
repository |
||
branch_name |
the name of the branch. |
|
target |
a GgitObject. |
|
flags |
||
error |
a GError for error reporting, or |
ggit_repository_enumerate_branches ()
GgitBranchEnumerator * ggit_repository_enumerate_branches (GgitRepository *repository
,GgitBranchType list_type
,GError **error
);
Get a branch enumerator to enumerate over all branches of the specified
list_type
in repository
.
ggit_repository_lookup_branch ()
GgitBranch * ggit_repository_lookup_branch (GgitRepository *repository
,const gchar *branch_name
,GgitBranchType branch_type
,GError **error
);
Lookups a branch by its name in a repository.
ggit_repository_create_remote ()
GgitRemote * ggit_repository_create_remote (GgitRepository *repository
,const gchar *name
,const gchar *url
,GError **error
);
Adds a remote with the default fetch refspec to the repository's configuration.
ggit_repository_list_remotes ()
gchar ** ggit_repository_list_remotes (GgitRepository *repository
,GError **error
);
Fill a list with all the remotes in repository
.
ggit_repository_get_head ()
GgitRef * ggit_repository_get_head (GgitRepository *repository
,GError **error
);
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.
ggit_repository_discover ()
GFile * ggit_repository_discover (GFile *location
,GError **error
);
Looks for a git repository.
The lookup starts from path
and walks up the parent directories
and stops when a repository is found.
ggit_repository_is_head_detached ()
gboolean ggit_repository_is_head_detached (GgitRepository *repository
,GError **error
);
Checks if repository
's HEAD is detached.
A repository's HEAD is detached when it points directly to a commit instead of a branch.
ggit_repository_is_head_unborn ()
gboolean ggit_repository_is_head_unborn (GgitRepository *repository
,GError **error
);
Checks if repository
'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.
ggit_repository_is_empty ()
gboolean ggit_repository_is_empty (GgitRepository *repository
,GError **error
);
Checks if repository
is empty.
An empty repository has just been initialized and contains no commits.
ggit_repository_get_location ()
GFile *
ggit_repository_get_location (GgitRepository *repository
);
Get the gitdir location of the repository.
ggit_repository_get_workdir ()
GFile *
ggit_repository_get_workdir (GgitRepository *repository
);
Gets the working directory of the repository.
ggit_repository_set_workdir ()
void ggit_repository_set_workdir (GgitRepository *repository
,GFile *workdir
,gboolean update_gitlink
);
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).
ggit_repository_is_bare ()
gboolean
ggit_repository_is_bare (GgitRepository *repository
);
Checks if repository
is bare.
ggit_repository_file_status ()
GgitStatusFlags ggit_repository_file_status (GgitRepository *repository
,GFile *location
,GError **error
);
Gets the file status for a single file.
ggit_repository_file_status_foreach ()
gboolean ggit_repository_file_status_foreach (GgitRepository *repository
,GgitStatusOptions *options
,GgitStatusCallback callback
,gpointer user_data
,GError **error
);
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 NULL
to get the default status options.
ggit_repository_references_foreach_name ()
gboolean ggit_repository_references_foreach_name (GgitRepository *repository
,GgitReferencesNameCallback callback
,gpointer user_data
,GError **error
);
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.
ggit_repository_get_config ()
GgitConfig * ggit_repository_get_config (GgitRepository *repository
,GError **error
);
Get the config for a specific repository.
ggit_repository_get_index ()
GgitIndex * ggit_repository_get_index (GgitRepository *repository
,GError **error
);
Get the index for a specific repository.
ggit_repository_lookup_submodule ()
GgitSubmodule * ggit_repository_lookup_submodule (GgitRepository *repository
,const gchar *name
,GError **error
);
Lookups a submodule information by name or path. If the submodule
does not exist, NULL
is returned and a GGIT_ERROR_NOTFOUND error set.
ggit_repository_submodule_foreach ()
gboolean ggit_repository_submodule_foreach (GgitRepository *repository
,GgitSubmoduleCallback callback
,gpointer user_data
,GError **error
);
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.
ggit_repository_reset ()
void ggit_repository_reset (GgitRepository *repository
,GgitObject *target
,GgitResetType reset_type
,GgitCheckoutOptions *checkout_options
,GError **error
);
Performs a reset of type reset_type
on repository
to target
,
or error
will be set.
Parameters
repository |
||
target |
the target GgitObject which is a commit or a tag. |
|
reset_type |
the GgitResetType to perform. |
|
checkout_options |
the GgitCheckoutOptions to be used for a HARD reset. |
|
error |
a GError for error reporting, or |
ggit_repository_revparse ()
GgitObject * ggit_repository_revparse (GgitRepository *repository
,const gchar *spec
,GError **error
);
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.
ggit_repository_save_stash ()
GgitOId * ggit_repository_save_stash (GgitRepository *repository
,GgitSignature *stasher
,const gchar *message
,GgitStashFlags flags
,GError **error
);
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.
Parameters
repository |
||
stasher |
||
message |
description along with the stashed state or |
|
flags |
a GgitStashFlags to control the stashing process. |
|
error |
a GError for error reporting, GGIT_ENOTFOUND if there's nothing to stash or |
ggit_repository_drop_stash ()
void ggit_repository_drop_stash (GgitRepository *repository
,gsize index
,GError **error
);
Removes a single stashed state from the stash list.
ggit_repository_stash_foreach ()
gboolean ggit_repository_stash_foreach (GgitRepository *repository
,GgitStashCallback callback
,gpointer user_data
,GError **error
);
Loops over all the stashed states and issue a callback for each one.
If callback
returns a non-zero value, this will stop looping.
ggit_repository_get_ahead_behind ()
void ggit_repository_get_ahead_behind (GgitRepository *repository
,GgitOId *local
,GgitOId *upstream
,gsize *ahead
,gsize *behind
,GError **error
);
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.
Types and Values
GgitRepository
typedef struct _GgitRepository GgitRepository;
Represents an existing git repository including all of it's object contents.
struct GgitRepositoryClass
struct GgitRepositoryClass { };
The class structure for GgitRepositoryClass.
enum GgitStashFlags
Describes how a stash should be applied.
Property Details
The “clone-options”
property
“clone-options” GgitCloneOptions *
Clone options.
Flags: Read / Write / Construct Only
The “init”
property
“init” gboolean
Whether to initialize a repository.
Flags: Read / Write / Construct Only
Default value: FALSE
The “is-bare”
property
“is-bare” gboolean
Is a bare repository.
Flags: Read / Write / Construct Only
Default value: FALSE
The “location”
property
“location” GFile *
The location of the repository.
Flags: Read / Write / Construct Only
The “url”
property
“url” gchar *
The URL for cloning a repository.
Flags: Read / Write / Construct Only
Default value: NULL