## GgitConfig GgitConfig |

## Synopsis

                        GgitConfig;
    struct              GgitConfigClass;
    gint                (*GgitConfigCallback)               (GgitConfigEntry *entry,
                                                             gpointer user_data);
    enum                GgitConfigLevel;
    gint                (*GgitConfigMatchCallback)          (GMatchInfo *match_info,
                                                             const gchar *value,
                                                             gpointer user_data);
    GgitConfig *        ggit_config_new                     (void);
    GgitConfig *        ggit_config_new_default             (GError **error);
    GgitConfig *        ggit_config_new_from_file           (GFile *file,
                                                             GError **error);
    GFile *             ggit_config_find_global             (void);
    GFile *             ggit_config_find_system             (void);
    void                ggit_config_add_file                (GgitConfig *config,
                                                             GFile *file,
                                                             GgitConfigLevel level,
                                                             gboolean force,
                                                             GError **error);
    void                ggit_config_refresh                 (GgitConfig *config,
                                                             GError **error);
    gint32              ggit_config_get_int32               (GgitConfig *config,
                                                             const gchar *name,
                                                             GError **error);
    gboolean            ggit_config_set_int32               (GgitConfig *config,
                                                             const gchar *name,
                                                             gint32 value,
                                                             GError **error);
    gint64              ggit_config_get_int64               (GgitConfig *config,
                                                             const gchar *name,
                                                             GError **error);
    gboolean            ggit_config_set_int64               (GgitConfig *config,
                                                             const gchar *name,
                                                             gint64 value,
                                                             GError **error);
    gboolean            ggit_config_get_bool                (GgitConfig *config,
                                                             const gchar *name,
                                                             GError **error);
    gboolean            ggit_config_set_bool                (GgitConfig *config,
                                                             const gchar *name,
                                                             gboolean value,
                                                             GError **error);
    const gchar *       ggit_config_get_string              (GgitConfig *config,
                                                             const gchar *name,
                                                             GError **error);
    gboolean            ggit_config_set_string              (GgitConfig *config,
                                                             const gchar *name,
                                                             const gchar *value,
                                                             GError **error);
    gboolean            ggit_config_delete_entry            (GgitConfig *config,
                                                             const gchar *name,
                                                             GError **error);
    gboolean            ggit_config_foreach                 (GgitConfig *config,
                                                             GgitConfigCallback callback,
                                                             gpointer user_data,
                                                             GError **error);
    const gchar *       ggit_config_match                   (GgitConfig *config,
                                                             GRegex *regex,
                                                             GMatchInfo **match_info,
                                                             GError **error);
    gboolean            ggit_config_match_foreach           (GgitConfig *config,
                                                             GRegex *regex,
                                                             GgitConfigMatchCallback callback,
                                                             gpointer user_data,
                                                             GError **error);

## Object Hierarchy

      GObject
       +----GgitObjectFactoryBase
             +----GgitNative
                   +----GgitConfig

      GEnum
       +----GgitConfigLevel

## Description

## Details

### GgitConfig

    typedef struct _GgitConfig GgitConfig;

Represents a git configuration.

### struct GgitConfigClass

    struct GgitConfigClass {
    };

The class structure for GgitConfigClass.

### GgitConfigCallback ()

    gint                (*GgitConfigCallback)               (GgitConfigEntry *entry,
                                                             gpointer user_data);

The type of the callback functions for retrieving values from a GgitConfig. See `ggit_config_foreach()`.

`entry` : | a GgitConfigEntry.
`user_data` : | user-supplied data. [closure]
Returns : | 0 to go for the next config value or a GgitError in case there was an error.

### enum GgitConfigLevel

    typedef enum {
    	GGIT_CONFIG_LEVEL_SYSTEM = 1,
    	GGIT_CONFIG_LEVEL_XDG = 2,
    	GGIT_CONFIG_LEVEL_GLOBAL = 3,
    	GGIT_CONFIG_LEVEL_LOCAL = 4,
    	GGIT_CONFIG_LEVEL_HIGHEST = -1
    } GgitConfigLevel;

Priority level of a config file. These priority levels correspond to the natural escalation logic (from higher to lower) when searching for config entries in git.git.

`GGIT_CONFIG_LEVEL_SYSTEM` | System-wide configuration file.
`GGIT_CONFIG_LEVEL_XDG` | XDG compatible configuration file (.config/git/config).
`GGIT_CONFIG_LEVEL_GLOBAL` | User-specific configuration file, also called Global configuration file.
`GGIT_CONFIG_LEVEL_LOCAL` | Repository specific configuration file.
`GGIT_CONFIG_LEVEL_HIGHEST` | Represents the highest level of a config file.

