## GgitIndex GgitIndex |

## Synopsis

                        GgitIndex;
    struct              GgitIndexClass;
    GgitIndex *         ggit_index_open                     (GFile *file,
                                                             GError **error);
    gboolean            ggit_index_read                     (GgitIndex *idx,
                                                             GError **error);
    gboolean            ggit_index_write                    (GgitIndex *idx,
                                                             GError **error);
    GgitOId *           ggit_index_write_tree               (GgitIndex *idx,
                                                             GError **error);
    gboolean            ggit_index_remove                   (GgitIndex *idx,
                                                             GFile *file,
                                                             gint stage,
                                                             GError **error);
    gboolean            ggit_index_add                      (GgitIndex *idx,
                                                             GgitIndexEntry *entry,
                                                             GError **error);
    gboolean            ggit_index_add_file                 (GgitIndex *idx,
                                                             GFile *file,
                                                             GError **error);
    gboolean            ggit_index_add_path                 (GgitIndex *idx,
                                                             const gchar *path,
                                                             GError **error);
    GgitRepository *    ggit_index_get_owner                (GgitIndex *idx);
    GgitIndexEntries *  ggit_index_get_entries              (GgitIndex *idx);
    GgitIndexEntriesResolveUndo * ggit_index_get_entries_resolve_undo
                                                            (GgitIndex *idx);

## Object Hierarchy

      GObject
       +----GgitObjectFactoryBase
             +----GgitNative
                   +----GgitIndex

## Implemented Interfaces

GgitIndex implements GInitable.

## Properties

      "file"                     GFile*                : Read / Write / Construct Only

## Description

## Details

### GgitIndex

    typedef struct _GgitIndex GgitIndex;

Represents an index object.

### struct GgitIndexClass

    struct GgitIndexClass {
    };

The class structure for GgitIndexClass.

### ggit_index_open ()

    GgitIndex *         ggit_index_open                     (GFile *file,
                                                             GError **error);

Create a new bare Git index object as a memory representation of the Git index file in `file`, without a repository to back it.

`file` : | a GFile.
`error` : | a GError for error reporting, or `NULL`.
Returns : | a GgitIndex or `NULL` if an error occurred. [transfer full]

### ggit_index_read ()

    gboolean            ggit_index_read                     (GgitIndex *idx,
                                                             GError **error);

Update the contents of an existing index object in memory by reading from the hard disk.

`idx` : | a GgitIndex.
`error` : | a GError for error reporting, or `NULL`.
Returns : | `TRUE` if the index could be read from the file associated with the index, `FALSE` otherwise.

### ggit_index_write ()

    gboolean            ggit_index_write                    (GgitIndex *idx,
                                                             GError **error);

Write an existing index object from memory back to disk using an atomic file lock.

`idx` : | a GgitIndex.
`error` : | a GError for error reporting, or `NULL`.
Returns : | `TRUE` if the index was successfully written to disk, `FALSE` otherwise.

### ggit_index_write_tree ()

    GgitOId *           ggit_index_write_tree               (GgitIndex *idx,
                                                             GError **error);

Write a new tree object to disk containing a representation of the current state of the index. The index must be associated to an existing repository and must not contain any files in conflict. You can use the resulting tree to for instance create a commit.

`idx` : | a GgitIndex.
`error` : | a GError for error reporting, or `NULL`.
Returns : | a GgitOId or `NULL` in case of an error.

### ggit_index_remove ()

    gboolean            ggit_index_remove                   (GgitIndex *idx,
                                                             GFile *file,
                                                             gint stage,
                                                             GError **error);

Remove a file from the index (specified by position).

`idx` : | a GgitIndex.
`file` : | the file to search.
`stage` : | the stage to search.
`error` : | a GError for error reporting, or `NULL`.
Returns : | `TRUE` if the file was successfully removed, `FALSE` otherwise.

### ggit_index_add ()

    gboolean            ggit_index_add                      (GgitIndex *idx,
                                                             GgitIndexEntry *entry,
                                                             GError **error);

Add a file to the index.

`idx` : | a GgitIndex.
`entry` : | a GgitIndexEntry.
`error` : | a GError for error reporting, or `NULL`.
Returns : | `TRUE` if the file was successfully added, `FALSE` otherwise.

### ggit_index_add_file ()

    gboolean            ggit_index_add_file                 (GgitIndex *idx,
                                                             GFile *file,
                                                             GError **error);

Add a file to the index. The specified file must be in the working directory and must exist and be readable.

`idx` : | a GgitIndex.
`file` : | file to add.
`error` : | a GError for error reporting, or `NULL`.
Returns : | `TRUE` if the file was added to the index or `FALSE` if there was an error.

### ggit_index_add_path ()

    gboolean            ggit_index_add_path                 (GgitIndex *idx,
                                                             const gchar *path,
                                                             GError **error);

Add a file to the index by path. You can specify both relative paths (to the working directory) and absolute paths. Absolute paths however must reside in the working directory. The specified path must exist and must be readable.

`idx` : | a GgitIndex.
`path` : | path to the file to add.
`error` : | a GError for error reporting, or `NULL`.
Returns : | `TRUE` if the file was added to the index or `FALSE` if there was an error.

### ggit_index_get_owner ()

    GgitRepository *    ggit_index_get_owner                (GgitIndex *idx);

Get the GgitRepository that owns the index.

`idx` : | a GgitIndex.
Returns : | the GgitRepository that owns this index. [transfer full]

### ggit_index_get_entries ()

    GgitIndexEntries *  ggit_index_get_entries              (GgitIndex *idx);

Get the index entries enumerator.

`idx` : | a GgitIndex.
Returns : | a GgitIndexEntries. [transfer full]

### ggit_index_get_entries_resolve_undo ()

    GgitIndexEntriesResolveUndo * ggit_index_get_entries_resolve_undo
                                                            (GgitIndex *idx);

Get the resolve undo entries enumerator.

`idx` : | a GgitIndex.
Returns : | a GgitIndexEntriesResolveUndo. [transfer full]

## Property Details

### The `"file"` property

      "file"                     GFile*                : Read / Write / Construct Only

File.