Skip to content

Commit 820fa1a

Browse files
committed
config_file: internalize git_config_file struct
With the previous commits, we have finally separated the config parsing logic from the specific configuration file backend. Due to that, we can now move the `git_config_file` structure into the config file backend's implementation so that no other code may accidentally start using it again. Furthermore, we rename the structure to `diskfile` to make it obvious that it is internal, only, and to unify it with naming scheme of the other diskfile structures.
1 parent 6e6da75 commit 820fa1a

File tree

2 files changed

+20
-20
lines changed

2 files changed

+20
-20
lines changed

src/config_file.c

Lines changed: 20 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,13 @@
2626
/* Max depth for [include] directives */
2727
#define MAX_INCLUDE_DEPTH 10
2828

29+
typedef struct diskfile {
30+
git_futils_filestamp stamp;
31+
git_oid checksum;
32+
char *path;
33+
git_array_t(struct diskfile) includes;
34+
} diskfile;
35+
2936
typedef struct {
3037
git_config_backend parent;
3138
/* mutex to coordinate accessing the values */
@@ -44,7 +51,7 @@ typedef struct {
4451
git_filebuf locked_buf;
4552
git_buf locked_content;
4653

47-
git_config_file file;
54+
diskfile file;
4855
} diskfile_backend;
4956

5057
typedef struct {
@@ -55,14 +62,14 @@ typedef struct {
5562

5663
typedef struct {
5764
const git_repository *repo;
58-
git_config_file *file;
65+
diskfile *file;
5966
git_config_entries *entries;
6067
git_config_level_t level;
6168
unsigned int depth;
6269
} diskfile_parse_state;
6370

64-
static int config_read(git_config_entries *entries, const git_repository *repo, git_config_file *file, git_config_level_t level, int depth);
65-
static int config_read_buffer(git_config_entries *entries, const git_repository *repo, git_config_file *file, git_config_level_t level, int depth, const char *buf, size_t buflen);
71+
static int config_read(git_config_entries *entries, const git_repository *repo, diskfile *file, git_config_level_t level, int depth);
72+
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);
6673
static int config_write(diskfile_backend *cfg, const char *orig_key, const char *key, const p_regex_t *preg, const char *value);
6774
static char *escape_value(const char *ptr);
6875

@@ -96,9 +103,9 @@ static git_config_entries *diskfile_entries_take(diskfile_header *h)
96103
return entries;
97104
}
98105

99-
static void config_file_clear(git_config_file *file)
106+
static void config_file_clear(diskfile *file)
100107
{
101-
git_config_file *include;
108+
diskfile *include;
102109
uint32_t i;
103110

104111
if (file == NULL)
@@ -134,9 +141,9 @@ static int config_open(git_config_backend *cfg, git_config_level_t level, const
134141
return res;
135142
}
136143

137-
static int config_is_modified(int *modified, git_config_file *file)
144+
static int config_is_modified(int *modified, diskfile *file)
138145
{
139-
git_config_file *include;
146+
diskfile *include;
140147
git_buf buf = GIT_BUF_INIT;
141148
git_oid hash;
142149
uint32_t i;
@@ -174,9 +181,9 @@ static int config_set_entries(git_config_backend *cfg, git_config_entries *entri
174181
{
175182
diskfile_backend *b = (diskfile_backend *)cfg;
176183
git_config_entries *old = NULL;
177-
git_config_file *include;
184+
diskfile *include;
178185
int error;
179-
size_t i;
186+
uint32_t i;
180187

181188
if (b->header.parent.readonly)
182189
return config_error_readonly();
@@ -679,7 +686,7 @@ static char *escape_value(const char *ptr)
679686

680687
static int parse_include(diskfile_parse_state *parse_data, const char *file)
681688
{
682-
git_config_file *include;
689+
diskfile *include;
683690
git_buf path = GIT_BUF_INIT;
684691
char *dir;
685692
int result;
@@ -873,7 +880,7 @@ static int read_on_variable(
873880
static int config_read_buffer(
874881
git_config_entries *entries,
875882
const git_repository *repo,
876-
git_config_file *file,
883+
diskfile *file,
877884
git_config_level_t level,
878885
int depth,
879886
const char *buf,
@@ -913,7 +920,7 @@ static int config_read_buffer(
913920
static int config_read(
914921
git_config_entries *entries,
915922
const git_repository *repo,
916-
git_config_file *file,
923+
diskfile *file,
917924
git_config_level_t level,
918925
int depth)
919926
{

src/config_parse.h

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,6 @@
1717
extern const char *git_config_escapes;
1818
extern const char *git_config_escaped;
1919

20-
typedef struct config_file {
21-
git_futils_filestamp stamp;
22-
git_oid checksum;
23-
char *path;
24-
git_array_t(struct config_file) includes;
25-
} git_config_file;
26-
2720
typedef struct {
2821
const char *path;
2922
git_parse_ctx ctx;

0 commit comments

Comments
 (0)