## GgitRepository GgitRepository |

## Functions

gint | (*GgitReferencesNameCallback) ()
gint | (*GgitStashCallback) ()
gint | (*GgitStatusCallback) ()
GgitRepository * | ggit_repository_open ()
GgitRepository * | ggit_repository_init_repository ()
GgitRepository * | ggit_repository_clone ()
GgitObject * | ggit_repository_lookup ()
GgitRef * | ggit_repository_lookup_reference ()
GgitRef * | ggit_repository_create_reference ()
GgitRef * | ggit_repository_create_symbolic_reference ()
GgitBlobOutputStream * | ggit_repository_create_blob ()
GgitOId * | ggit_repository_create_blob_from_buffer ()
GgitOId * | ggit_repository_create_blob_from_file ()
GgitOId * | ggit_repository_create_blob_from_path ()
GgitOId * | ggit_repository_create_commit ()
GgitOId * | ggit_repository_create_tag ()
GgitOId * | ggit_repository_create_tag_from_buffer ()
GgitOId * | ggit_repository_create_tag_lightweight ()
GgitTreeBuilder * | ggit_repository_create_tree_builder ()
GgitTreeBuilder * | ggit_repository_create_tree_builder_from_tree ()
GgitIndexEntry * | ggit_repository_create_index_entry_for_file ()
GgitIndexEntry * | ggit_repository_create_index_entry_for_path ()
gchar ** | ggit_repository_list_tags ()
GgitBranch * | ggit_repository_create_branch ()
GgitBranchEnumerator * | ggit_repository_enumerate_branches ()
GgitBranch * | ggit_repository_lookup_branch ()
GgitRemote * | ggit_repository_create_remote ()
gchar ** | ggit_repository_list_remotes ()
GgitRef * | ggit_repository_get_head ()
GFile * | ggit_repository_discover ()
gboolean | ggit_repository_is_head_detached ()
gboolean | ggit_repository_is_head_unborn ()
gboolean | ggit_repository_is_empty ()
GFile * | ggit_repository_get_location ()
GFile * | ggit_repository_get_workdir ()
void | ggit_repository_set_workdir ()
gboolean | ggit_repository_is_bare ()
GgitStatusFlags | ggit_repository_file_status ()
gboolean | ggit_repository_file_status_foreach ()
gboolean | ggit_repository_references_foreach_name ()
GgitConfig * | ggit_repository_get_config ()
GgitIndex * | ggit_repository_get_index ()
GgitSubmodule * | ggit_repository_lookup_submodule ()
gboolean | ggit_repository_submodule_foreach ()
void | ggit_repository_reset ()
GgitObject * | ggit_repository_revparse ()
GgitOId * | ggit_repository_save_stash ()
void | ggit_repository_drop_stash ()
gboolean | ggit_repository_stash_foreach ()
void | ggit_repository_get_ahead_behind ()

## 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

## Object Hierarchy

        GEnum
        ╰── GgitResetType
        GFlags
        ├── GgitCreateFlags
        ├── GgitStashFlags
        ╰── GgitStatusFlags
        GObject
        ╰── GgitObjectFactoryBase
            ╰── GgitNative
                ╰── GgitRepository

## Implemented Interfaces

GgitRepository implements GInitable.

## Description

## 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()`.

#### Parameters

name | the name of the reference |
user_data | user-supplied data. | [closure]

#### Returns

0 to go for the next references or a GgitError in case there was an error.

### 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()`.

#### Parameters

index | the position within the stash list. 0 points to the most recent stashed state. |
message | the stash message. |
stash_oid | the commit oid of the stashed state. |
user_data | user-suplied data. | [closure]

#### Returns

0 to go continue or a GgitError in case there was an error.

### 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()`.

#### Parameters

path | the file to retrieve status for, rooted at the repository working dir. |
status_flags | the status value. |
user_data | user-supplied data. | [closure]

#### Returns

0 to go for the next file or a GgitError in case there was an error.

### 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.

#### Parameters

