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

Skip to content

Commit c1524b2

Browse files
committed
config: move the repository to the diskfile header
We pass this around and when creating a new iterator we need to read the repository pointer. Put it in a common place so we can reach it regardless of whether we got a full object or a snapshot.
1 parent c9d59c6 commit c1524b2

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

src/config_file.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -86,13 +86,13 @@ typedef struct {
8686
/* mutex to coordinate accessing the values */
8787
git_mutex values_mutex;
8888
refcounted_strmap *values;
89+
const git_repository *repo;
8990
} diskfile_header;
9091

9192
typedef struct {
9293
diskfile_header header;
9394

9495
git_config_level_t level;
95-
const git_repository *repo;
9696

9797
git_array_t(git_config_parser) readers;
9898

@@ -271,7 +271,7 @@ static int config_open(git_config_backend *cfg, git_config_level_t level, const
271271
diskfile_backend *b = (diskfile_backend *)cfg;
272272

273273
b->level = level;
274-
b->repo = repo;
274+
b->header.repo = repo;
275275

276276
if ((res = refcounted_strmap_alloc(&b->header.values)) < 0)
277277
return res;
@@ -343,7 +343,7 @@ static int config_refresh(git_config_backend *cfg)
343343
}
344344
git_array_clear(b->file.includes);
345345

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

349349
if ((error = git_mutex_lock(&b->header.values_mutex)) < 0) {
@@ -423,7 +423,7 @@ static int config_iterator_new(
423423
if ((error = config_snapshot(&snapshot, backend)) < 0)
424424
return error;
425425

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

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

0 commit comments

Comments
 (0)