Skip to content

Commit 37ebe9a

Browse files
committed
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 parent 2bff84b commit 37ebe9a

File tree

2 files changed

+46
-46
lines changed

2 files changed

+46
-46
lines changed

src/config_file.c

Lines changed: 39 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -28,12 +28,12 @@
2828
/* Max depth for [include] directives */
2929
#define MAX_INCLUDE_DEPTH 10
3030

31-
typedef struct diskfile {
31+
typedef struct config_file {
3232
git_futils_filestamp stamp;
3333
git_oid checksum;
3434
char *path;
35-
git_array_t(struct diskfile) includes;
36-
} diskfile;
35+
git_array_t(struct config_file) includes;
36+
} config_file;
3737

3838
typedef struct {
3939
git_config_backend parent;
@@ -48,28 +48,28 @@ typedef struct {
4848
git_filebuf locked_buf;
4949
git_buf locked_content;
5050

51-
diskfile file;
52-
} diskfile_backend;
51+
config_file file;
52+
} config_file_backend;
5353

5454
typedef struct {
5555
const git_repository *repo;
56-
diskfile *file;
56+
config_file *file;
5757
git_config_entries *entries;
5858
git_config_level_t level;
5959
unsigned int depth;
60-
} diskfile_parse_state;
60+
} config_file_parse_data;
6161

62-
static int config_read(git_config_entries *entries, const git_repository *repo, diskfile *file, git_config_level_t level, int depth);
63-
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);
64-
static int config_write(diskfile_backend *cfg, const char *orig_key, const char *key, const p_regex_t *preg, const char *value);
62+
static int config_read(git_config_entries *entries, const git_repository *repo, config_file *file, git_config_level_t level, int depth);
63+
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);
64+
static int config_write(config_file_backend *cfg, const char *orig_key, const char *key, const p_regex_t *preg, const char *value);
6565
static char *escape_value(const char *ptr);
6666

6767
/**
6868
* Take the current values map from the backend and increase its
6969
* refcount. This is its own function to make sure we use the mutex to
7070
* avoid the map pointer from changing under us.
7171
*/
72-
static git_config_entries *diskfile_entries_take(diskfile_backend *b)
72+
static git_config_entries *diskfile_entries_take(config_file_backend *b)
7373
{
7474
git_config_entries *entries;
7575

@@ -86,9 +86,9 @@ static git_config_entries *diskfile_entries_take(diskfile_backend *b)
8686
return entries;
8787
}
8888