### GgitConfigMatchCallback ()

    gint                (*GgitConfigMatchCallback)          (GMatchInfo *match_info,
                                                             const gchar *value,
                                                             gpointer user_data);

The type of the callback functions for retrieving values from a GgitConfig using a regular expression. See `ggit_config_match_foreach()`.

`match_info` : | the match
`value` : | the value
`user_data` : | user-supplied data. [closure]
Returns : | 0 to go for the next config value or a GgitError in case there was an error.

### ggit_config_new ()

    GgitConfig *        ggit_config_new                     (void);

Create a new config. See also `ggit_config_get_default()` to get a GgitConfig representing the global, XDG and system configuration files. To get a GgitConfig for a repository use ggit_repository_get_config instead.

Returns : | a GgitConfig. [transfer full]

### ggit_config_new_default ()

    GgitConfig *        ggit_config_new_default             (GError **error);

Get the global, XDG and system configuration files merged into one GgitConfig with their appropriate priority levels. If an error occured trying to load the various configuration files, this function will return `NULL` and `error` will be set accordingly.

`error` : | a GError for error reporting, or `NULL`.
Returns : | A GgitConfig. [transfer none]

### ggit_config_new_from_file ()

    GgitConfig *        ggit_config_new_from_file           (GFile *file,
                                                             GError **error);

Create a new config from a single on disk file. This is a convenience API and is exactly the same as creating an empty GgitConfig using ggit_config_new and adding the file with ggit_config_add_file. The level will be set to GGIT_CONFIG_LEVEL_LOCAL. If the config could not be loaded this function returns `NULL` and `error` will be set accordingly.

`file` : | the file to load.
`error` : | a GError for error reporting, or `NULL`.
Returns : | a GgitConfig. [transfer full]

### ggit_config_find_global ()

    GFile *             ggit_config_find_global             (void);

Find the file representing the users global git configuration. This file is usually located at $HOME/.gitconfig. This function will try to guess the full path to that file, if the file exists. The returned file may then be used with ggit_config_new_from_file or ggit_config_add_file. This function returns `NULL` if the global config could not be found.

Returns : | a GFile or `NULL` if the global config could not be found. [transfer full]

### ggit_config_find_system ()

    GFile *             ggit_config_find_system             (void);

Find the file representing the systems global git configuration. This file is usually located at /etc/gitconfig on UNIX type systems or `PROGRAMFILES`%\Git\etc\gitconfig on windows. This function will try to guess the full path to that file, if the file exists. The returned file may then be used with ggit_config_new_from_file or ggit_config_add_file. This function returns `NULL` if the system config could not be found.

Returns : | a GFile or `NULL` if the system config could not be found. [transfer full]

### ggit_config_add_file ()

    void                ggit_config_add_file                (GgitConfig *config,
                                                             GFile *file,
                                                             GgitConfigLevel level,
                                                             gboolean force,
                                                             GError **error);

Add an on-disk config file instance to an existing config

The on-disk file pointed at by `file` will be opened and parsed; it's expected to be a native Git config file following the default Git config syntax (see man git-config).

Further queries on this config object will access each of the config file instances in order (instances with a higher priority level will be accessed first).

`config` : | a GgitConfig.
`file` : | a GFile.
`level` : | a GgitConfigLevel.
`force` : | if a config file already exists for the given priority level, replace it.
`error` : | a GError for error reporting, or `NULL`.

### ggit_config_refresh ()

    void                ggit_config_refresh                 (GgitConfig *config,
                                                             GError **error);

Reloads changed config files.

A config file may be changed on disk out from under the in-memory config object. This function causes us to look for files that have been modified since we last loaded them and refresh the config with the latest information.

`config` : | a GgitConfig.
`error` : | a GError for error reporting, or `NULL`.

### ggit_config_get_int32 ()

    gint32              ggit_config_get_int32               (GgitConfig *config,
                                                             const gchar *name,
                                                             GError **error);

Get a int32 configuration value.

`config` : | a GgitConfig.
`name` : | the name of the configuration value.
`error` : | a GError for error reporting, or `NULL`.
Returns : | the value.

### ggit_config_set_int32 ()

    gboolean            ggit_config_set_int32               (GgitConfig *config,
                                                             const gchar *name,
                                                             gint32 value,
                                                             GError **error);

Set a int32 value.

`config` : | a GgitConfig.
`name` : | the name of the configuration value.
`value` : | the new value.
`error` : | a GError for error reporting, or `NULL`.
Returns : | `TRUE` if the value was successfully set, `FALSE` otherwise.

