config_entries: rename functions and structure The previous commit simply moved all code that is required to handle config entries to a new module without yet adjusting any of the function and structure names to help readability. We now rename things accordingly to have a common "git_config_entries" entries instead of the old "diskfile_entries" one.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307
diff --git a/src/config_entries.c b/src/config_entries.c
index 644e60c..576ddfd 100644
--- a/src/config_entries.c
+++ b/src/config_entries.c
@@ -32,12 +32,12 @@ static void config_entry_list_append(config_entry_list **list, config_entry_list
(*list)->last = entry;
}
-int diskfile_entries_alloc(diskfile_entries **out)
+int git_config_entries_new(git_config_entries **out)
{
- diskfile_entries *entries;
+ git_config_entries *entries;
int error;
- entries = git__calloc(1, sizeof(diskfile_entries));
+ entries = git__calloc(1, sizeof(git_config_entries));
GITERR_CHECK_ALLOC(entries);
git_atomic_set(&entries->refcount, 1);
@@ -50,7 +50,7 @@ int diskfile_entries_alloc(diskfile_entries **out)
return error;
}
-void diskfile_entries_free(diskfile_entries *entries)
+void git_config_entries_free(git_config_entries *entries)
{
config_entry_list *list = NULL, *next;
@@ -73,7 +73,7 @@ void diskfile_entries_free(diskfile_entries *entries)
git__free(entries);
}
-int diskfile_entries_append(diskfile_entries *entries, git_config_entry *entry)
+int git_config_entries_append(git_config_entries *entries, git_config_entry *entry)
{
git_strmap_iter pos;
config_entry_list *existing, *var;
diff --git a/src/config_entries.h b/src/config_entries.h
index fbb901b..d74e172 100644
--- a/src/config_entries.h
+++ b/src/config_entries.h
@@ -20,17 +20,17 @@ typedef struct {
git_atomic refcount;
git_strmap *map;
config_entry_list *list;
-} diskfile_entries;
+} git_config_entries;
typedef struct git_config_file_iter {
git_config_iterator parent;
config_entry_list *head;
} git_config_file_iter;
-int diskfile_entries_alloc(diskfile_entries **out);
-void diskfile_entries_free(diskfile_entries *entries);
+int git_config_entries_new(git_config_entries **out);
+void git_config_entries_free(git_config_entries *entries);
/* Add or append the new config option */
-int diskfile_entries_append(diskfile_entries *entries, git_config_entry *entry);
+int git_config_entries_append(git_config_entries *entries, git_config_entry *entry);
void config_iterator_free(git_config_iterator* iter);
int config_iterator_next(git_config_entry **entry,
diff --git a/src/config_file.c b/src/config_file.c
index 1934ec2..a93af53 100644
--- a/src/config_file.c
+++ b/src/config_file.c
@@ -30,7 +30,7 @@ typedef struct {
git_config_backend parent;
/* mutex to coordinate accessing the values */
git_mutex values_mutex;
- diskfile_entries *entries;
+ git_config_entries *entries;
const git_repository *repo;
git_config_level_t level;
} diskfile_header;
@@ -56,12 +56,12 @@ typedef struct {
typedef struct {
const git_repository *repo;
const char *file_path;
- diskfile_entries *entries;
+ git_config_entries *entries;
git_config_level_t level;
unsigned int depth;
} diskfile_parse_state;
-static int config_read(diskfile_entries *entries, const git_repository *repo, git_config_file *file, git_config_level_t level, int depth);
+static int config_read(git_config_entries *entries, const git_repository *repo, git_config_file *file, git_config_level_t level, int depth);
static int config_write(diskfile_backend *cfg, const char *orig_key, const char *key, const regex_t *preg, const char *value);
static char *escape_value(const char *ptr);
@@ -78,9 +78,9 @@ static int config_error_readonly(void)
* refcount. This is its own function to make sure we use the mutex to
* avoid the map pointer from changing under us.
*/
-static diskfile_entries *diskfile_entries_take(diskfile_header *h)
+static git_config_entries *diskfile_entries_take(diskfile_header *h)
{
- diskfile_entries *entries;
+ git_config_entries *entries;
if (git_mutex_lock(&h->values_mutex) < 0) {
giterr_set(GITERR_OS, "failed to lock config backend");
@@ -119,14 +119,14 @@ static int config_open(git_config_backend *cfg, git_config_level_t level, const
b->header.level = level;
b->header.repo = repo;
- if ((res = diskfile_entries_alloc(&b->header.entries)) < 0)
+ if ((res = git_config_entries_new(&b->header.entries)) < 0)
return res;
if (!git_path_exists(b->file.path))
return 0;
if (res < 0 || (res = config_read(b->header.entries, repo, &b->file, level, 0)) < 0) {
- diskfile_entries_free(b->header.entries);
+ git_config_entries_free(b->header.entries);
b->header.entries = NULL;
}
@@ -168,7 +168,7 @@ out:
static int config_refresh(git_config_backend *cfg)
{
diskfile_backend *b = (diskfile_backend *)cfg;
- diskfile_entries *entries = NULL, *tmp;
+ git_config_entries *entries = NULL, *tmp;
git_config_file *include;
int error, modified;
uint32_t i;
@@ -183,7 +183,7 @@ static int config_refresh(git_config_backend *cfg)
if (!modified)
return 0;
- if ((error = diskfile_entries_alloc(&entries)) < 0)
+ if ((error = git_config_entries_new(&entries)) < 0)
goto out;
/* Reparse the current configuration */
@@ -207,7 +207,7 @@ static int config_refresh(git_config_backend *cfg)
git_mutex_unlock(&b->header.values_mutex);
out:
- diskfile_entries_free(entries);
+ git_config_entries_free(entries);
return (error == GIT_ENOTFOUND) ? 0 : error;
}
@@ -220,7 +220,7 @@ static void backend_free(git_config_backend *_backend)
return;
config_file_clear(&backend->file);
- diskfile_entries_free(backend->header.entries);
+ git_config_entries_free(backend->header.entries);
git_mutex_free(&backend->header.values_mutex);
git__free(backend);
}
@@ -259,7 +259,7 @@ static int config_iterator_new(
static int config_set(git_config_backend *cfg, const char *name, const char *value)
{
diskfile_backend *b = (diskfile_backend *)cfg;
- diskfile_entries *entries;
+ git_config_entries *entries;
git_strmap *entry_map;
char *key, *esc_value = NULL;
khiter_t pos;
@@ -314,7 +314,7 @@ static int config_set(git_config_backend *cfg, const char *name, const char *val
ret = config_refresh(cfg);
out:
- diskfile_entries_free(entries);
+ git_config_entries_free(entries);
git__free(esc_value);
git__free(key);
return ret;
@@ -323,8 +323,8 @@ out:
/* release the map containing the entry as an equivalent to freeing it */
static void free_diskfile_entry(git_config_entry *entry)
{
- diskfile_entries *map = (diskfile_entries *) entry->payload;
- diskfile_entries_free(map);
+ git_config_entries *entries = (git_config_entries *) entry->payload;
+ git_config_entries_free(entries);
}
/*
@@ -333,7 +333,7 @@ static void free_diskfile_entry(git_config_entry *entry)
static int config_get(git_config_backend *cfg, const char *key, git_config_entry **out)
{
diskfile_header *h = (diskfile_header *)cfg;
- diskfile_entries *entries;
+ git_config_entries *entries;
git_strmap *entry_map;
khiter_t pos;
config_entry_list *var;
@@ -350,7 +350,7 @@ static int config_get(git_config_backend *cfg, const char *key, git_config_entry
/* no error message; the config system will write one */
if (!git_strmap_valid_index(entry_map, pos)) {
- diskfile_entries_free(entries);
+ git_config_entries_free(entries);
return GIT_ENOTFOUND;
}
@@ -399,7 +399,7 @@ static int config_delete(git_config_backend *cfg, const char *name)
{
config_entry_list *var;
diskfile_backend *b = (diskfile_backend *)cfg;
- diskfile_entries *map;
+ git_config_entries *entries;
git_strmap *entry_map;
char *key;
int result;
@@ -408,7 +408,7 @@ static int config_delete(git_config_backend *cfg, const char *name)
if ((result = git_config__normalize_name(name, &key)) < 0)
return result;
- if ((map = diskfile_entries_take(&b->header)) == NULL)
+ if ((entries = diskfile_entries_take(&b->header)) == NULL)
return -1;
entry_map = b->header.entries->map;
@@ -416,13 +416,13 @@ static int config_delete(git_config_backend *cfg, const char *name)
git__free(key);
if (!git_strmap_valid_index(entry_map, pos)) {
- diskfile_entries_free(map);
+ git_config_entries_free(entries);
giterr_set(GITERR_CONFIG, "could not find key '%s' to delete", name);
return GIT_ENOTFOUND;
}
var = git_strmap_value_at(entry_map, pos);
- diskfile_entries_free(map);
+ git_config_entries_free(entries);
if (var->entry->include_depth) {
giterr_set(GITERR_CONFIG, "cannot delete included variable");
@@ -443,7 +443,7 @@ static int config_delete(git_config_backend *cfg, const char *name)
static int config_delete_multivar(git_config_backend *cfg, const char *name, const char *regexp)
{
diskfile_backend *b = (diskfile_backend *)cfg;
- diskfile_entries *map;
+ git_config_entries *entries;
git_strmap *entry_map;
char *key;
regex_t preg;
@@ -453,20 +453,20 @@ static int config_delete_multivar(git_config_backend *cfg, const char *name, con
if ((result = git_config__normalize_name(name, &key)) < 0)
return result;
- if ((map = diskfile_entries_take(&b->header)) == NULL)
+ if ((entries = diskfile_entries_take(&b->header)) == NULL)
return -1;
entry_map = b->header.entries->map;
pos = git_strmap_lookup_index(entry_map, key);
if (!git_strmap_valid_index(entry_map, pos)) {
- diskfile_entries_free(map);
+ git_config_entries_free(entries);
git__free(key);
giterr_set(GITERR_CONFIG, "could not find key '%s' to delete", name);
return GIT_ENOTFOUND;
}
- diskfile_entries_free(map);
+ git_config_entries_free(entries);
result = p_regcomp(&preg, regexp, REG_EXTENDED);
if (result != 0) {
@@ -612,7 +612,7 @@ static void backend_readonly_free(git_config_backend *_backend)
if (backend == NULL)
return;
- diskfile_entries_free(backend->header.entries);
+ git_config_entries_free(backend->header.entries);
git_mutex_free(&backend->header.values_mutex);
git__free(backend);
}
@@ -622,7 +622,7 @@ static int config_readonly_open(git_config_backend *cfg, git_config_level_t leve
diskfile_readonly_backend *b = (diskfile_readonly_backend *) cfg;
diskfile_backend *src = b->snapshot_from;
diskfile_header *src_header = &src->header;
- diskfile_entries *entries;
+ git_config_entries *entries;
int error;
if (!src_header->parent.readonly && (error = config_refresh(&src_header->parent)) < 0)
@@ -885,7 +885,7 @@ static int read_on_variable(
entry->level = parse_data->level;
entry->include_depth = parse_data->depth;
- if ((result = diskfile_entries_append(parse_data->entries, entry)) < 0)
+ if ((result = git_config_entries_append(parse_data->entries, entry)) < 0)
return result;
result = 0;
@@ -902,7 +902,7 @@ static int read_on_variable(
}
static int config_read(
- diskfile_entries *entries,
+ git_config_entries *entries,
const git_repository *repo,
git_config_file *file,
git_config_level_t level,