config_backend: rename internal structures The internal backend structures are kind-of legacy and do not really speak for themselves. Rename them accordingly to make them easier to understand.
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 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338
diff --git a/src/config_file.c b/src/config_file.c
index bd5472f..3e8e30c 100644
--- a/src/config_file.c
+++ b/src/config_file.c
@@ -28,12 +28,12 @@
/* Max depth for [include] directives */
#define MAX_INCLUDE_DEPTH 10
-typedef struct diskfile {
+typedef struct config_file {
git_futils_filestamp stamp;
git_oid checksum;
char *path;
- git_array_t(struct diskfile) includes;
-} diskfile;
+ git_array_t(struct config_file) includes;
+} config_file;
typedef struct {
git_config_backend parent;
@@ -48,20 +48,20 @@ typedef struct {
git_filebuf locked_buf;
git_buf locked_content;
- diskfile file;
-} diskfile_backend;
+ config_file file;
+} config_file_backend;
typedef struct {
const git_repository *repo;
- diskfile *file;
+ config_file *file;
git_config_entries *entries;
git_config_level_t level;
unsigned int depth;
-} diskfile_parse_state;
+} config_file_parse_data;
-static int config_read(git_config_entries *entries, const git_repository *repo, diskfile *file, git_config_level_t level, int depth);
-static int config_read_buffer(git_config_entries *entries, const git_repository *repo, diskfile *file, git_config_level_t level, int depth, const char *buf, size_t buflen);
-static int config_write(diskfile_backend *cfg, const char *orig_key, const char *key, const p_regex_t *preg, const char *value);
+static int config_read(git_config_entries *entries, const git_repository *repo, config_file *file, git_config_level_t level, int depth);
+static int config_read_buffer(git_config_entries *entries, const git_repository *repo, config_file *file, git_config_level_t level, int depth, const char *buf, size_t buflen);
+static int config_write(config_file_backend *cfg, const char *orig_key, const char *key, const p_regex_t *preg, const char *value);
static char *escape_value(const char *ptr);
/**
@@ -69,7 +69,7 @@ static char *escape_value(const char *ptr);
* refcount. This is its own function to make sure we use the mutex to
* avoid the map pointer from changing under us.
*/
-static git_config_entries *diskfile_entries_take(diskfile_backend *b)
+static git_config_entries *diskfile_entries_take(config_file_backend *b)
{
git_config_entries *entries;
@@ -86,9 +86,9 @@ static git_config_entries *diskfile_entries_take(diskfile_backend *b)
return entries;
}
-static void config_file_clear(diskfile *file)
+static void config_file_clear(config_file *file)
{
- diskfile *include;
+ config_file *include;
uint32_t i;
if (file == NULL)
@@ -104,7 +104,7 @@ static void config_file_clear(diskfile *file)
static int config_open(git_config_backend *cfg, git_config_level_t level, const git_repository *repo)
{
- diskfile_backend *b = GIT_CONTAINER_OF(cfg, diskfile_backend, parent);
+ config_file_backend *b = GIT_CONTAINER_OF(cfg, config_file_backend, parent);
int res;
b->level = level;
@@ -124,9 +124,9 @@ static int config_open(git_config_backend *cfg, git_config_level_t level, const
return res;
}
-static int config_is_modified(int *modified, diskfile *file)
+static int config_is_modified(int *modified, config_file *file)
{
- diskfile *include;
+ config_file *include;
git_buf buf = GIT_BUF_INIT;
git_oid hash;
uint32_t i;
@@ -162,9 +162,9 @@ out:
static int config_set_entries(git_config_backend *cfg, git_config_entries *entries)
{
- diskfile_backend *b = GIT_CONTAINER_OF(cfg, diskfile_backend, parent);
+ config_file_backend *b = GIT_CONTAINER_OF(cfg, config_file_backend, parent);
git_config_entries *old = NULL;
- diskfile *include;
+ config_file *include;
int error;
uint32_t i;
@@ -194,7 +194,7 @@ out:
static int config_refresh_from_buffer(git_config_backend *cfg, const char *buf, size_t buflen)
{
- diskfile_backend *b = GIT_CONTAINER_OF(cfg, diskfile_backend, parent);
+ config_file_backend *b = GIT_CONTAINER_OF(cfg, config_file_backend, parent);
git_config_entries *entries = NULL;
int error;
@@ -212,7 +212,7 @@ out:
static int config_refresh(git_config_backend *cfg)
{
- diskfile_backend *b = GIT_CONTAINER_OF(cfg, diskfile_backend, parent);
+ config_file_backend *b = GIT_CONTAINER_OF(cfg, config_file_backend, parent);
git_config_entries *entries = NULL;
int error, modified;
@@ -239,7 +239,7 @@ out:
static void backend_free(git_config_backend *_backend)
{
- diskfile_backend *backend = GIT_CONTAINER_OF(_backend, diskfile_backend, parent);
+ config_file_backend *backend = GIT_CONTAINER_OF(_backend, config_file_backend, parent);
if (backend == NULL)
return;
@@ -254,7 +254,7 @@ static int config_iterator_new(
git_config_iterator **iter,
struct git_config_backend *backend)
{
- diskfile_backend *b = GIT_CONTAINER_OF(backend, diskfile_backend, parent);
+ config_file_backend *b = GIT_CONTAINER_OF(backend, config_file_backend, parent);
git_config_entries *entries = NULL;
int error;
@@ -271,7 +271,7 @@ out:
static int config_set(git_config_backend *cfg, const char *name, const char *value)
{
- diskfile_backend *b = GIT_CONTAINER_OF(cfg, diskfile_backend, parent);
+ config_file_backend *b = GIT_CONTAINER_OF(cfg, config_file_backend, parent);
git_config_entries *entries;
git_config_entry *existing;
char *key, *esc_value = NULL;
@@ -323,7 +323,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_backend *h = GIT_CONTAINER_OF(cfg, diskfile_backend, parent);
+ config_file_backend *h = GIT_CONTAINER_OF(cfg, config_file_backend, parent);
git_config_entries *entries = NULL;
git_config_entry *entry;
int error = 0;
@@ -349,7 +349,7 @@ static int config_get(git_config_backend *cfg, const char *key, git_config_entry
static int config_set_multivar(
git_config_backend *cfg, const char *name, const char *regexp, const char *value)
{
- diskfile_backend *b = GIT_CONTAINER_OF(cfg, diskfile_backend, parent);
+ config_file_backend *b = GIT_CONTAINER_OF(cfg, config_file_backend, parent);
char *key;
p_regex_t preg;
int result;
@@ -379,7 +379,7 @@ out:
static int config_delete(git_config_backend *cfg, const char *name)
{
- diskfile_backend *b = GIT_CONTAINER_OF(cfg, diskfile_backend, parent);
+ config_file_backend *b = GIT_CONTAINER_OF(cfg, config_file_backend, parent);
git_config_entries *entries = NULL;
git_config_entry *entry;
char *key = NULL;
@@ -409,7 +409,7 @@ out:
static int config_delete_multivar(git_config_backend *cfg, const char *name, const char *regexp)
{
- diskfile_backend *b = GIT_CONTAINER_OF(cfg, diskfile_backend, parent);
+ config_file_backend *b = GIT_CONTAINER_OF(cfg, config_file_backend, parent);
git_config_entries *entries = NULL;
git_config_entry *entry = NULL;
p_regex_t preg = { 0 };
@@ -448,7 +448,7 @@ out:
static int config_lock(git_config_backend *_cfg)
{
- diskfile_backend *cfg = GIT_CONTAINER_OF(_cfg, diskfile_backend, parent);
+ config_file_backend *cfg = GIT_CONTAINER_OF(_cfg, config_file_backend, parent);
int error;
if ((error = git_filebuf_open(&cfg->locked_buf, cfg->file.path, 0, GIT_CONFIG_FILE_MODE)) < 0)
@@ -467,7 +467,7 @@ static int config_lock(git_config_backend *_cfg)
static int config_unlock(git_config_backend *_cfg, int success)
{
- diskfile_backend *cfg = GIT_CONTAINER_OF(_cfg, diskfile_backend, parent);
+ config_file_backend *cfg = GIT_CONTAINER_OF(_cfg, config_file_backend, parent);
int error = 0;
if (success) {
@@ -484,9 +484,9 @@ static int config_unlock(git_config_backend *_cfg, int success)
int git_config_backend_from_file(git_config_backend **out, const char *path)
{
- diskfile_backend *backend;
+ config_file_backend *backend;
- backend = git__calloc(1, sizeof(diskfile_backend));
+ backend = git__calloc(1, sizeof(config_file_backend));
GIT_ERROR_CHECK_ALLOC(backend);
backend->parent.version = GIT_CONFIG_BACKEND_VERSION;
@@ -554,9 +554,9 @@ static char *escape_value(const char *ptr)
return git_buf_detach(&buf);
}
-static int parse_include(diskfile_parse_state *parse_data, const char *file)
+static int parse_include(config_file_parse_data *parse_data, const char *file)
{
- diskfile *include;
+ config_file *include;
git_buf path = GIT_BUF_INIT;
char *dir;
int result;
@@ -659,7 +659,7 @@ static const struct {
{ "gitdir/i:", conditional_match_gitdir_i }
};
-static int parse_conditional_include(diskfile_parse_state *parse_data, const char *section, const char *file)
+static int parse_conditional_include(config_file_parse_data *parse_data, const char *section, const char *file)
{
char *condition;
size_t i;
@@ -700,7 +700,7 @@ static int read_on_variable(
size_t line_len,
void *data)
{
- diskfile_parse_state *parse_data = (diskfile_parse_state *)data;
+ config_file_parse_data *parse_data = (config_file_parse_data *)data;
git_buf buf = GIT_BUF_INIT;
git_config_entry *entry;
const char *c;
@@ -750,13 +750,13 @@ static int read_on_variable(
static int config_read_buffer(
git_config_entries *entries,
const git_repository *repo,
- diskfile *file,
+ config_file *file,
git_config_level_t level,
int depth,
const char *buf,
size_t buflen)
{
- diskfile_parse_state parse_data;
+ config_file_parse_data parse_data;
git_config_parser reader;
int error;
@@ -790,7 +790,7 @@ out:
static int config_read(
git_config_entries *entries,
const git_repository *repo,
- diskfile *file,
+ config_file *file,
git_config_level_t level,
int depth)
{
@@ -1042,7 +1042,7 @@ static int write_on_eof(
/*
* This is pretty much the parsing, except we write out anything we don't have
*/
-static int config_write(diskfile_backend *cfg, const char *orig_key, const char *key, const p_regex_t *preg, const char* value)
+static int config_write(config_file_backend *cfg, const char *orig_key, const char *key, const p_regex_t *preg, const char* value)
{
char *orig_section = NULL, *section = NULL, *orig_name, *name, *ldot;
git_buf buf = GIT_BUF_INIT, contents = GIT_BUF_INIT;
diff --git a/src/config_snapshot.c b/src/config_snapshot.c
index 59617ce..764abe2 100644
--- a/src/config_snapshot.c
+++ b/src/config_snapshot.c
@@ -14,7 +14,7 @@ typedef struct {
git_mutex values_mutex;
git_config_entries *entries;
git_config_backend *source;
-} diskfile_readonly_backend;
+} config_snapshot_backend;
static int config_error_readonly(void)
{
@@ -26,7 +26,7 @@ static int config_iterator_new_readonly(
git_config_iterator **iter,
struct git_config_backend *backend)
{
- diskfile_readonly_backend *b = GIT_CONTAINER_OF(backend, diskfile_readonly_backend, parent);
+ config_snapshot_backend *b = GIT_CONTAINER_OF(backend, config_snapshot_backend, parent);
git_config_entries *entries = NULL;
int error;
@@ -49,7 +49,7 @@ static void free_diskfile_entry(git_config_entry *entry)
static int config_get_readonly(git_config_backend *cfg, const char *key, git_config_entry **out)
{
- diskfile_readonly_backend *b = GIT_CONTAINER_OF(cfg, diskfile_readonly_backend, parent);
+ config_snapshot_backend *b = GIT_CONTAINER_OF(cfg, config_snapshot_backend, parent);
git_config_entries *entries = NULL;
git_config_entry *entry;
int error = 0;
@@ -129,7 +129,7 @@ static int config_unlock_readonly(git_config_backend *_cfg, int success)
static void backend_readonly_free(git_config_backend *_backend)
{
- diskfile_readonly_backend *backend = GIT_CONTAINER_OF(_backend, diskfile_readonly_backend, parent);
+ config_snapshot_backend *backend = GIT_CONTAINER_OF(_backend, config_snapshot_backend, parent);
if (backend == NULL)
return;
@@ -141,7 +141,7 @@ static void backend_readonly_free(git_config_backend *_backend)
static int config_readonly_open(git_config_backend *cfg, git_config_level_t level, const git_repository *repo)
{
- diskfile_readonly_backend *b = GIT_CONTAINER_OF(cfg, diskfile_readonly_backend, parent);
+ config_snapshot_backend *b = GIT_CONTAINER_OF(cfg, config_snapshot_backend, parent);
git_config_entries *entries = NULL;
git_config_iterator *it = NULL;
git_config_entry *entry;
@@ -176,9 +176,9 @@ out:
int git_config_backend_snapshot(git_config_backend **out, git_config_backend *source)
{
- diskfile_readonly_backend *backend;
+ config_snapshot_backend *backend;
- backend = git__calloc(1, sizeof(diskfile_readonly_backend));
+ backend = git__calloc(1, sizeof(config_snapshot_backend));
GIT_ERROR_CHECK_ALLOC(backend);
backend->parent.version = GIT_CONFIG_BACKEND_VERSION;