config: make names backend-agnostic As a last step to make variables and structures more backend agnostic for our `git_config` structure, rename local variables to not be called `file` anymore.
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
diff --git a/src/config.c b/src/config.c
index e9b5a5c..72c1c73 100644
--- a/src/config.c
+++ b/src/config.c
@@ -37,10 +37,10 @@ typedef struct {
static void backend_internal_free(backend_internal *internal)
{
- git_config_backend *file;
+ git_config_backend *backend;
- file = internal->backend;
- file->free(file);
+ backend = internal->backend;
+ backend->free(backend);
git__free(internal);
}
@@ -179,8 +179,8 @@ int git_config_snapshot(git_config **out, git_config *in)
return error;
}
-static int find_internal_file_by_level(
- backend_internal **internal_out,
+static int find_backend_by_level(
+ backend_internal **out,
const git_config *cfg,
git_config_level_t level)
{
@@ -190,7 +190,7 @@ static int find_internal_file_by_level(
/* when passing GIT_CONFIG_HIGHEST_LEVEL, the idea is to get the config backend
* which has the highest level. As config backends are stored in a vector
- * sorted by decreasing order of level, getting the file at position 0
+ * sorted by decreasing order of level, getting the backend at position 0
* will do the job.
*/
if (level == GIT_CONFIG_HIGHEST_LEVEL) {
@@ -204,11 +204,11 @@ static int find_internal_file_by_level(
if (pos == -1) {
giterr_set(GITERR_CONFIG,
- "no config file exists for the given level '%i'", (int)level);
+ "no configuration exists for the given level '%i'", (int)level);
return GIT_ENOTFOUND;
}
- *internal_out = git_vector_get(&cfg->backends, pos);
+ *out = git_vector_get(&cfg->backends, pos);
return 0;
}
@@ -219,11 +219,11 @@ static int duplicate_level(void **old_raw, void *new_raw)
GIT_UNUSED(new_raw);
- giterr_set(GITERR_CONFIG, "a file with the same level (%i) has already been added to the config", (int)(*old)->level);
+ giterr_set(GITERR_CONFIG, "there already exists a configuration for the given level (%i)", (int)(*old)->level);
return GIT_EEXISTS;
}
-static void try_remove_existing_file_internal(
+static void try_remove_existing_backend(
git_config *cfg,
git_config_level_t level)
{
@@ -255,9 +255,9 @@ static int git_config__add_internal(
{
int result;
- /* delete existing config file for level if it exists */
+ /* delete existing config backend for level if it exists */
if (force)
- try_remove_existing_file_internal(cfg, level);
+ try_remove_existing_backend(cfg, level);
if ((result = git_vector_insert_sorted(&cfg->backends,
internal, &duplicate_level)) < 0)
@@ -288,7 +288,7 @@ int git_config_open_level(
backend_internal *internal;
int res;
- if ((res = find_internal_file_by_level(&internal, cfg_parent, level)) < 0)
+ if ((res = find_backend_by_level(&internal, cfg_parent, level)) < 0)
return res;
if ((res = git_config_new(&cfg)) < 0)
@@ -306,7 +306,7 @@ int git_config_open_level(
int git_config_add_backend(
git_config *cfg,
- git_config_backend *file,
+ git_config_backend *backend,
git_config_level_t level,
const git_repository *repo,
int force)
@@ -314,11 +314,11 @@ int git_config_add_backend(
backend_internal *internal;
int result;
- assert(cfg && file);
+ assert(cfg && backend);
- GITERR_CHECK_VERSION(file, GIT_CONFIG_BACKEND_VERSION, "git_config_backend");
+ GITERR_CHECK_VERSION(backend, GIT_CONFIG_BACKEND_VERSION, "git_config_backend");
- if ((result = file->open(file, level, repo)) < 0)
+ if ((result = backend->open(backend, level, repo)) < 0)
return result;
internal = git__malloc(sizeof(backend_internal));
@@ -326,7 +326,7 @@ int git_config_add_backend(
memset(internal, 0x0, sizeof(backend_internal));
- internal->backend = file;
+ internal->backend = backend;
internal->level = level;
if ((result = git_config__add_internal(cfg, internal, level, force)) < 0) {
@@ -618,12 +618,12 @@ static int get_backend_for_use(git_config_backend **out,
int git_config_delete_entry(git_config *cfg, const char *name)
{
- git_config_backend *file;
+ git_config_backend *backend;
- if (get_backend_for_use(&file, cfg, name, BACKEND_USE_DELETE) < 0)
+ if (get_backend_for_use(&backend, cfg, name, BACKEND_USE_DELETE) < 0)
return GIT_ENOTFOUND;
- return file->del(file, name);
+ return backend->del(backend, name);
}
int git_config_set_int64(git_config *cfg, const char *name, int64_t value)
@@ -646,17 +646,17 @@ 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)
{
int error;
- git_config_backend *file;
+ git_config_backend *backend;
if (!value) {
giterr_set(GITERR_CONFIG, "the value to set cannot be NULL");
return -1;
}
- if (get_backend_for_use(&file, cfg, name, BACKEND_USE_SET) < 0)
+ if (get_backend_for_use(&backend, cfg, name, BACKEND_USE_SET) < 0)
return GIT_ENOTFOUND;
- error = file->set(file, name, value);
+ error = backend->set(backend, name, value);
if (!error && GIT_REFCOUNT_OWNER(cfg) != NULL)
git_repository__cvar_cache_clear(GIT_REFCOUNT_OWNER(cfg));
@@ -1058,22 +1058,22 @@ on_error:
int git_config_set_multivar(git_config *cfg, const char *name, const char *regexp, const char *value)
{
- git_config_backend *file;
+ git_config_backend *backend;
- if (get_backend_for_use(&file, cfg, name, BACKEND_USE_DELETE) < 0)
+ if (get_backend_for_use(&backend, cfg, name, BACKEND_USE_DELETE) < 0)
return GIT_ENOTFOUND;
- return file->set_multivar(file, name, regexp, value);
+ return backend->set_multivar(backend, name, regexp, value);
}
int git_config_delete_multivar(git_config *cfg, const char *name, const char *regexp)
{
- git_config_backend *file;
+ git_config_backend *backend;
- if (get_backend_for_use(&file, cfg, name, BACKEND_USE_DELETE) < 0)
+ if (get_backend_for_use(&backend, cfg, name, BACKEND_USE_DELETE) < 0)
return GIT_ENOTFOUND;
- return file->del_multivar(file, name, regexp);
+ return backend->del_multivar(backend, name, regexp);
}
int git_config_next(git_config_entry **entry, git_config_iterator *iter)
@@ -1179,7 +1179,7 @@ int git_config_open_default(git_config **out)
int git_config_lock(git_transaction **out, git_config *cfg)
{
int error;
- git_config_backend *file;
+ git_config_backend *backend;
backend_internal *internal;
internal = git_vector_get(&cfg->backends, 0);
@@ -1187,9 +1187,9 @@ int git_config_lock(git_transaction **out, git_config *cfg)
giterr_set(GITERR_CONFIG, "cannot lock; the config has no backends");
return -1;
}
- file = internal->backend;
+ backend = internal->backend;
- if ((error = file->lock(file)) < 0)
+ if ((error = backend->lock(backend)) < 0)
return error;
return git_transaction_config_new(out, cfg);
@@ -1197,7 +1197,7 @@ int git_config_lock(git_transaction **out, git_config *cfg)
int git_config_unlock(git_config *cfg, int commit)
{
- git_config_backend *file;
+ git_config_backend *backend;
backend_internal *internal;
internal = git_vector_get(&cfg->backends, 0);
@@ -1206,9 +1206,9 @@ int git_config_unlock(git_config *cfg, int commit)
return -1;
}
- file = internal->backend;
+ backend = internal->backend;
- return file->unlock(file, commit);
+ return backend->unlock(backend, commit);
}
/***********