Commit 2d1f6676 by Patrick Steinhardt

config_file: rename cvar_t struct to config_entry_list

The `cvar_t` structure is really awkward to grasp, because its name
actively hinders discovery of what it actually is. As it is nothing more
than a singly-linked list of configuration entries, name rename it to
just that: `config_entry_list`.
parent 26cf48fc
...@@ -23,15 +23,15 @@ ...@@ -23,15 +23,15 @@
#include <sys/types.h> #include <sys/types.h>
#include <regex.h> #include <regex.h>
typedef struct cvar_t { typedef struct config_entry_list {
struct cvar_t *next; struct config_entry_list *next;
git_config_entry *entry; git_config_entry *entry;
} cvar_t; } config_entry_list;
typedef struct git_config_file_iter { typedef struct git_config_file_iter {
git_config_iterator parent; git_config_iterator parent;
git_strmap_iter iter; git_strmap_iter iter;
cvar_t* next_var; config_entry_list* next_var;
} git_config_file_iter; } git_config_file_iter;
/* Max depth for [include] directives */ /* Max depth for [include] directives */
...@@ -82,7 +82,7 @@ static int config_error_readonly(void) ...@@ -82,7 +82,7 @@ static int config_error_readonly(void)
return -1; return -1;
} }
static void cvar_free(cvar_t *var) static void cvar_free(config_entry_list *var)
{ {
if (var == NULL) if (var == NULL)
return; return;
...@@ -120,10 +120,10 @@ int git_config_file_normalize_section(char *start, char *end) ...@@ -120,10 +120,10 @@ int git_config_file_normalize_section(char *start, char *end)
static int append_entry(git_strmap *values, git_config_entry *entry) static int append_entry(git_strmap *values, git_config_entry *entry)
{ {
git_strmap_iter pos; git_strmap_iter pos;
cvar_t *existing, *var; config_entry_list *existing, *var;
int error = 0; int error = 0;
var = git__calloc(1, sizeof(cvar_t)); var = git__calloc(1, sizeof(config_entry_list));
GITERR_CHECK_ALLOC(var); GITERR_CHECK_ALLOC(var);
var->entry = entry; var->entry = entry;
...@@ -146,14 +146,14 @@ static int append_entry(git_strmap *values, git_config_entry *entry) ...@@ -146,14 +146,14 @@ static int append_entry(git_strmap *values, git_config_entry *entry)
static void free_vars(git_strmap *values) static void free_vars(git_strmap *values)
{ {
cvar_t *var = NULL; config_entry_list *var = NULL;
if (values == NULL) if (values == NULL)
return; return;
git_strmap_foreach_value(values, var, git_strmap_foreach_value(values, var,
while (var != NULL) { while (var != NULL) {
cvar_t *next = var->next; config_entry_list *next = var->next;
cvar_free(var); cvar_free(var);
var = next; var = next;
}); });
...@@ -358,7 +358,7 @@ static int config_iterator_next( ...@@ -358,7 +358,7 @@ static int config_iterator_next(
diskfile_header *h = (diskfile_header *) it->parent.backend; diskfile_header *h = (diskfile_header *) it->parent.backend;
git_strmap *values = h->values->values; git_strmap *values = h->values->values;
int err = 0; int err = 0;
cvar_t * var; config_entry_list * var;
if (it->next_var == NULL) { if (it->next_var == NULL) {
err = git_strmap_next((void**) &var, &(it->iter), values); err = git_strmap_next((void**) &var, &(it->iter), values);
...@@ -434,7 +434,7 @@ static int config_set(git_config_backend *cfg, const char *name, const char *val ...@@ -434,7 +434,7 @@ static int config_set(git_config_backend *cfg, const char *name, const char *val
*/ */
pos = git_strmap_lookup_index(values, key); pos = git_strmap_lookup_index(values, key);
if (git_strmap_valid_index(values, pos)) { if (git_strmap_valid_index(values, pos)) {
cvar_t *existing = git_strmap_value_at(values, pos); config_entry_list *existing = git_strmap_value_at(values, pos);
if (existing->next != NULL) { if (existing->next != NULL) {
giterr_set(GITERR_CONFIG, "multivar incompatible with simple set"); giterr_set(GITERR_CONFIG, "multivar incompatible with simple set");
...@@ -492,7 +492,7 @@ static int config_get(git_config_backend *cfg, const char *key, git_config_entry ...@@ -492,7 +492,7 @@ static int config_get(git_config_backend *cfg, const char *key, git_config_entry
refcounted_strmap *map; refcounted_strmap *map;
git_strmap *values; git_strmap *values;
khiter_t pos; khiter_t pos;
cvar_t *var; config_entry_list *var;
int error = 0; int error = 0;
if (!h->parent.readonly && ((error = config_refresh(cfg)) < 0)) if (!h->parent.readonly && ((error = config_refresh(cfg)) < 0))
...@@ -556,7 +556,7 @@ out: ...@@ -556,7 +556,7 @@ out:
static int config_delete(git_config_backend *cfg, const char *name) static int config_delete(git_config_backend *cfg, const char *name)
{ {
cvar_t *var; config_entry_list *var;
diskfile_backend *b = (diskfile_backend *)cfg; diskfile_backend *b = (diskfile_backend *)cfg;
refcounted_strmap *map; git_strmap *values; refcounted_strmap *map; git_strmap *values;
char *key; char *key;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment