mirror of
https://git.proxmox.com/git/libgit2
synced 2025-05-29 06:20:56 +00:00
Clean up config.h
This commit is contained in:
parent
eecc805029
commit
54b2a37ac7
@ -41,23 +41,26 @@ typedef struct {
|
||||
unsigned int level;
|
||||
} git_config_entry;
|
||||
|
||||
typedef int (*git_config_foreach_cb)(const git_config_entry *, void *);
|
||||
|
||||
|
||||
/**
|
||||
* Generic backend that implements the interface to
|
||||
* access a configuration file
|
||||
*/
|
||||
struct git_config_file {
|
||||
struct git_config_backend {
|
||||
struct git_config *cfg;
|
||||
|
||||
/* Open means open the file/database and parse if necessary */
|
||||
int (*open)(struct git_config_file *, unsigned int level);
|
||||
int (*get)(struct git_config_file *, const char *key, const git_config_entry **entry);
|
||||
int (*get_multivar)(struct git_config_file *, const char *key, const char *regexp, int (*fn)(const git_config_entry *, void *), void *data);
|
||||
int (*set)(struct git_config_file *, const char *key, const char *value);
|
||||
int (*set_multivar)(git_config_file *cfg, const char *name, const char *regexp, const char *value);
|
||||
int (*del)(struct git_config_file *, const char *key);
|
||||
int (*foreach)(struct git_config_file *, const char *, int (*fn)(const git_config_entry *, void *), void *data);
|
||||
int (*refresh)(struct git_config_file *);
|
||||
void (*free)(struct git_config_file *);
|
||||
int (*open)(struct git_config_backend *, unsigned int level);
|
||||
int (*get)(const struct git_config_backend *, const char *key, const git_config_entry **entry);
|
||||
int (*get_multivar)(struct git_config_backend *, const char *key, const char *regexp, git_config_foreach_cb callback, void *payload);
|
||||
int (*set)(struct git_config_backend *, const char *key, const char *value);
|
||||
int (*set_multivar)(git_config_backend *cfg, const char *name, const char *regexp, const char *value);
|
||||
int (*del)(struct git_config_backend *, const char *key);
|
||||
int (*foreach)(struct git_config_backend *, const char *, git_config_foreach_cb callback, void *payload);
|
||||
int (*refresh)(struct git_config_backend *);
|
||||
void (*free)(struct git_config_backend *);
|
||||
};
|
||||
|
||||
typedef enum {
|
||||
@ -87,11 +90,11 @@ typedef struct {
|
||||
* This method will not guess the path to the xdg compatible
|
||||
* config file (.config/git/config).
|
||||
*
|
||||
* @param global_config_path Buffer of GIT_PATH_MAX length to store the path
|
||||
* @return 0 if a global configuration file has been
|
||||
* found. Its path will be stored in `buffer`.
|
||||
* @param out Buffer to store the path in
|
||||
* @param length size of the buffer in bytes
|
||||
* @return 0 if a global configuration file has been found. Its path will be stored in `buffer`.
|
||||
*/
|
||||
GIT_EXTERN(int) git_config_find_global(char *global_config_path, size_t length);
|
||||
GIT_EXTERN(int) git_config_find_global(char *out, size_t length);
|
||||
|
||||
/**
|
||||
* Locate the path to the global xdg compatible configuration file
|
||||
@ -104,11 +107,12 @@ GIT_EXTERN(int) git_config_find_global(char *global_config_path, size_t length);
|
||||
* may be used on any `git_config` call to load the
|
||||
* xdg compatible configuration file.
|
||||
*
|
||||
* @param xdg_config_path Buffer of GIT_PATH_MAX length to store the path
|
||||
* @param out Buffer to store the path in
|
||||
* @param length size of the buffer in bytes
|
||||
* @return 0 if a xdg compatible configuration file has been
|
||||
* found. Its path will be stored in `buffer`.
|
||||
*/
|
||||
GIT_EXTERN(int) git_config_find_xdg(char *xdg_config_path, size_t length);
|
||||
GIT_EXTERN(int) git_config_find_xdg(char *out, size_t length);
|
||||
|
||||
/**
|
||||
* Locate the path to the system configuration file
|
||||
@ -116,11 +120,12 @@ GIT_EXTERN(int) git_config_find_xdg(char *xdg_config_path, size_t length);
|
||||
* If /etc/gitconfig doesn't exist, it will look for
|
||||
* %PROGRAMFILES%\Git\etc\gitconfig.
|
||||
|
||||
* @param system_config_path Buffer of GIT_PATH_MAX length to store the path
|
||||
* @param global_config_path Buffer to store the path in
|
||||
* @param length size of the buffer in bytes
|
||||
* @return 0 if a system configuration file has been
|
||||
* found. Its path will be stored in `buffer`.
|
||||
*/
|
||||
GIT_EXTERN(int) git_config_find_system(char *system_config_path, size_t length);
|
||||
GIT_EXTERN(int) git_config_find_system(char *out, size_t length);
|
||||
|
||||
/**
|
||||
* Open the global, XDG and system configuration files
|
||||
@ -163,9 +168,9 @@ GIT_EXTERN(int) git_config_new(git_config **out);
|
||||
* @return 0 on success, GIT_EEXISTS when adding more than one file
|
||||
* for a given priority level (and force_replace set to 0), or error code
|
||||
*/
|
||||
GIT_EXTERN(int) git_config_add_file(
|
||||
GIT_EXTERN(int) git_config_add_backend(
|
||||
git_config *cfg,
|
||||
git_config_file *file,
|
||||
git_config_backend *file,
|
||||
unsigned int level,
|
||||
int force);
|
||||
|
||||
@ -223,12 +228,15 @@ GIT_EXTERN(int) git_config_open_ondisk(git_config **out, const char *path);
|
||||
* will return different config instances, but containing the same config_file
|
||||
* instance.
|
||||
*
|
||||
* @param out The configuration instance to create
|
||||
* @param parent Multi-level config to search for the given level
|
||||
* @param level Configuration level to search for
|
||||
* @return 0, GIT_ENOTFOUND if the passed level cannot be found in the
|
||||
* multi-level parent config, or an error code
|
||||
*/
|
||||
GIT_EXTERN(int) git_config_open_level(
|
||||
git_config **cfg_out,
|
||||
git_config *cfg_parent,
|
||||
git_config **out,
|
||||
const git_config *parent,
|
||||
unsigned int level);
|
||||
|
||||
/**
|
||||
@ -262,7 +270,10 @@ GIT_EXTERN(void) git_config_free(git_config *cfg);
|
||||
* @param name the variable's name
|
||||
* @return 0 or an error code
|
||||
*/
|
||||
GIT_EXTERN(int) git_config_get_entry(const git_config_entry **out, git_config *cfg, const char *name);
|
||||
GIT_EXTERN(int) git_config_get_entry(
|
||||
const git_config_entry **out,
|
||||
const git_config *cfg,
|
||||
const char *name);
|
||||
|
||||
/**
|
||||
* Get the value of an integer config variable.
|
||||
@ -276,7 +287,7 @@ GIT_EXTERN(int) git_config_get_entry(const git_config_entry **out, git_config *c
|
||||
* @param name the variable's name
|
||||
* @return 0 or an error code
|
||||
*/
|
||||
GIT_EXTERN(int) git_config_get_int32(int32_t *out, git_config *cfg, const char *name);
|
||||
GIT_EXTERN(int) git_config_get_int32(int32_t *out, const git_config *cfg, const char *name);
|
||||
|
||||
/**
|
||||
* Get the value of a long integer config variable.
|
||||
@ -290,7 +301,7 @@ GIT_EXTERN(int) git_config_get_int32(int32_t *out, git_config *cfg, const char *
|
||||
* @param name the variable's name
|
||||
* @return 0 or an error code
|
||||
*/
|
||||
GIT_EXTERN(int) git_config_get_int64(int64_t *out, git_config *cfg, const char *name);
|
||||
GIT_EXTERN(int) git_config_get_int64(int64_t *out, const git_config *cfg, const char *name);
|
||||
|
||||
/**
|
||||
* Get the value of a boolean config variable.
|
||||
@ -307,7 +318,7 @@ GIT_EXTERN(int) git_config_get_int64(int64_t *out, git_config *cfg, const char *
|
||||
* @param name the variable's name
|
||||
* @return 0 or an error code
|
||||
*/
|
||||
GIT_EXTERN(int) git_config_get_bool(int *out, git_config *cfg, const char *name);
|
||||
GIT_EXTERN(int) git_config_get_bool(int *out, const git_config *cfg, const char *name);
|
||||
|
||||
/**
|
||||
* Get the value of a string config variable.
|
||||
@ -324,7 +335,7 @@ GIT_EXTERN(int) git_config_get_bool(int *out, git_config *cfg, const char *name)
|
||||
* @param name the variable's name
|
||||
* @return 0 or an error code
|
||||
*/
|
||||
GIT_EXTERN(int) git_config_get_string(const char **out, git_config *cfg, const char *name);
|
||||
GIT_EXTERN(int) git_config_get_string(const char **out, const git_config *cfg, const char *name);
|
||||
|
||||
/**
|
||||
* Get each value of a multivar.
|
||||
@ -338,7 +349,7 @@ GIT_EXTERN(int) git_config_get_string(const char **out, git_config *cfg, const c
|
||||
* @param fn the function to be called on each value of the variable
|
||||
* @param data opaque pointer to pass to the callback
|
||||
*/
|
||||
GIT_EXTERN(int) git_config_get_multivar(git_config *cfg, const char *name, const char *regexp, int (*fn)(const git_config_entry *, void *), void *data);
|
||||
GIT_EXTERN(int) git_config_get_multivar(const git_config *cfg, const char *name, const char *regexp, git_config_foreach_cb callback, void *payload);
|
||||
|
||||
/**
|
||||
* Set the value of an integer config variable in the config file
|
||||
@ -404,7 +415,7 @@ GIT_EXTERN(int) git_config_set_multivar(git_config *cfg, const char *name, const
|
||||
* @param cfg the configuration
|
||||
* @param name the variable to delete
|
||||
*/
|
||||
GIT_EXTERN(int) git_config_delete(git_config *cfg, const char *name);
|
||||
GIT_EXTERN(int) git_config_delete_entry(git_config *cfg, const char *name);
|
||||
|
||||
/**
|
||||
* Perform an operation on each config variable.
|
||||
@ -420,8 +431,8 @@ GIT_EXTERN(int) git_config_delete(git_config *cfg, const char *name);
|
||||
* @return 0 on success, GIT_EUSER on non-zero callback, or error code
|
||||
*/
|
||||
GIT_EXTERN(int) git_config_foreach(
|
||||
git_config *cfg,
|
||||
int (*callback)(const git_config_entry *, void *payload),
|
||||
const git_config *cfg,
|
||||
git_config_foreach_cb callback,
|
||||
void *payload);
|
||||
|
||||
/**
|
||||
@ -438,9 +449,9 @@ GIT_EXTERN(int) git_config_foreach(
|
||||
* @return 0 or the return value of the callback which didn't return 0
|
||||
*/
|
||||
GIT_EXTERN(int) git_config_foreach_match(
|
||||
git_config *cfg,
|
||||
const git_config *cfg,
|
||||
const char *regexp,
|
||||
int (*callback)(const git_config_entry *entry, void *payload),
|
||||
git_config_foreach_cb callback,
|
||||
void *payload);
|
||||
|
||||
/**
|
||||
@ -477,7 +488,12 @@ GIT_EXTERN(int) git_config_foreach_match(
|
||||
* @param map_n number of mapping objects in `maps`
|
||||
* @return 0 on success, error code otherwise
|
||||
*/
|
||||
GIT_EXTERN(int) git_config_get_mapped(int *out, git_config *cfg, const char *name, git_cvar_map *maps, size_t map_n);
|
||||
GIT_EXTERN(int) git_config_get_mapped(
|
||||
int *out,
|
||||
const git_config *cfg,
|
||||
const char *name,
|
||||
const git_cvar_map *maps,
|
||||
size_t map_n);
|
||||
|
||||
/**
|
||||
* Maps a string value to an integer constant
|
||||
@ -489,7 +505,7 @@ GIT_EXTERN(int) git_config_get_mapped(int *out, git_config *cfg, const char *nam
|
||||
*/
|
||||
GIT_EXTERN(int) git_config_lookup_map_value(
|
||||
int *out,
|
||||
git_cvar_map *maps,
|
||||
const git_cvar_map *maps,
|
||||
size_t map_n,
|
||||
const char *value);
|
||||
|
||||
@ -505,18 +521,6 @@ GIT_EXTERN(int) git_config_lookup_map_value(
|
||||
*/
|
||||
GIT_EXTERN(int) git_config_parse_bool(int *out, const char *value);
|
||||
|
||||
/**
|
||||
* Parse a string value as an int64.
|
||||
*
|
||||
* An optional value suffix of 'k', 'm', or 'g' will
|
||||
* cause the value to be multiplied by 1024, 1048576,
|
||||
* or 1073741824 prior to output.
|
||||
*
|
||||
* @param out place to store the result of the parsing
|
||||
* @param value value to parse
|
||||
*/
|
||||
GIT_EXTERN(int) git_config_parse_int64(int64_t *out, const char *value);
|
||||
|
||||
/**
|
||||
* Parse a string value as an int32.
|
||||
*
|
||||
@ -529,6 +533,18 @@ GIT_EXTERN(int) git_config_parse_int64(int64_t *out, const char *value);
|
||||
*/
|
||||
GIT_EXTERN(int) git_config_parse_int32(int32_t *out, const char *value);
|
||||
|
||||
/**
|
||||
* Parse a string value as an int64.
|
||||
*
|
||||
* An optional value suffix of 'k', 'm', or 'g' will
|
||||
* cause the value to be multiplied by 1024, 1048576,
|
||||
* or 1073741824 prior to output.
|
||||
*
|
||||
* @param out place to store the result of the parsing
|
||||
* @param value value to parse
|
||||
*/
|
||||
GIT_EXTERN(int) git_config_parse_int64(int64_t *out, const char *value);
|
||||
|
||||
|
||||
/** @} */
|
||||
GIT_END_DECL
|
||||
|
@ -129,7 +129,7 @@ typedef struct git_index git_index;
|
||||
typedef struct git_config git_config;
|
||||
|
||||
/** Interface to access a configuration file */
|
||||
typedef struct git_config_file git_config_file;
|
||||
typedef struct git_config_backend git_config_backend;
|
||||
|
||||
/** Representation of a reference log entry */
|
||||
typedef struct git_reflog_entry git_reflog_entry;
|
||||
|
74
src/config.c
74
src/config.c
@ -19,13 +19,13 @@
|
||||
typedef struct {
|
||||
git_refcount rc;
|
||||
|
||||
git_config_file *file;
|
||||
git_config_backend *file;
|
||||
unsigned int level;
|
||||
} file_internal;
|
||||
|
||||
static void file_internal_free(file_internal *internal)
|
||||
{
|
||||
git_config_file *file;
|
||||
git_config_backend *file;
|
||||
|
||||
file = internal->file;
|
||||
file->free(file);
|
||||
@ -87,7 +87,7 @@ int git_config_add_file_ondisk(
|
||||
unsigned int level,
|
||||
int force)
|
||||
{
|
||||
git_config_file *file = NULL;
|
||||
git_config_backend *file = NULL;
|
||||
int res;
|
||||
|
||||
assert(cfg && path);
|
||||
@ -100,7 +100,7 @@ int git_config_add_file_ondisk(
|
||||
if (git_config_file__ondisk(&file, path) < 0)
|
||||
return -1;
|
||||
|
||||
if ((res = git_config_add_file(cfg, file, level, force)) < 0) {
|
||||
if ((res = git_config_add_backend(cfg, file, level, force)) < 0) {
|
||||
/*
|
||||
* free manually; the file is not owned by the config
|
||||
* instance yet and will not be freed on cleanup
|
||||
@ -132,7 +132,7 @@ int git_config_open_ondisk(git_config **out, const char *path)
|
||||
|
||||
static int find_internal_file_by_level(
|
||||
file_internal **internal_out,
|
||||
git_config *cfg,
|
||||
const git_config *cfg,
|
||||
int level)
|
||||
{
|
||||
int pos = -1;
|
||||
@ -224,7 +224,7 @@ static int git_config__add_internal(
|
||||
|
||||
int git_config_open_level(
|
||||
git_config **cfg_out,
|
||||
git_config *cfg_parent,
|
||||
const git_config *cfg_parent,
|
||||
unsigned int level)
|
||||
{
|
||||
git_config *cfg;
|
||||
@ -247,9 +247,9 @@ int git_config_open_level(
|
||||
return 0;
|
||||
}
|
||||
|
||||
int git_config_add_file(
|
||||
int git_config_add_backend(
|
||||
git_config *cfg,
|
||||
git_config_file *file,
|
||||
git_config_backend *file,
|
||||
unsigned int level,
|
||||
int force)
|
||||
{
|
||||
@ -284,7 +284,7 @@ int git_config_refresh(git_config *cfg)
|
||||
|
||||
for (i = 0; i < cfg->files.length && !error; ++i) {
|
||||
file_internal *internal = git_vector_get(&cfg->files, i);
|
||||
git_config_file *file = internal->file;
|
||||
git_config_backend *file = internal->file;
|
||||
error = file->refresh(file);
|
||||
}
|
||||
|
||||
@ -296,34 +296,34 @@ int git_config_refresh(git_config *cfg)
|
||||
*/
|
||||
|
||||
int git_config_foreach(
|
||||
git_config *cfg, int (*fn)(const git_config_entry *, void *), void *data)
|
||||
const git_config *cfg, git_config_foreach_cb cb, void *payload)
|
||||
{
|
||||
return git_config_foreach_match(cfg, NULL, fn, data);
|
||||
return git_config_foreach_match(cfg, NULL, cb, payload);
|
||||
}
|
||||
|
||||
int git_config_foreach_match(
|
||||
git_config *cfg,
|
||||
const git_config *cfg,
|
||||
const char *regexp,
|
||||
int (*fn)(const git_config_entry *, void *),
|
||||
void *data)
|
||||
git_config_foreach_cb cb,
|
||||
void *payload)
|
||||
{
|
||||
int ret = 0;
|
||||
unsigned int i;
|
||||
file_internal *internal;
|
||||
git_config_file *file;
|
||||
git_config_backend *file;
|
||||
|
||||
for (i = 0; i < cfg->files.length && ret == 0; ++i) {
|
||||
internal = git_vector_get(&cfg->files, i);
|
||||
file = internal->file;
|
||||
ret = file->foreach(file, regexp, fn, data);
|
||||
ret = file->foreach(file, regexp, cb, payload);
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
int git_config_delete(git_config *cfg, const char *name)
|
||||
int git_config_delete_entry(git_config *cfg, const char *name)
|
||||
{
|
||||
git_config_file *file;
|
||||
git_config_backend *file;
|
||||
file_internal *internal;
|
||||
|
||||
internal = git_vector_get(&cfg->files, 0);
|
||||
@ -355,7 +355,7 @@ int git_config_set_bool(git_config *cfg, const char *name, int value)
|
||||
|
||||
int git_config_set_string(git_config *cfg, const char *name, const char *value)
|
||||
{
|
||||
git_config_file *file;
|
||||
git_config_backend *file;
|
||||
file_internal *internal;
|
||||
|
||||
internal = git_vector_get(&cfg->files, 0);
|
||||
@ -369,9 +369,9 @@ int git_config_set_string(git_config *cfg, const char *name, const char *value)
|
||||
***********/
|
||||
int git_config_get_mapped(
|
||||
int *out,
|
||||
git_config *cfg,
|
||||
const git_config *cfg,
|
||||
const char *name,
|
||||
git_cvar_map *maps,
|
||||
const git_cvar_map *maps,
|
||||
size_t map_n)
|
||||
{
|
||||
const char *value;
|
||||
@ -383,7 +383,7 @@ int git_config_get_mapped(
|
||||
return git_config_lookup_map_value(out, maps, map_n, value);
|
||||
}
|
||||
|
||||
int git_config_get_int64(int64_t *out, git_config *cfg, const char *name)
|
||||
int git_config_get_int64(int64_t *out, const git_config *cfg, const char *name)
|
||||
{
|
||||
const char *value;
|
||||
int ret;
|
||||
@ -394,7 +394,7 @@ int git_config_get_int64(int64_t *out, git_config *cfg, const char *name)
|
||||
return git_config_parse_int64(out, value);
|
||||
}
|
||||
|
||||
int git_config_get_int32(int32_t *out, git_config *cfg, const char *name)
|
||||
int git_config_get_int32(int32_t *out, const git_config *cfg, const char *name)
|
||||
{
|
||||
const char *value;
|
||||
int ret;
|
||||
@ -405,7 +405,7 @@ int git_config_get_int32(int32_t *out, git_config *cfg, const char *name)
|
||||
return git_config_parse_int32(out, value);
|
||||
}
|
||||
|
||||
static int get_string_at_file(const char **out, git_config_file *file, const char *name)
|
||||
static int get_string_at_file(const char **out, const git_config_backend *file, const char *name)
|
||||
{
|
||||
const git_config_entry *entry;
|
||||
int res;
|
||||
@ -417,7 +417,7 @@ static int get_string_at_file(const char **out, git_config_file *file, const cha
|
||||
return res;
|
||||
}
|
||||
|
||||
static int get_string(const char **out, git_config *cfg, const char *name)
|
||||
static int get_string(const char **out, const git_config *cfg, const char *name)
|
||||
{
|
||||
file_internal *internal;
|
||||
unsigned int i;
|
||||
@ -434,7 +434,7 @@ static int get_string(const char **out, git_config *cfg, const char *name)
|
||||
return GIT_ENOTFOUND;
|
||||
}
|
||||
|
||||
int git_config_get_bool(int *out, git_config *cfg, const char *name)
|
||||
int git_config_get_bool(int *out, const git_config *cfg, const char *name)
|
||||
{
|
||||
const char *value = NULL;
|
||||
int ret;
|
||||
@ -445,7 +445,7 @@ int git_config_get_bool(int *out, git_config *cfg, const char *name)
|
||||
return git_config_parse_bool(out, value);
|
||||
}
|
||||
|
||||
int git_config_get_string(const char **out, git_config *cfg, const char *name)
|
||||
int git_config_get_string(const char **out, const git_config *cfg, const char *name)
|
||||
{
|
||||
int ret;
|
||||
const char *str = NULL;
|
||||
@ -457,7 +457,7 @@ int git_config_get_string(const char **out, git_config *cfg, const char *name)
|
||||
return 0;
|
||||
}
|
||||
|
||||
int git_config_get_entry(const git_config_entry **out, git_config *cfg, const char *name)
|
||||
int git_config_get_entry(const git_config_entry **out, const git_config *cfg, const char *name)
|
||||
{
|
||||
file_internal *internal;
|
||||
unsigned int i;
|
||||
@ -467,7 +467,7 @@ int git_config_get_entry(const git_config_entry **out, git_config *cfg, const ch
|
||||
*out = NULL;
|
||||
|
||||
git_vector_foreach(&cfg->files, i, internal) {
|
||||
git_config_file *file = internal->file;
|
||||
git_config_backend *file = internal->file;
|
||||
int ret = file->get(file, name, out);
|
||||
if (ret != GIT_ENOTFOUND)
|
||||
return ret;
|
||||
@ -476,11 +476,11 @@ int git_config_get_entry(const git_config_entry **out, git_config *cfg, const ch
|
||||
return GIT_ENOTFOUND;
|
||||
}
|
||||
|
||||
int git_config_get_multivar(git_config *cfg, const char *name, const char *regexp,
|
||||
int (*fn)(const git_config_entry *entry, void *data), void *data)
|
||||
int git_config_get_multivar(const git_config *cfg, const char *name, const char *regexp,
|
||||
git_config_foreach_cb cb, void *payload)
|
||||
{
|
||||
file_internal *internal;
|
||||
git_config_file *file;
|
||||
git_config_backend *file;
|
||||
int ret = GIT_ENOTFOUND;
|
||||
size_t i;
|
||||
|
||||
@ -493,7 +493,7 @@ int git_config_get_multivar(git_config *cfg, const char *name, const char *regex
|
||||
for (i = cfg->files.length; i > 0; --i) {
|
||||
internal = git_vector_get(&cfg->files, i - 1);
|
||||
file = internal->file;
|
||||
ret = file->get_multivar(file, name, regexp, fn, data);
|
||||
ret = file->get_multivar(file, name, regexp, cb, payload);
|
||||
if (ret < 0 && ret != GIT_ENOTFOUND)
|
||||
return ret;
|
||||
}
|
||||
@ -503,7 +503,7 @@ int git_config_get_multivar(git_config *cfg, const char *name, const char *regex
|
||||
|
||||
int git_config_set_multivar(git_config *cfg, const char *name, const char *regexp, const char *value)
|
||||
{
|
||||
git_config_file *file;
|
||||
git_config_backend *file;
|
||||
file_internal *internal;
|
||||
|
||||
internal = git_vector_get(&cfg->files, 0);
|
||||
@ -634,7 +634,7 @@ int git_config_open_default(git_config **out)
|
||||
***********/
|
||||
int git_config_lookup_map_value(
|
||||
int *out,
|
||||
git_cvar_map *maps,
|
||||
const git_cvar_map *maps,
|
||||
size_t map_n,
|
||||
const char *value)
|
||||
{
|
||||
@ -644,7 +644,7 @@ int git_config_lookup_map_value(
|
||||
goto fail_parse;
|
||||
|
||||
for (i = 0; i < map_n; ++i) {
|
||||
git_cvar_map *m = maps + i;
|
||||
const git_cvar_map *m = maps + i;
|
||||
|
||||
switch (m->cvar_type) {
|
||||
case GIT_CVAR_FALSE:
|
||||
@ -790,7 +790,7 @@ static int rename_config_entries_cb(
|
||||
return error;
|
||||
}
|
||||
|
||||
return git_config_delete(data->config, entry->name);
|
||||
return git_config_delete_entry(data->config, entry->name);
|
||||
}
|
||||
|
||||
int git_config_rename_section(
|
||||
|
@ -43,6 +43,6 @@ extern int git_config_rename_section(
|
||||
* @param out the new backend
|
||||
* @param path where the config file is located
|
||||
*/
|
||||
extern int git_config_file__ondisk(struct git_config_file **out, const char *path);
|
||||
extern int git_config_file__ondisk(struct git_config_backend **out, const char *path);
|
||||
|
||||
#endif
|
||||
|
@ -64,7 +64,7 @@ typedef struct cvar_t {
|
||||
(iter) = (tmp))
|
||||
|
||||
typedef struct {
|
||||
git_config_file parent;
|
||||
git_config_backend parent;
|
||||
|
||||
git_strmap *values;
|
||||
|
||||
@ -149,7 +149,7 @@ static void free_vars(git_strmap *values)
|
||||
git_strmap_free(values);
|
||||
}
|
||||
|
||||
static int config_open(git_config_file *cfg, unsigned int level)
|
||||
static int config_open(git_config_backend *cfg, unsigned int level)
|
||||
{
|
||||
int res;
|
||||
diskfile_backend *b = (diskfile_backend *)cfg;
|
||||
@ -176,7 +176,7 @@ static int config_open(git_config_file *cfg, unsigned int level)
|
||||
return res;
|
||||
}
|
||||
|
||||
static int config_refresh(git_config_file *cfg)
|
||||
static int config_refresh(git_config_backend *cfg)
|
||||
{
|
||||
int res, updated = 0;
|
||||
diskfile_backend *b = (diskfile_backend *)cfg;
|
||||
@ -203,7 +203,7 @@ static int config_refresh(git_config_file *cfg)
|
||||
return res;
|
||||
}
|
||||
|
||||
static void backend_free(git_config_file *_backend)
|
||||
static void backend_free(git_config_backend *_backend)
|
||||
{
|
||||
diskfile_backend *backend = (diskfile_backend *)_backend;
|
||||
|
||||
@ -216,7 +216,7 @@ static void backend_free(git_config_file *_backend)
|
||||
}
|
||||
|
||||
static int file_foreach(
|
||||
git_config_file *backend,
|
||||
git_config_backend *backend,
|
||||
const char *regexp,
|
||||
int (*fn)(const git_config_entry *, void *),
|
||||
void *data)
|
||||
@ -262,7 +262,7 @@ cleanup:
|
||||
return result;
|
||||
}
|
||||
|
||||
static int config_set(git_config_file *cfg, const char *name, const char *value)
|
||||
static int config_set(git_config_backend *cfg, const char *name, const char *value)
|
||||
{
|
||||
cvar_t *var = NULL, *old_var;
|
||||
diskfile_backend *b = (diskfile_backend *)cfg;
|
||||
@ -346,7 +346,7 @@ static int config_set(git_config_file *cfg, const char *name, const char *value)
|
||||
/*
|
||||
* Internal function that actually gets the value in string form
|
||||
*/
|
||||
static int config_get(git_config_file *cfg, const char *name, const git_config_entry **out)
|
||||
static int config_get(const git_config_backend *cfg, const char *name, const git_config_entry **out)
|
||||
{
|
||||
diskfile_backend *b = (diskfile_backend *)cfg;
|
||||
char *key;
|
||||
@ -368,7 +368,7 @@ static int config_get(git_config_file *cfg, const char *name, const git_config_e
|
||||
}
|
||||
|
||||
static int config_get_multivar(
|
||||
git_config_file *cfg,
|
||||
git_config_backend *cfg,
|
||||
const char *name,
|
||||
const char *regex_str,
|
||||
int (*fn)(const git_config_entry *, void *),
|
||||
@ -431,7 +431,7 @@ static int config_get_multivar(
|
||||
}
|
||||
|
||||
static int config_set_multivar(
|
||||
git_config_file *cfg, const char *name, const char *regexp, const char *value)
|
||||
git_config_backend *cfg, const char *name, const char *regexp, const char *value)
|
||||
{
|
||||
int replaced = 0;
|
||||
cvar_t *var, *newvar;
|
||||
@ -506,7 +506,7 @@ static int config_set_multivar(
|
||||
return result;
|
||||
}
|
||||
|
||||
static int config_delete(git_config_file *cfg, const char *name)
|
||||
static int config_delete(git_config_backend *cfg, const char *name)
|
||||
{
|
||||
cvar_t *var;
|
||||
diskfile_backend *b = (diskfile_backend *)cfg;
|
||||
@ -540,7 +540,7 @@ static int config_delete(git_config_file *cfg, const char *name)
|
||||
return result;
|
||||
}
|
||||
|
||||
int git_config_file__ondisk(git_config_file **out, const char *path)
|
||||
int git_config_file__ondisk(git_config_backend **out, const char *path)
|
||||
{
|
||||
diskfile_backend *backend;
|
||||
|
||||
@ -562,7 +562,7 @@ int git_config_file__ondisk(git_config_file **out, const char *path)
|
||||
backend->parent.refresh = config_refresh;
|
||||
backend->parent.free = backend_free;
|
||||
|
||||
*out = (git_config_file *)backend;
|
||||
*out = (git_config_backend *)backend;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -9,36 +9,36 @@
|
||||
|
||||
#include "git2/config.h"
|
||||
|
||||
GIT_INLINE(int) git_config_file_open(git_config_file *cfg, unsigned int level)
|
||||
GIT_INLINE(int) git_config_file_open(git_config_backend *cfg, unsigned int level)
|
||||
{
|
||||
return cfg->open(cfg, level);
|
||||
}
|
||||
|
||||
GIT_INLINE(void) git_config_file_free(git_config_file *cfg)
|
||||
GIT_INLINE(void) git_config_file_free(git_config_backend *cfg)
|
||||
{
|
||||
cfg->free(cfg);
|
||||
}
|
||||
|
||||
GIT_INLINE(int) git_config_file_get_string(
|
||||
const git_config_entry **out, git_config_file *cfg, const char *name)
|
||||
const git_config_entry **out, git_config_backend *cfg, const char *name)
|
||||
{
|
||||
return cfg->get(cfg, name, out);
|
||||
}
|
||||
|
||||
GIT_INLINE(int) git_config_file_set_string(
|
||||
git_config_file *cfg, const char *name, const char *value)
|
||||
git_config_backend *cfg, const char *name, const char *value)
|
||||
{
|
||||
return cfg->set(cfg, name, value);
|
||||
}
|
||||
|
||||
GIT_INLINE(int) git_config_file_delete(
|
||||
git_config_file *cfg, const char *name)
|
||||
git_config_backend *cfg, const char *name)
|
||||
{
|
||||
return cfg->del(cfg, name);
|
||||
}
|
||||
|
||||
GIT_INLINE(int) git_config_file_foreach(
|
||||
git_config_file *cfg,
|
||||
git_config_backend *cfg,
|
||||
int (*fn)(const git_config_entry *entry, void *data),
|
||||
void *data)
|
||||
{
|
||||
@ -46,7 +46,7 @@ GIT_INLINE(int) git_config_file_foreach(
|
||||
}
|
||||
|
||||
GIT_INLINE(int) git_config_file_foreach_match(
|
||||
git_config_file *cfg,
|
||||
git_config_backend *cfg,
|
||||
const char *regexp,
|
||||
int (*fn)(const git_config_entry *entry, void *data),
|
||||
void *data)
|
||||
|
@ -303,7 +303,7 @@ int git_remote_save(const git_remote *remote)
|
||||
return -1;
|
||||
}
|
||||
} else {
|
||||
int error = git_config_delete(config, git_buf_cstr(&buf));
|
||||
int error = git_config_delete_entry(config, git_buf_cstr(&buf));
|
||||
if (error == GIT_ENOTFOUND) {
|
||||
error = 0;
|
||||
giterr_clear();
|
||||
@ -356,7 +356,7 @@ int git_remote_save(const git_remote *remote)
|
||||
if (git_config_set_string(config, git_buf_cstr(&buf), "--no-tags") < 0)
|
||||
goto on_error;
|
||||
} else if (tagopt) {
|
||||
if (git_config_delete(config, git_buf_cstr(&buf)) < 0)
|
||||
if (git_config_delete_entry(config, git_buf_cstr(&buf)) < 0)
|
||||
goto on_error;
|
||||
}
|
||||
|
||||
|
@ -824,7 +824,7 @@ static int repo_init_config(
|
||||
SET_REPO_CONFIG(string, "core.worktree", work_dir);
|
||||
}
|
||||
else if ((opts->flags & GIT_REPOSITORY_INIT__IS_REINIT) != 0) {
|
||||
if (git_config_delete(config, "core.worktree") < 0)
|
||||
if (git_config_delete_entry(config, "core.worktree") < 0)
|
||||
giterr_clear();
|
||||
}
|
||||
} else {
|
||||
@ -1356,7 +1356,7 @@ int git_repository_set_workdir(
|
||||
|
||||
/* passthrough error means gitlink is unnecessary */
|
||||
if (error == GIT_PASSTHROUGH)
|
||||
error = git_config_delete(config, "core.worktree");
|
||||
error = git_config_delete_entry(config, "core.worktree");
|
||||
else if (!error)
|
||||
error = git_config_set_string(config, "core.worktree", path.ptr);
|
||||
|
||||
|
@ -66,7 +66,7 @@ __KHASH_IMPL(
|
||||
str_hash_no_trailing_slash, str_equal_no_trailing_slash);
|
||||
|
||||
static int load_submodule_config(git_repository *repo, bool force);
|
||||
static git_config_file *open_gitmodules(git_repository *, bool, const git_oid *);
|
||||
static git_config_backend *open_gitmodules(git_repository *, bool, const git_oid *);
|
||||
static int lookup_head_remote(git_buf *url, git_repository *repo);
|
||||
static int submodule_get(git_submodule **, git_repository *, const char *, const char *);
|
||||
static void submodule_release(git_submodule *sm, int decr);
|
||||
@ -201,7 +201,7 @@ int git_submodule_add_setup(
|
||||
int use_gitlink)
|
||||
{
|
||||
int error = 0;
|
||||
git_config_file *mods = NULL;
|
||||
git_config_backend *mods = NULL;
|
||||
git_submodule *sm;
|
||||
git_buf name = GIT_BUF_INIT, real_url = GIT_BUF_INIT;
|
||||
git_repository_init_options initopt;
|
||||
@ -412,7 +412,7 @@ cleanup:
|
||||
int git_submodule_save(git_submodule *submodule)
|
||||
{
|
||||
int error = 0;
|
||||
git_config_file *mods;
|
||||
git_config_backend *mods;
|
||||
git_buf key = GIT_BUF_INIT;
|
||||
|
||||
assert(submodule);
|
||||
@ -717,7 +717,7 @@ int git_submodule_reload(git_submodule *submodule)
|
||||
git_index *index;
|
||||
int pos, error;
|
||||
git_tree *head;
|
||||
git_config_file *mods;
|
||||
git_config_backend *mods;
|
||||
|
||||
assert(submodule);
|
||||
|
||||
@ -1187,14 +1187,14 @@ static int load_submodule_config_from_head(
|
||||
return error;
|
||||
}
|
||||
|
||||
static git_config_file *open_gitmodules(
|
||||
static git_config_backend *open_gitmodules(
|
||||
git_repository *repo,
|
||||
bool okay_to_create,
|
||||
const git_oid *gitmodules_oid)
|
||||
{
|
||||
const char *workdir = git_repository_workdir(repo);
|
||||
git_buf path = GIT_BUF_INIT;
|
||||
git_config_file *mods = NULL;
|
||||
git_config_backend *mods = NULL;
|
||||
|
||||
if (workdir != NULL) {
|
||||
if (git_buf_joinpath(&path, workdir, GIT_MODULES_FILE) != 0)
|
||||
@ -1230,7 +1230,7 @@ static int load_submodule_config(git_repository *repo, bool force)
|
||||
int error;
|
||||
git_oid gitmodules_oid;
|
||||
git_buf path = GIT_BUF_INIT;
|
||||
git_config_file *mods = NULL;
|
||||
git_config_backend *mods = NULL;
|
||||
|
||||
if (repo->submodules && !force)
|
||||
return 0;
|
||||
@ -1378,7 +1378,7 @@ static int submodule_update_config(
|
||||
goto cleanup;
|
||||
|
||||
if (!value)
|
||||
error = git_config_delete(config, key.ptr);
|
||||
error = git_config_delete_entry(config, key.ptr);
|
||||
else
|
||||
error = git_config_set_string(config, key.ptr, value);
|
||||
|
||||
|
@ -55,7 +55,7 @@ GIT_INLINE(int) git_vector_bsearch2(
|
||||
return git_vector_bsearch3(NULL, v, cmp, key);
|
||||
}
|
||||
|
||||
GIT_INLINE(void *) git_vector_get(git_vector *v, size_t position)
|
||||
GIT_INLINE(void *) git_vector_get(const git_vector *v, size_t position)
|
||||
{
|
||||
return (position < v->length) ? v->contents[position] : NULL;
|
||||
}
|
||||
|
@ -537,7 +537,7 @@ int p_inet_pton(int af, const char* src, void* dst)
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (WSAStringToAddress(src, af, NULL, (struct sockaddr *) &sa, &srcsize) != 0)
|
||||
if (WSAStringToAddress((LPSTR)src, af, NULL, (struct sockaddr *) &sa, &srcsize) != 0)
|
||||
{
|
||||
errno = WSAGetLastError();
|
||||
return -1;
|
||||
|
@ -19,7 +19,7 @@ void test_config_add__to_existing_section(void)
|
||||
cl_git_pass(git_config_set_int32(cfg, "empty.tmp", 5));
|
||||
cl_git_pass(git_config_get_int32(&i, cfg, "empty.tmp"));
|
||||
cl_assert(i == 5);
|
||||
cl_git_pass(git_config_delete(cfg, "empty.tmp"));
|
||||
cl_git_pass(git_config_delete_entry(cfg, "empty.tmp"));
|
||||
git_config_free(cfg);
|
||||
}
|
||||
|
||||
@ -32,6 +32,6 @@ void test_config_add__to_new_section(void)
|
||||
cl_git_pass(git_config_set_int32(cfg, "section.tmp", 5));
|
||||
cl_git_pass(git_config_get_int32(&i, cfg, "section.tmp"));
|
||||
cl_assert(i == 5);
|
||||
cl_git_pass(git_config_delete(cfg, "section.tmp"));
|
||||
cl_git_pass(git_config_delete_entry(cfg, "section.tmp"));
|
||||
git_config_free(cfg);
|
||||
}
|
||||
|
@ -62,7 +62,7 @@ void test_config_write__delete_value(void)
|
||||
git_config_free(cfg);
|
||||
|
||||
cl_git_pass(git_config_open_ondisk(&cfg, "config9"));
|
||||
cl_git_pass(git_config_delete(cfg, "core.dummy"));
|
||||
cl_git_pass(git_config_delete_entry(cfg, "core.dummy"));
|
||||
git_config_free(cfg);
|
||||
|
||||
cl_git_pass(git_config_open_ondisk(&cfg, "config9"));
|
||||
@ -94,7 +94,7 @@ void test_config_write__delete_value_at_specific_level(void)
|
||||
|
||||
cl_git_pass(git_config_open_level(&cfg_specific, cfg, GIT_CONFIG_LEVEL_GLOBAL));
|
||||
|
||||
cl_git_pass(git_config_delete(cfg_specific, "core.dummy2"));
|
||||
cl_git_pass(git_config_delete_entry(cfg_specific, "core.dummy2"));
|
||||
git_config_free(cfg);
|
||||
|
||||
cl_git_pass(git_config_open_ondisk(&cfg, "config15"));
|
||||
@ -125,7 +125,7 @@ void test_config_write__delete_inexistent(void)
|
||||
git_config *cfg;
|
||||
|
||||
cl_git_pass(git_config_open_ondisk(&cfg, "config9"));
|
||||
cl_assert(git_config_delete(cfg, "core.imaginary") == GIT_ENOTFOUND);
|
||||
cl_assert(git_config_delete_entry(cfg, "core.imaginary") == GIT_ENOTFOUND);
|
||||
git_config_free(cfg);
|
||||
}
|
||||
|
||||
|
@ -64,7 +64,7 @@ void test_network_remoterename__renaming_a_remote_without_a_fetchrefspec_doesnt_
|
||||
|
||||
git_remote_free(_remote);
|
||||
cl_git_pass(git_repository_config__weakptr(&config, _repo));
|
||||
cl_git_pass(git_config_delete(config, "remote.test.fetch"));
|
||||
cl_git_pass(git_config_delete_entry(config, "remote.test.fetch"));
|
||||
|
||||
cl_git_pass(git_remote_load(&_remote, _repo, "test"));
|
||||
|
||||
|
@ -57,7 +57,7 @@ void test_notes_notesref__config_corenotesref(void)
|
||||
cl_git_pass(git_note_default_ref(&default_ref, _repo));
|
||||
cl_assert(!strcmp(default_ref, "refs/notes/mydefaultnotesref"));
|
||||
|
||||
cl_git_pass(git_config_delete(_cfg, "core.notesRef"));
|
||||
cl_git_pass(git_config_delete_entry(_cfg, "core.notesRef"));
|
||||
|
||||
cl_git_pass(git_note_default_ref(&default_ref, _repo));
|
||||
cl_assert(!strcmp(default_ref, GIT_NOTES_DEFAULT_REF));
|
||||
|
@ -76,7 +76,7 @@ void test_submodule_modify__add(void)
|
||||
static int delete_one_config(const git_config_entry *entry, void *payload)
|
||||
{
|
||||
git_config *cfg = payload;
|
||||
return git_config_delete(cfg, entry->name);
|
||||
return git_config_delete_entry(cfg, entry->name);
|
||||
}
|
||||
|
||||
static int init_one_submodule(
|
||||
|
Loading…
Reference in New Issue
Block a user