![]() |
![]() |
![]() |
libgit2-glib Reference Manual | ![]() |
---|---|---|---|---|
Top | Description | Object Hierarchy |
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
);
GObject +----GgitObjectFactoryBase +----GgitNative +----GgitConfig
GEnum +----GgitConfigLevel
gint (*GgitConfigCallback) (GgitConfigEntry *entry
,gpointer user_data
);
The type of the callback functions for retrieving values from a GgitConfig.
See ggit_config_foreach()
.
|
a GgitConfigEntry. |
|
user-supplied data. [closure] |
Returns : |
0 to go for the next config value or a GgitError in case there was an error. |
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.
System-wide configuration file. | |
XDG compatible configuration file (.config/git/config). | |
User-specific configuration file, also called Global configuration file. | |
Repository specific configuration file. | |
Represents the highest level of a config file. |
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()
.
|
the match |
|
the value |
|
user-supplied data. [closure] |
Returns : |
0 to go for the next config value or a GgitError in case there was an error. |
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] |
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.
|
a GError for error reporting, or NULL . |
Returns : |
A GgitConfig. [transfer none] |
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.
|
the file to load. |
|
a GError for error reporting, or NULL . |
Returns : |
a GgitConfig. [transfer full] |
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]
|
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]
|
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).
|
a GgitConfig. |
|
a GFile. |
|
a GgitConfigLevel. |
|
if a config file already exists for the given priority level, replace it. |
|
a GError for error reporting, or NULL . |
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.
|
a GgitConfig. |
|
a GError for error reporting, or NULL . |
gint32 ggit_config_get_int32 (GgitConfig *config
,const gchar *name
,GError **error
);
Get a int32 configuration value.
|
a GgitConfig. |
|
the name of the configuration value. |
|
a GError for error reporting, or NULL . |
Returns : |
the value. |
gboolean ggit_config_set_int32 (GgitConfig *config
,const gchar *name
,gint32 value
,GError **error
);
Set a int32 value.
|
a GgitConfig. |
|
the name of the configuration value. |
|
the new value. |
|
a GError for error reporting, or NULL . |
Returns : |
TRUE if the value was successfully set, FALSE otherwise. |
gint64 ggit_config_get_int64 (GgitConfig *config
,const gchar *name
,GError **error
);
Get a int64 configuration value.
|
a GgitConfig. |
|
the name of the configuration value. |
|
a GError for error reporting, or NULL . |
Returns : |
the value. |
gboolean ggit_config_set_int64 (GgitConfig *config
,const gchar *name
,gint64 value
,GError **error
);
Set a int64 value.
|
a GgitConfig. |
|
the name of the configuration value. |
|
the new value. |
|
a GError for error reporting, or NULL . |
Returns : |
TRUE if the value was successfully set, FALSE otherwise. |
gboolean ggit_config_get_bool (GgitConfig *config
,const gchar *name
,GError **error
);
Get a boolean configuration value.
|
a GgitConfig. |
|
the name of the configuration value. |
|
a GError for error reporting, or NULL . |
Returns : |
the value. |
gboolean ggit_config_set_bool (GgitConfig *config
,const gchar *name
,gboolean value
,GError **error
);
Set a boolean value.
|
a GgitConfig. |
|
the name of the configuration value. |
|
the new value. |
|
a GError for error reporting, or NULL . |
Returns : |
TRUE if the value was successfully set, FALSE otherwise. |
const gchar * ggit_config_get_string (GgitConfig *config
,const gchar *name
,GError **error
);
Get the configuration value of name
as string.
|
a GgitConfig. |
|
the name of the configuration value. |
|
a GError for error reporting, or NULL . |
Returns : |
the string value of name , or NULL if such a value
does not exist. [allow-none]
|
gboolean ggit_config_set_string (GgitConfig *config
,const gchar *name
,const gchar *value
,GError **error
);
Set a new string value of a configuration.
|
a GgitConfig. |
|
the name of the configuration value. |
|
the new value. |
|
a GError for error reporting, or NULL . |
Returns : |
TRUE if the value was successfully set, FALSE otherwise. |
gboolean ggit_config_delete_entry (GgitConfig *config
,const gchar *name
,GError **error
);
Delete a config variable from the config file.
|
a GgitConfig. |
|
the configuration value. |
|
a GError for error reporting, or NULL . |
Returns : |
TRUE if the configuration value was deleted, FALSE otherwise. |
gboolean ggit_config_foreach (GgitConfig *config
,GgitConfigCallback callback
,gpointer user_data
,GError **error
);
Call callback
for each configuration value.
|
a GgitConfig. |
|
a GgitConfigCallback. [scope call] |
|
the user data for callback . [allow-none]
|
|
a GError for error reporting, or NULL . |
Returns : |
TRUE if successfull, FALSE otherwise |
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.
|
a GgitConfig. |
|
a GRegex. |
|
a GMatchInfo. [out][allow-none] |
|
a GError for error reporting, or NULL . |
Returns : |
the value of that matched configuration. [allow-none] |
gboolean ggit_config_match_foreach (GgitConfig *config
,GRegex *regex
,GgitConfigMatchCallback callback
,gpointer user_data
,GError **error
);
Call callback
for all configurations matching regex
.
|
a GgitConfig. |
|
a GRegex. |
|
a GgitConfigMatchCallback. [scope call][closure user_data] |
|
the user data for callback . [closure]
|
|
a GError for error reporting, or NULL . |
Returns : |
TRUE if matches were successfull, FALSE otherwise |