@@ -86,14 +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 ;
90+ git_config_level_t level ;
8991} diskfile_header ;
9092
9193typedef struct {
9294 diskfile_header header ;
9395
94- git_config_level_t level ;
95- const git_repository * repo ;
96-
9796 git_array_t (git_config_parser ) readers ;
9897
9998 bool locked ;
@@ -270,8 +269,8 @@ 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 ;
274- b -> repo = repo ;
272+ b -> header . level = level ;
273+ b -> header . repo = repo ;
275274
276275 if ((res = refcounted_strmap_alloc (& b -> header .values )) < 0 )
277276 return res ;
@@ -327,6 +326,9 @@ static int config_refresh(git_config_backend *cfg)
327326 int error , modified ;
328327 uint32_t i ;
329328
329+ if (b -> header .parent .readonly )
330+ return config_error_readonly ();
331+
330332 error = config_is_modified (& modified , & b -> file );
331333 if (error < 0 && error != GIT_ENOTFOUND )
332334 goto out ;
@@ -343,7 +345,7 @@ static int config_refresh(git_config_backend *cfg)
343345 }
344346 git_array_clear (b -> file .includes );
345347
346- if ((error = config_read (values -> values , b -> repo , & b -> file , b -> level , 0 )) < 0 )
348+ if ((error = config_read (values -> values , b -> header . repo , & b -> file , b -> header . level , 0 )) < 0 )
347349 goto out ;
348350
349351 if ((error = git_mutex_lock (& b -> header .values_mutex )) < 0 ) {
@@ -417,13 +419,13 @@ static int config_iterator_new(
417419 diskfile_header * h ;
418420 git_config_file_iter * it ;
419421 git_config_backend * snapshot ;
420- diskfile_backend * b = (diskfile_backend * ) backend ;
422+ diskfile_header * bh = (diskfile_header * ) backend ;
421423 int error ;
422424
423425 if ((error = config_snapshot (& snapshot , backend )) < 0 )
424426 return error ;
425427
426- if ((error = snapshot -> open (snapshot , b -> level , b -> repo )) < 0 )
428+ if ((error = snapshot -> open (snapshot , bh -> level , bh -> repo )) < 0 )
427429 return error ;
428430
429431 it = git__calloc (1 , sizeof (git_config_file_iter ));
0 commit comments