89-
static void config_file_clear(diskfile *file)
89+
static void config_file_clear(config_file *file)
9090
{
91-
diskfile *include;
91+
config_file *include;
9292
uint32_t i;
9393

9494
if (file == NULL)
@@ -104,7 +104,7 @@ static void config_file_clear(diskfile *file)
104104

105105
static int config_open(git_config_backend *cfg, git_config_level_t level, const git_repository *repo)
106106
{
107-
diskfile_backend *b = GIT_CONTAINER_OF(cfg, diskfile_backend, parent);
107+
config_file_backend *b = GIT_CONTAINER_OF(cfg, config_file_backend, parent);
108108
int res;
109109

110110
b->level = level;
@@ -124,9 +124,9 @@ static int config_open(git_config_backend *cfg, git_config_level_t level, const
124124
return res;
125125
}
126126

127-
static int config_is_modified(int *modified, diskfile *file)
127+
static int config_is_modified(int *modified, config_file *file)
128128
{
129-
diskfile *include;
129+
config_file *include;
130130
git_buf buf = GIT_BUF_INIT;
131131
git_oid hash;
132132
uint32_t i;
@@ -162,9 +162,9 @@ static int config_is_modified(int *modified, diskfile *file)
162162

163163
static int config_set_entries(git_config_backend *cfg, git_config_entries *entries)
164164
{
165-
diskfile_backend *b = GIT_CONTAINER_OF(cfg, diskfile_backend, parent);
165+
config_file_backend *b = GIT_CONTAINER_OF(cfg, config_file_backend, parent);
166166
git_config_entries *old = NULL;
167-
diskfile *include;
167+
config_file *include;
168168
int error;
169169
uint32_t i;
170170

@@ -194,7 +194,7 @@ static int config_set_entries(git_config_backend *cfg, git_config_entries *entri
194194

195195
static int config_refresh_from_buffer(git_config_backend *cfg, const char *buf, size_t buflen)
196196
{
197-
diskfile_backend *b = GIT_CONTAINER_OF(cfg, diskfile_backend, parent);
197+
config_file_backend *b = GIT_CONTAINER_OF(cfg, config_file_backend, parent);
198198
git_config_entries *entries = NULL;
199199
int error;
200200

@@ -212,7 +212,7 @@ static int config_refresh_from_buffer(git_config_backend *cfg, const char *buf,
212212

213213
static int config_refresh(git_config_backend *cfg)
214214
{
215-
diskfile_backend *b = GIT_CONTAINER_OF(cfg, diskfile_backend, parent);
215+
config_file_backend *b = GIT_CONTAINER_OF(cfg, config_file_backend, parent);
216216
git_config_entries *entries = NULL;
217217
int error, modified;
218218

@@ -239,7 +239,7 @@ static int config_refresh(git_config_backend *cfg)
239239

240240
static void backend_free(git_config_backend *_backend)
241241
{
242-
diskfile_backend *backend = GIT_CONTAINER_OF(_backend, diskfile_backend, parent);
242+
config_file_backend *backend = GIT_CONTAINER_OF(_backend, config_file_backend, parent);
243243

244244
if (backend == NULL)
245245
return;
@@ -254,7 +254,7 @@ static int config_iterator_new(
254254
git_config_iterator **iter,
255255
struct git_config_backend *backend)
256256
{
257-
diskfile_backend *b = GIT_CONTAINER_OF(backend, diskfile_backend, parent);
257+
config_file_backend *b = GIT_CONTAINER_OF(backend, config_file_backend, parent);
258258
git_config_entries *entries = NULL;
259259
int error;
260260

@@ -271,7 +271,7 @@ static int config_iterator_new(
271271

272272
static int config_set(git_config_backend *cfg, const char *name, const char *value)
273273
{
274-
diskfile_backend *b = GIT_CONTAINER_OF(cfg, diskfile_backend, parent);
274+
config_file_backend *b = GIT_CONTAINER_OF(cfg, config_file_backend, parent);
275275
git_config_entries *entries;
276276
git_config_entry *existing;
277277
char *key, *esc_value = NULL;
@@ -323,7 +323,7 @@ static void free_diskfile_entry(git_config_entry *entry)
323323
*/
324324
static int config_get(git_config_backend *cfg, const char *key, git_config_entry **out)
325325
{
326-
diskfile_backend *h = GIT_CONTAINER_OF(cfg, diskfile_backend, parent);
326+
config_file_backend *h = GIT_CONTAINER_OF(cfg, config_file_backend, parent);
327327
git_config_entries *entries = NULL;
328328
git_config_entry *entry;
329329
int error = 0;
@@ -349,7 +349,7 @@ static int config_get(git_config_backend *cfg, const char *key, git_config_entry
349349
static int config_set_multivar(
350350
git_config_backend *cfg, const char *name, const char *regexp, const char *value)
351351
{
352-
diskfile_backend *b = GIT_CONTAINER_OF(cfg, diskfile_backend, parent);
352+
config_file_backend *b = GIT_CONTAINER_OF(cfg, config_file_backend, parent);
353353
char *key;
354354
p_regex_t preg;
355355
int result;
@@ -379,7 +379,7 @@ static int config_set_multivar(
379379

380380
static int config_delete(git_config_backend *cfg, const char *name)
381381
{
382-
diskfile_backend *b = GIT_CONTAINER_OF(cfg, diskfile_backend, parent);
382+
config_file_backend *b = GIT_CONTAINER_OF(cfg, config_file_backend, parent);
383383
git_config_entries *entries = NULL;
384384
git_config_entry *entry;
385385
char *key = NULL;
@@ -409,7 +409,7 @@ static int config_delete(git_config_backend *cfg, const char *name)
409409

410410
static int config_delete_multivar(git_config_backend *cfg, const char *name, const char *regexp)
411411
{
412-
diskfile_backend *b = GIT_CONTAINER_OF(cfg, diskfile_backend, parent);
412+
config_file_backend *b = GIT_CONTAINER_OF(cfg, config_file_backend, parent);
413413
git_config_entries *entries = NULL;
414414
git_config_entry *entry = NULL;
415415
p_regex_t preg = { 0 };
@@ -448,7 +448,7 @@ static int config_delete_multivar(git_config_backend *cfg, const char *name, con
448448

449449
static int config_lock(git_config_backend *_cfg)
450450
{
451-
diskfile_backend *cfg = GIT_CONTAINER_OF(_cfg, diskfile_backend, parent);
451+
config_file_backend *cfg = GIT_CONTAINER_OF(_cfg, config_file_backend, parent);
452452
int error;
453453

454454
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)
467467

468468
static int config_unlock(git_config_backend *_cfg, int success)
469469
{
470-
diskfile_backend *cfg = GIT_CONTAINER_OF(_cfg, diskfile_backend, parent);
470+
config_file_backend *cfg = GIT_CONTAINER_OF(_cfg, config_file_backend, parent);
471471
int error = 0;
472472

473473
if (success) {
@@ -484,9 +484,9 @@ static int config_unlock(git_config_backend *_cfg, int success)
484484

485485
int git_config_backend_from_file(git_config_backend **out, const char *path)
486486
{
487-
diskfile_backend *backend;
487+
config_file_backend *backend;
488488

489-
backend = git__calloc(1, sizeof(diskfile_backend));
489+
backend = git__calloc(1, sizeof(config_file_backend));
490490
GIT_ERROR_CHECK_ALLOC(backend);
491491

492492
backend->parent.version = GIT_CONFIG_BACKEND_VERSION;
@@ -554,9 +554,9 @@ static char *escape_value(const char *ptr)
554554
return git_buf_detach(&buf);
555555
}
556556

557-
static int parse_include(diskfile_parse_state *parse_data, const char *file)
557+
static int parse_include(config_file_parse_data *parse_data, const char *file)
558558
{
559-
diskfile *include;
559+
config_file *include;
560560
git_buf path = GIT_BUF_INIT;
561561
char *dir;
562562
int result;
@@ -659,7 +659,7 @@ static const struct {
659659
{ "gitdir/i:", conditional_match_gitdir_i }
660660
};
661661

662-
static int parse_conditional_include(diskfile_parse_state *parse_data, const char *section, const char *file)
662+
static int parse_conditional_include(config_file_parse_data *parse_data, const char *section, const char *file)
663663
{
664664
char *condition;
665665
size_t i;
@@ -700,7 +700,7 @@ static int read_on_variable(
700700
size_t line_len,
701701
void *data)
702702
{
703-
diskfile_parse_state *parse_data = (diskfile_parse_state *)data;
703+
config_file_parse_data *parse_data = (config_file_parse_data *)data;
704704
git_buf buf = GIT_BUF_INIT;
705705
git_config_entry *entry;
706706
const char *c;
@@ -750,13 +750,13 @@ static int read_on_variable(
750750
static int config_read_buffer(
751751
git_config_entries *entries,
752752
const git_repository *repo,
753-
diskfile *file,
753+
config_file *file,
754754
git_config_level_t level,
755755
int depth,
756756
const char *buf,
757757
size_t buflen)
758758
{
759-
diskfile_parse_state parse_data;
759+
config_file_parse_data parse_data;
760760
git_config_parser reader;
761761
int error;
762762

@@ -790,7 +790,7 @@ static int config_read_buffer(
790790
static int config_read(
791791
git_config_entries *entries,
792792
const git_repository *repo,
793-
diskfile *file,
793+
config_file *file,
794794
git_config_level_t level,
795795
int depth)
796796
{
@@ -1042,7 +1042,7 @@ static int write_on_eof(
10421042
/*
10431043
* This is pretty much the parsing, except we write out anything we don't have
10441044
*/
1045-
static int config_write(diskfile_backend *cfg, const char *orig_key, const char *key, const p_regex_t *preg, const char* value)
1045+
static int config_write(config_file_backend *cfg, const char *orig_key, const char *key, const p_regex_t *preg, const char* value)
10461046
{
10471047
char *orig_section = NULL, *section = NULL, *orig_name, *name, *ldot;
10481048
git_buf buf = GIT_BUF_INIT, contents = GIT_BUF_INIT;

src/config_snapshot.c

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ typedef struct {
1414
git_mutex values_mutex;
1515
git_config_entries *entries;
1616
git_config_backend *source;
17-
} diskfile_readonly_backend;
17+
} config_snapshot_backend;
1818

1919
static int config_error_readonly(void)
2020
{
@@ -26,7 +26,7 @@ static int config_iterator_new_readonly(
2626
git_config_iterator **iter,
2727
struct git_config_backend *backend)
2828
{
29-
diskfile_readonly_backend *b = GIT_CONTAINER_OF(backend, diskfile_readonly_backend, parent);
29+
config_snapshot_backend *b = GIT_CONTAINER_OF(backend, config_snapshot_backend, parent);
3030
git_config_entries *entries = NULL;
3131
int error;
3232

@@ -49,7 +49,7 @@ static void free_diskfile_entry(git_config_entry *entry)
4949

5050
static int config_get_readonly(git_config_backend *cfg, const char *key, git_config_entry **out)
5151
{
52-
diskfile_readonly_backend *b = GIT_CONTAINER_OF(cfg, diskfile_readonly_backend, parent);
52+
config_snapshot_backend *b = GIT_CONTAINER_OF(cfg, config_snapshot_backend, parent);
5353
git_config_entries *entries = NULL;
5454
git_config_entry *entry;
5555
int error = 0;
@@ -129,7 +129,7 @@ static int config_unlock_readonly(git_config_backend *_cfg, int success)
129129

130130
static void backend_readonly_free(git_config_backend *_backend)
131131
{
132-
diskfile_readonly_backend *backend = GIT_CONTAINER_OF(_backend, diskfile_readonly_backend, parent);
132+
config_snapshot_backend *backend = GIT_CONTAINER_OF(_backend, config_snapshot_backend, parent);
133133

134134
if (backend == NULL)
135135
return;
@@ -141,7 +141,7 @@ static void backend_readonly_free(git_config_backend *_backend)
141141

142142
static int config_readonly_open(git_config_backend *cfg, git_config_level_t level, const git_repository *repo)
143143
{
144-
diskfile_readonly_backend *b = GIT_CONTAINER_OF(cfg, diskfile_readonly_backend, parent);
144+
config_snapshot_backend *b = GIT_CONTAINER_OF(cfg, config_snapshot_backend, parent);
145145
git_config_entries *entries = NULL;
146146
git_config_iterator *it = NULL;
147147
git_config_entry *entry;
@@ -176,9 +176,9 @@ static int config_readonly_open(git_config_backend *cfg, git_config_level_t leve
176176

177177
int git_config_backend_snapshot(git_config_backend **out, git_config_backend *source)
178178
{
179-
diskfile_readonly_backend *backend;
179+
config_snapshot_backend *backend;
180180

181-
backend = git__calloc(1, sizeof(diskfile_readonly_backend));
181+
backend = git__calloc(1, sizeof(config_snapshot_backend));
182182
GIT_ERROR_CHECK_ALLOC(backend);
183183

184184
backend->parent.version = GIT_CONFIG_BACKEND_VERSION;

0 commit comments

Comments
 (0)