location | the location of the repository. |
error | a GError for error reporting, or `NULL`. |

#### Returns

a newly created GgitRepository.

[transfer full]

### 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 `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. |
error | a GError for error reporting, or `NULL`. |

#### Returns

a newly created GgitRepository.

[transfer full]

### 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.

#### Parameters

url | url to fetch the repository from. |
location | the location of the repository. |
options | a GgitCloneOptions. | [allow-none]
error | a GError for error reporting, or `NULL`. |

#### Returns

a newly created GgitRepository.

[transfer full]

### 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.

#### Parameters

repository | a GgitRepository. |
oid | a GgitOId. |
gtype | a GType. |
error | a GError for error reporting, or `NULL`. |

#### Returns

the found GgitObject, or `NULL` on error.

[transfer full]

### 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()`.

#### Parameters

repository | a GgitRepository. |
name | the long name for the reference (e.g. HEAD, ref/heads/master, refs/tags/v0.1.0, ...). |
error | a GError for error reporting, or `NULL`. |

#### Returns

the searched reference.

[transfer full]

### ggit_repository_create_reference ()

    GgitRef *
    ggit_repository_create_reference (GgitRepository *repository,
                                      const gchar *name,
                                      GgitOId *oid,
                                      GgitSignature *signature,
                                      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()`.

#### Parameters

repository | a GgitRepository. |
name | the name for the new GgitRef. |
oid | the GgitOId pointed to by the reference. |
signature | a GgitSignature that will used to populate the reflog entry. |
log_message | The one line long message to be appended to the reflog. |
error | a GError for error reporting, or `NULL`. |

#### Returns

the newly created reference.

[transfer full]

### ggit_repository_create_symbolic_reference ()

    GgitRef *
    ggit_repository_create_symbolic_reference
                                   (GgitRepository *repository,
                                    const gchar *name,
                                    const gchar *target,
                                    GgitSignature *signature,
                                    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 | a GgitRepository. |
name | the name for the new GgitRef. |
target | the full name to the reference. |
signature | a GgitSignature that will used to populate the reflog entry. |
log_message | The one line long message to be appended to the reflog. |
error | a GError for error reporting, or `NULL`. |

#### Returns

the newly created reference.

[transfer full]

### 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.

#### Parameters

repository | a GgitRepository. |

#### Returns

a GgitBlobOutputStream.

[transfer full]

### 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.

#### Parameters

repository | a GgitRepository. |
buffer | the data. | [array length=size][element-type guint8]
size | the length (in bytes) of the data. |
error | a GError for error reporting, or `NULL`. |

#### Returns

the new GgitOid of the written blob, or `NULL` if writing the blob failed.

### 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.

#### Parameters

repository | a GgitRepository. |
file | a GFile. |
error | a GError for error reporting, or `NULL`. |

#### Returns

the new GgitOid of the written blob, or `NULL` if writing the blob failed.

### 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.

#### Parameters

repository | a GgitRepository. |
path | the file path. |
error | a GError for error reporting, or `NULL`. |

#### Returns

the new GgitOid of the written blob, or `NULL` if writing the blob failed.

### 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 | a GgitRepository. |
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 `parents` . |
error | a GError for error reporting, or `NULL`. |

#### Returns

the GgitOId of the created commit object, or `NULL` in case of an error.

### 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 | a GgitRepository. |
tag_name | the tag name. |
target | a GgitObject. |
tagger | a GgitSignature. |
message | the tag message. |
flags | a GgitCreateFlags. |
error | a GError for error reporting, or `NULL`. |

#### Returns

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

[transfer full][allow-none]

### 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.

#### Parameters

repository | a GgitRepository. |
tag | the tag buffer. |
flags | a GgitCreateFlags. |
error | a GError for error reporting, or `NULL`. |

#### Returns

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

[transfer full][allow-none]

### 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 | a GgitRepository. |
tag_name | the name of the tag. |
target | a GgitObject. |
flags | a GgitCreateFlags. |
error | a GError for error reporting, or `NULL`. |

#### Returns

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

[transfer full][allow-none]

### ggit_repository_create_tree_builder ()

    GgitTreeBuilder *
    ggit_repository_create_tree_builder (GgitRepository *repository,
                                         GError **error);

Create a new tree builder.

#### Parameters

repository | a GgitRepository. |
error | a GError for error reporting, or `NULL`. |

#### Returns

a new GgitTreeBuilder, or `NULL` if there was an error.

[transfer full]

### 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.

#### Parameters

tree | a GgitTree. |
error | a GError for error reporting, or `NULL`. |

#### Returns

a new GgitTreeBuilder object, or `NULL` if there was an error.

[transfer full]

### 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 | a GgitRepository. |
file | a GFile. | [allow-none]
id | a GgitOId. | [allow-none]
error | a GError for error reporting, or `NULL`. |

#### Returns

a GgitIndexEntry or `NULL` when an error occurred.

### 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 `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 | a GgitRepository. |
path | a path. | [allow-none]
id | a GgitOId. | [allow-none]
error | a GError for error reporting, or `NULL`. |

#### Returns

a GgitIndexEntry or `NULL` when an error occurred.

### ggit_repository_list_tags ()

    gchar **
    ggit_repository_list_tags (GgitRepository *repository,
                               GError **error);

Fill a list with all the tags in the `repository` .

#### Parameters

repository | a GgitRepository. |
error | a GError for error reporting, or `NULL`. |

#### Returns

a list with the tags in `repository` .

[transfer full][allow-none]

### ggit_repository_create_branch ()

    GgitBranch *
    ggit_repository_create_branch (GgitRepository *repository,
                                   const gchar *branch_name,
                                   GgitObject *target,
                                   GgitCreateFlags flags,
                                   GgitSignature *signature,
                                   const gchar *log_message,
                                   GError **error);

Creates a new branch pointing at a target commit.

#### Parameters

repository | a GgitRepository. |
branch_name | the name of the branch. |
target | a GgitObject. |
flags | a GgitCreateFlags. |
signature | a GgitSignature that will used to populate the reflog entry. |
log_message | The one line long message to be appended to the reflog. |
error | a GError for error reporting, or `NULL`. |

#### Returns

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

[transfer full][allow-none]

### 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` .

#### Parameters

repository | a GgitRepository. |
list_type | a GgitBranchType. |
error | a GError for error reporting, or `NULL`. |

#### Returns

a branch enumerator.

[transfer full]

### 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.

#### Parameters

repository | a GgitRepository. |
branch_name | the name of the branch. |
branch_type | a GgitBranchType. |
error | a GError for error reporting, or `NULL`. |

#### Returns

a branch by its name in a repository.

[transfer full][allow-none]

### 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.

#### Parameters

repository | a GgitRepository. |
name | the name of the new remote. |
url | the url of the remote. |
error | a GError for error reporting, or `NULL`. |

#### Returns

a new GgitRemote or `NULL` if there is an error.

[transfer full][allow-none]

### ggit_repository_list_remotes ()

    gchar **
    ggit_repository_list_remotes (GgitRepository *repository,
                                  GError **error);

Fill a list with all the remotes in `repository` .

#### Parameters

repository | a GgitRepository. |
error | a GError for error reporting, or `NULL`. |

#### Returns

a list with the remotes.

[transfer full][allow-none]

### 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.

#### Parameters

repository | a GgitRepository. |
error | a GError for error reporting, or `NULL`. |

#### Returns

a GgitRef.

[transfer full]

### 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.

#### Parameters

location | the base location where the lookup starts. |
error | a GError for error reporting, or `NULL`. |

#### Returns

the repository location.

[transfer full]

### 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.

#### Parameters

repository | a GgitRepository. |
error | a GError for error reporting, or `NULL`. |

#### Returns

`TRUE` if HEAD is detached.

### 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.

#### Parameters

repository | a GgitRepository. |
error | a GError for error reporting, or `NULL`. |

#### Returns

`TRUE` if the current branch is an orphan.

### 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.

#### Parameters

repository | a GgitRepository. |
error | a GError for error reporting, or `NULL`. |

#### Returns

`TRUE` if the repository is empty.

### ggit_repository_get_location ()

    GFile *
    ggit_repository_get_location (GgitRepository *repository);

Get the gitdir location of the repository.

#### Parameters

repository | a GgitRepository. |

#### Returns

the location of the gitdir of the repository.

[transfer full]

### ggit_repository_get_workdir ()

    GFile *
    ggit_repository_get_workdir (GgitRepository *repository);

Gets the working directory of the repository.

#### Parameters

repository | a GgitRepository. |

#### Returns

the location of the working directory of the repository.

[transfer full]

### 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).

#### Parameters

repository | a GgitRepository. |
workdir | the working directory. |
update_gitlink | create/update gitlink in workdir. |

### ggit_repository_is_bare ()

    gboolean
    ggit_repository_is_bare (GgitRepository *repository);

Checks if `repository` is bare.

#### Parameters

repository | a GgitRepository. |

#### Returns

`TRUE` if the repository is empty.

### ggit_repository_file_status ()

    GgitStatusFlags
    ggit_repository_file_status (GgitRepository *repository,
                                 GFile *location,
                                 GError **error);

Gets the file status for a single file.

#### Parameters

repository | a GgitRepository. |
location | the file to retrieve status for, rooted at the repository working dir. |
error | a GError for error reporting, or `NULL`. |

#### Returns

the 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.

#### Parameters

repository | a GgitRepository. |
options | status options, or `NULL`. | [allow-none]
callback | a GgitStatusCallback. | [scope call]
user_data | callback user data. |
error | a GError for error reporting, or `NULL`. |

#### Returns

`TRUE` if there was no error, `FALSE` otherwise

### ggit_repository_references_foreach_name ()

    gboolean
    ggit_repository_references_foreach_name
                                   (GgitRepository *repository,
                                    GgitReferencesNameCallback callback,
                                    gpointer user_data,
                                    GError **error);

Gathers references 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.

#### Parameters

repository | a GgitRepository. |
callback | a GgitReferencesNameCallback. | [scope call]
user_data | callback user data. |
error | a GError for error reporting, or `NULL`. |

#### Returns

`TRUE` if there was no error, `FALSE` otherwise

### ggit_repository_get_config ()

    GgitConfig *
    ggit_repository_get_config (GgitRepository *repository,
                                GError **error);

Get the config for a specific repository.

#### Parameters

repository | a GgitRepository. |
error | a GError for error reporting, or `NULL`. |

#### Returns

a GgitConfig.

[transfer full]

### ggit_repository_get_index ()

    GgitIndex *
    ggit_repository_get_index (GgitRepository *repository,
                               GError **error);

Get the index for a specific repository.

#### Parameters

repository | a GgitRepository. |
error | a GError for error reporting, or `NULL`. |

#### Returns

a GgitIndex.

[transfer full]

### 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.

#### Parameters

repository | a GgitRepository. |
name | the name of the submodule. |
error | a GError for error reporting, or `NULL`. |

#### Returns

a newly-allocated GgitSubmodule.

[transfer full][allow-none]

### ggit_repository_submodule_foreach ()

    gboolean
    ggit_repository_submodule_foreach (GgitRepository *repository,
                                       GgitSubmoduleCallback 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.

#### Parameters

repository | a GgitRepository. |
callback | a GgitStatusCallback. | [scope call]
user_data | callback user data. |
error | a GError for error reporting, or `NULL`. |

#### Returns

`TRUE` if there was no error, `FALSE` otherwise

### ggit_repository_reset ()

    void
    ggit_repository_reset (GgitRepository *repository,
                           GgitObject *target,
                           GgitResetType reset_type,
                           GgitCheckoutOptions *checkout_options,
                           GgitSignature *signature,
                           const gchar *log_message,
                           GError **error);

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

#### Parameters

repository | a GgitRepository. |
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. |
signature | a GgitSignature that will used to populate the reflog entry. |
log_message | The one line long message to be appended to the reflog. |
error | a GError for error reporting, or `NULL`. |

### 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.

#### Parameters

repository | a GgitRepository. |
spec | the revision specification. |
error | a GError for error reporting, or `NULL`. |

#### Returns

a GgitObject or `NULL` if the revision could not be found.

[transfer full]

### 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 | a GgitRepository. |
stasher | a GgitSignature. |
message | description along with the stashed state or `NULL` to be autogenerated. |
flags | a GgitStashFlags to control the stashing process. |
error | a GError for error reporting, GGIT_ENOTFOUND if there's nothing to stash or `NULL`. |

#### Returns

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

[transfer full]

### ggit_repository_drop_stash ()

    void
    ggit_repository_drop_stash (GgitRepository *repository,
                                gsize index,
                                GError **error);

Removes a single stashed state from the stash list.

#### Parameters

repository | a GgitRepository. |
index | the position within the stash list. 0 points to the. most recent stashed state. |
error | a GError for error reporting, or `NULL`. |

### 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.

#### Parameters

repository | a GgitRepository. |
callback | a GgitStashCallback. | [scope call]
user_data | callback user data. |
error | a GError for error reporting, or `NULL`. |

#### Returns

`TRUE` if there was no error, `FALSE` otherwise.

### 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.

#### Parameters

repository | a GgitRepository. |
local | the commit for local. |
upstream | the commit for upstream. |
ahead | number of unique from commits in `upstream` . |
behind | number of unique from commits in `local` . |
error | a GError for error reporting, or `NULL`. |

## 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.

#### Members

### enum GgitCreateFlags

Describes how something should be created.

#### Members

GGIT_CREATE_NONE | attempt to create. |
GGIT_CREATE_FORCE | force creation. |

### enum GgitResetType

Describes the type of reset to perform.

#### Members

GGIT_RESET_SOFT | The head will be moved to the commit. |
GGIT_RESET_MIXED | the head will be moved to the commit and the index will be replaced with the content of the commit tree. |
GGIT_RESET_HARD | MIXED plus changes in working tree discarded. |

### enum GgitStashFlags

Describes how a stash should be applied.

#### Members

GGIT_STASH_DEFAULT | default stash. |
GGIT_STASH_KEEP_INDEX | All changes already added to the index are left intact in the working directory. |
GGIT_STASH_INCLUDE_UNTRACKED | All untracked files are also stashed and then cleaned up from the working directory. |
GGIT_STASH_INCLUDE_IGNORED | All ignored files are also stashed and then cleaned up from the working directory. |

### enum GgitStatusFlags

Describes a file's status.

#### Members

GGIT_STATUS_CURRENT | file is current. |
GGIT_STATUS_INDEX_NEW | file in index is new. |
GGIT_STATUS_INDEX_MODIFIED | file in index is modified. |
GGIT_STATUS_INDEX_DELETED | file in index is deleted. |
GGIT_STATUS_INDEX_RENAMED |  |
GGIT_STATUS_INDEX_TYPECHANGE |  |
GGIT_STATUS_WORKING_TREE_NEW | file in working tree is new. |
GGIT_STATUS_WORKING_TREE_MODIFIED | file in working tree is modified. |
GGIT_STATUS_WORKING_TREE_DELETED | file in working tree is deleted. |
GGIT_STATUS_WORKING_TREE_TYPECHANGE |  |
GGIT_STATUS_IGNORED | file is ignored. |

## Property Details

### The `“clone-options”` property

      “clone-options”            GgitCloneOptions *

Clone options.

Flags: Read / Write / Construct Only

### The `“head”` property

      “head”                     GgitRef *

Head.

Flags: Read

### 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

### The `“workdir”` property

      “workdir”                  GFile *

The path to the repository working directory.

Flags: Read / Write / Construct