### ggit_config_get_int64 ()

    gint64              ggit_config_get_int64               (GgitConfig *config,
                                                             const gchar *name,
                                                             GError **error);

Get a int64 configuration value.

`config` : | a GgitConfig.
`name` : | the name of the configuration value.
`error` : | a GError for error reporting, or `NULL`.
Returns : | the value.

### ggit_config_set_int64 ()

    gboolean            ggit_config_set_int64               (GgitConfig *config,
                                                             const gchar *name,
                                                             gint64 value,
                                                             GError **error);

Set a int64 value.

`config` : | a GgitConfig.
`name` : | the name of the configuration value.
`value` : | the new value.
`error` : | a GError for error reporting, or `NULL`.
Returns : | `TRUE` if the value was successfully set, `FALSE` otherwise.

### ggit_config_get_bool ()

    gboolean            ggit_config_get_bool                (GgitConfig *config,
                                                             const gchar *name,
                                                             GError **error);

Get a boolean configuration value.

`config` : | a GgitConfig.
`name` : | the name of the configuration value.
`error` : | a GError for error reporting, or `NULL`.
Returns : | the value.

### ggit_config_set_bool ()

    gboolean            ggit_config_set_bool                (GgitConfig *config,
                                                             const gchar *name,
                                                             gboolean value,
                                                             GError **error);

Set a boolean value.

`config` : | a GgitConfig.
`name` : | the name of the configuration value.
`value` : | the new value.
`error` : | a GError for error reporting, or `NULL`.
Returns : | `TRUE` if the value was successfully set, `FALSE` otherwise.

### ggit_config_get_string ()

    const gchar *       ggit_config_get_string              (GgitConfig *config,
                                                             const gchar *name,
                                                             GError **error);

Get the configuration value of `name` as string.

`config` : | a GgitConfig.
`name` : | the name of the configuration value.
`error` : | a GError for error reporting, or `NULL`.
Returns : | the string value of `name`, or `NULL` if such a value does not exist. [allow-none]

### ggit_config_set_string ()

    gboolean            ggit_config_set_string              (GgitConfig *config,
                                                             const gchar *name,
                                                             const gchar *value,
                                                             GError **error);

Set a new string value of a configuration.

`config` : | a GgitConfig.
`name` : | the name of the configuration value.
`value` : | the new value.
`error` : | a GError for error reporting, or `NULL`.
Returns : | `TRUE` if the value was successfully set, `FALSE` otherwise.

### ggit_config_delete_entry ()

    gboolean            ggit_config_delete_entry            (GgitConfig *config,
                                                             const gchar *name,
                                                             GError **error);

Delete a config variable from the config file.

`config` : | a GgitConfig.
`name` : | the configuration value.
`error` : | a GError for error reporting, or `NULL`.
Returns : | `TRUE` if the configuration value was deleted, `FALSE` otherwise.

### ggit_config_foreach ()

    gboolean            ggit_config_foreach                 (GgitConfig *config,
                                                             GgitConfigCallback callback,
                                                             gpointer user_data,
                                                             GError **error);

Call `callback` for each configuration value.

`config` : | a GgitConfig.
`callback` : | a GgitConfigCallback. [scope call]
`user_data` : | the user data for `callback`. [allow-none]
`error` : | a GError for error reporting, or `NULL`.
Returns : | `TRUE` if successfull, `FALSE` otherwise

### ggit_config_match ()

    const gchar *       ggit_config_match                   (GgitConfig *config,
                                                             GRegex *regex,
                                                             GMatchInfo **match_info,
                                                             GError **error);

Matches a configuration against a regular expression. `match_info` will contain the match information if the return value is not `NULL`, otherwise `error` will be set.

`config` : | a GgitConfig.
`regex` : | a GRegex.
`match_info` : | a GMatchInfo. [out][allow-none]
`error` : | a GError for error reporting, or `NULL`.
Returns : | the value of that matched configuration. [allow-none]

### ggit_config_match_foreach ()

    gboolean            ggit_config_match_foreach           (GgitConfig *config,
                                                             GRegex *regex,
                                                             GgitConfigMatchCallback callback,
                                                             gpointer user_data,
                                                             GError **error);

Call `callback` for all configurations matching `regex`.

`config` : | a GgitConfig.
`regex` : | a GRegex.
`callback` : | a GgitConfigMatchCallback. [scope call][closure user_data]
`user_data` : | the user data for `callback`. [closure]
`error` : | a GError for error reporting, or `NULL`.
Returns : | `TRUE` if matches were successfull, `FALSE` otherwise