Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 1785de4

Browse files
committed
config: move the level field into the header
We use it in a few places where we might have a full object or a snapshot so move it to where we can actually access it.
1 parent c1524b2 commit 1785de4

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

src/config_file.c

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -87,13 +87,12 @@ typedef struct {
8787
git_mutex values_mutex;
8888
refcounted_strmap *values;
8989
const git_repository *repo;
90+
git_config_level_t level;
9091
} diskfile_header;
9192

9293
typedef struct {
9394
diskfile_header header;
9495

95-
git_config_level_t level;
96-
9796
git_array_t(git_config_parser) readers;
9897

9998
bool locked;
@@ -270,7 +269,7 @@ static int config_open(git_config_backend *cfg, git_config_level_t level, const
270269
int res;
271270
diskfile_backend *b = (diskfile_backend *)cfg;
272271

273-
b->level = level;
272+
b->header.level = level;
274273
b->header.repo = repo;
275274

276275
if ((res = refcounted_strmap_alloc(&b->header.values)) < 0)
@@ -343,7 +342,7 @@ static int config_refresh(git_config_backend *cfg)
343342
}
344343
git_array_clear(b->file.includes);
345344

346-
if ((error = config_read(values->values, b->header.repo, &b->file, b->level, 0)) < 0)
345+
if ((error = config_read(values->values, b->header.repo, &b->file, b->header.level, 0)) < 0)
347346
goto out;
348347

349348
if ((error = git_mutex_lock(&b->header.values_mutex)) < 0) {
@@ -423,7 +422,7 @@ static int config_iterator_new(
423422
if ((error = config_snapshot(&snapshot, backend)) < 0)
424423
return error;
425424

426-
if ((error = snapshot->open(snapshot, b->level, b->header.repo)) < 0)
425+
if ((error = snapshot->open(snapshot, b->header.level, b->header.repo)) < 0)
427426
return error;
428427

429428
it = git__calloc(1, sizeof(git_config_file_iter));

0 commit comments

Comments
 (0)