@@ -39,14 +39,14 @@ typedef struct git_config_file_iter {
3939
4040typedef struct {
4141 git_atomic refcount ;
42- git_strmap * values ;
43- } refcounted_strmap ;
42+ git_strmap * map ;
43+ } diskfile_entries ;
4444
4545typedef struct {
4646 git_config_backend parent ;
4747 /* mutex to coordinate accessing the values */
4848 git_mutex values_mutex ;
49- refcounted_strmap * values ;
49+ diskfile_entries * entries ;
5050 const git_repository * repo ;
5151 git_config_level_t level ;
5252} diskfile_header ;
@@ -157,57 +157,57 @@ static int append_entry(git_strmap *values, git_config_entry *entry)
157157 return error ;
158158}
159159
160- static void refcounted_strmap_free ( refcounted_strmap * map )
160+ static void diskfile_entries_free ( diskfile_entries * entries )
161161{
162162 config_entry_list * list = NULL ;
163163
164- if (!map )
164+ if (!entries )
165165 return ;
166166
167- if (git_atomic_dec (& map -> refcount ) != 0 )
167+ if (git_atomic_dec (& entries -> refcount ) != 0 )
168168 return ;
169169
170- git_strmap_foreach_value (map -> values , list , config_entry_list_free (list ));
171- git_strmap_free (map -> values );
172- git__free (map );
170+ git_strmap_foreach_value (entries -> map , list , config_entry_list_free (list ));
171+ git_strmap_free (entries -> map );
172+ git__free (entries );
173173}
174174
175175/**
176176 * Take the current values map from the backend and increase its
177177 * refcount. This is its own function to make sure we use the mutex to
178178 * avoid the map pointer from changing under us.
179179 */
180- static refcounted_strmap * refcounted_strmap_take (diskfile_header * h )
180+ static diskfile_entries * diskfile_entries_take (diskfile_header * h )
181181{
182- refcounted_strmap * map ;
182+ diskfile_entries * entries ;
183183
184184 if (git_mutex_lock (& h -> values_mutex ) < 0 ) {
185185 giterr_set (GITERR_OS , "failed to lock config backend" );
186186 return NULL ;
187187 }
188188
189- map = h -> values ;
190- git_atomic_inc (& map -> refcount );
189+ entries = h -> entries ;
190+ git_atomic_inc (& entries -> refcount );
191191
192192 git_mutex_unlock (& h -> values_mutex );
193193
194- return map ;
194+ return entries ;
195195}
196196
197- static int refcounted_strmap_alloc ( refcounted_strmap * * out )
197+ static int diskfile_entries_alloc ( diskfile_entries * * out )
198198{
199- refcounted_strmap * map ;
199+ diskfile_entries * entries ;
200200 int error ;
201201
202- map = git__calloc (1 , sizeof (refcounted_strmap ));
203- GITERR_CHECK_ALLOC (map );
202+ entries = git__calloc (1 , sizeof (diskfile_entries ));
203+ GITERR_CHECK_ALLOC (entries );
204204
205- git_atomic_set (& map -> refcount , 1 );
205+ git_atomic_set (& entries -> refcount , 1 );
206206
207- if ((error = git_strmap_alloc (& map -> values )) < 0 )
208- git__free (map );
207+ if ((error = git_strmap_alloc (& entries -> map )) < 0 )
208+ git__free (entries );
209209 else
210- * out = map ;
210+ * out = entries ;
211211
212212 return error ;
213213}
@@ -236,15 +236,15 @@ static int config_open(git_config_backend *cfg, git_config_level_t level, const
236236 b -> header .level = level ;
237237 b -> header .repo = repo ;
238238
239- if ((res = refcounted_strmap_alloc (& b -> header .values )) < 0 )
239+ if ((res = diskfile_entries_alloc (& b -> header .entries )) < 0 )
240240 return res ;
241241
242242 if (!git_path_exists (b -> file .path ))
243243 return 0 ;
244244
245- if (res < 0 || (res = config_read (b -> header .values -> values , repo , & b -> file , level , 0 )) < 0 ) {
246- refcounted_strmap_free (b -> header .values );
247- b -> header .values = NULL ;
245+ if (res < 0 || (res = config_read (b -> header .entries -> map , repo , & b -> file , level , 0 )) < 0 ) {
246+ diskfile_entries_free (b -> header .entries );
247+ b -> header .entries = NULL ;
248248 }
249249
250250 return res ;
@@ -285,7 +285,7 @@ static int config_is_modified(int *modified, struct config_file *file)
285285static int config_refresh (git_config_backend * cfg )
286286{
287287 diskfile_backend * b = (diskfile_backend * )cfg ;
288- refcounted_strmap * values = NULL , * tmp ;
288+ diskfile_entries * entries = NULL , * tmp ;
289289 git_config_file * include ;
290290 int error , modified ;
291291 uint32_t i ;
@@ -300,7 +300,7 @@ static int config_refresh(git_config_backend *cfg)
300300 if (!modified )
301301 return 0 ;
302302
303- if ((error = refcounted_strmap_alloc ( & values )) < 0 )
303+ if ((error = diskfile_entries_alloc ( & entries )) < 0 )
304304 goto out ;
305305
306306 /* Reparse the current configuration */
@@ -309,22 +309,22 @@ static int config_refresh(git_config_backend *cfg)
309309 }
310310 git_array_clear (b -> file .includes );
311311
312- if ((error = config_read (values -> values , b -> header .repo , & b -> file , b -> header .level , 0 )) < 0 )
312+ if ((error = config_read (entries -> map , b -> header .repo , & b -> file , b -> header .level , 0 )) < 0 )
313313 goto out ;
314314
315315 if ((error = git_mutex_lock (& b -> header .values_mutex )) < 0 ) {
316316 giterr_set (GITERR_OS , "failed to lock config backend" );
317317 goto out ;
318318 }
319319
320- tmp = b -> header .values ;
321- b -> header .values = values ;
322- values = tmp ;
320+ tmp = b -> header .entries ;
321+ b -> header .entries = entries ;
322+ entries = tmp ;
323323
324324 git_mutex_unlock (& b -> header .values_mutex );
325325
326326out :
327- refcounted_strmap_free ( values );
327+ diskfile_entries_free ( entries );
328328
329329 return (error == GIT_ENOTFOUND ) ? 0 : error ;
330330}
@@ -337,7 +337,7 @@ static void backend_free(git_config_backend *_backend)
337337 return ;
338338
339339 config_file_clear (& backend -> file );
340- refcounted_strmap_free (backend -> header .values );
340+ diskfile_entries_free (backend -> header .entries );
341341 git_mutex_free (& backend -> header .values_mutex );
342342 git__free (backend );
343343}
@@ -355,12 +355,12 @@ static int config_iterator_next(
355355{
356356 git_config_file_iter * it = (git_config_file_iter * ) iter ;
357357 diskfile_header * h = (diskfile_header * ) it -> parent .backend ;
358- git_strmap * values = h -> values -> values ;
358+ git_strmap * entry_map = h -> entries -> map ;
359359 int err = 0 ;
360360 config_entry_list * var ;
361361
362362 if (it -> next_var == NULL ) {
363- err = git_strmap_next ((void * * ) & var , & (it -> iter ), values );
363+ err = git_strmap_next ((void * * ) & var , & (it -> iter ), entry_map );
364364 } else {
365365 var = it -> next_var ;
366366 }
@@ -414,26 +414,26 @@ static int config_iterator_new(
414414static int config_set (git_config_backend * cfg , const char * name , const char * value )
415415{
416416 diskfile_backend * b = (diskfile_backend * )cfg ;
417- refcounted_strmap * map ;
418- git_strmap * values ;
417+ diskfile_entries * entries ;
418+ git_strmap * entry_map ;
419419 char * key , * esc_value = NULL ;
420420 khiter_t pos ;
421421 int rval , ret ;
422422
423423 if ((rval = git_config__normalize_name (name , & key )) < 0 )
424424 return rval ;
425425
426- if ((map = refcounted_strmap_take (& b -> header )) == NULL )
426+ if ((entries = diskfile_entries_take (& b -> header )) == NULL )
427427 return -1 ;
428- values = map -> values ;
428+ entry_map = entries -> map ;
429429
430430 /*
431431 * Try to find it in the existing values and update it if it
432432 * only has one value.
433433 */
434- pos = git_strmap_lookup_index (values , key );
435- if (git_strmap_valid_index (values , pos )) {
436- config_entry_list * existing = git_strmap_value_at (values , pos );
434+ pos = git_strmap_lookup_index (entry_map , key );
435+ if (git_strmap_valid_index (entry_map , pos )) {
436+ config_entry_list * existing = git_strmap_value_at (entry_map , pos );
437437
438438 if (existing -> next != NULL ) {
439439 giterr_set (GITERR_CONFIG , "multivar incompatible with simple set" );
@@ -469,17 +469,17 @@ static int config_set(git_config_backend *cfg, const char *name, const char *val
469469 ret = config_refresh (cfg );
470470
471471out :
472- refcounted_strmap_free ( map );
472+ diskfile_entries_free ( entries );
473473 git__free (esc_value );
474474 git__free (key );
475475 return ret ;
476476}
477477
478478/* release the map containing the entry as an equivalent to freeing it */
479- static void release_map (git_config_entry * entry )
479+ static void free_diskfile_entry (git_config_entry * entry )
480480{
481- refcounted_strmap * map = (refcounted_strmap * ) entry -> payload ;
482- refcounted_strmap_free (map );
481+ diskfile_entries * map = (diskfile_entries * ) entry -> payload ;
482+ diskfile_entries_free (map );
483483}
484484
485485/*
@@ -488,34 +488,34 @@ static void release_map(git_config_entry *entry)
488488static int config_get (git_config_backend * cfg , const char * key , git_config_entry * * out )
489489{
490490 diskfile_header * h = (diskfile_header * )cfg ;
491- refcounted_strmap * map ;
492- git_strmap * values ;
491+ diskfile_entries * entries ;
492+ git_strmap * entry_map ;
493493 khiter_t pos ;
494494 config_entry_list * var ;
495495 int error = 0 ;
496496
497497 if (!h -> parent .readonly && ((error = config_refresh (cfg )) < 0 ))
498498 return error ;
499499
500- if ((map = refcounted_strmap_take (h )) == NULL )
500+ if ((entries = diskfile_entries_take (h )) == NULL )
501501 return -1 ;
502- values = map -> values ;
502+ entry_map = entries -> map ;
503503
504- pos = git_strmap_lookup_index (values , key );
504+ pos = git_strmap_lookup_index (entry_map , key );
505505
506506 /* no error message; the config system will write one */
507- if (!git_strmap_valid_index (values , pos )) {
508- refcounted_strmap_free ( map );
507+ if (!git_strmap_valid_index (entry_map , pos )) {
508+ diskfile_entries_free ( entries );
509509 return GIT_ENOTFOUND ;
510510 }
511511
512- var = git_strmap_value_at (values , pos );
512+ var = git_strmap_value_at (entry_map , pos );
513513 while (var -> next )
514514 var = var -> next ;
515515
516516 * out = var -> entry ;
517- (* out )-> free = release_map ;
518- (* out )-> payload = map ;
517+ (* out )-> free = free_diskfile_entry ;
518+ (* out )-> payload = entries ;
519519
520520 return error ;
521521}
@@ -557,30 +557,30 @@ static int config_delete(git_config_backend *cfg, const char *name)
557557{
558558 config_entry_list * var ;
559559 diskfile_backend * b = (diskfile_backend * )cfg ;
560- refcounted_strmap * map ;
561- git_strmap * values ;
560+ diskfile_entries * map ;
561+ git_strmap * entry_map ;
562562 char * key ;
563563 int result ;
564564 khiter_t pos ;
565565
566566 if ((result = git_config__normalize_name (name , & key )) < 0 )
567567 return result ;
568568
569- if ((map = refcounted_strmap_take (& b -> header )) == NULL )
569+ if ((map = diskfile_entries_take (& b -> header )) == NULL )
570570 return -1 ;
571- values = b -> header .values -> values ;
571+ entry_map = b -> header .entries -> map ;
572572
573- pos = git_strmap_lookup_index (values , key );
573+ pos = git_strmap_lookup_index (entry_map , key );
574574 git__free (key );
575575
576- if (!git_strmap_valid_index (values , pos )) {
577- refcounted_strmap_free (map );
576+ if (!git_strmap_valid_index (entry_map , pos )) {
577+ diskfile_entries_free (map );
578578 giterr_set (GITERR_CONFIG , "could not find key '%s' to delete" , name );
579579 return GIT_ENOTFOUND ;
580580 }
581581
582- var = git_strmap_value_at (values , pos );
583- refcounted_strmap_free (map );
582+ var = git_strmap_value_at (entry_map , pos );
583+ diskfile_entries_free (map );
584584
585585 if (var -> entry -> include_depth ) {
586586 giterr_set (GITERR_CONFIG , "cannot delete included variable" );
@@ -601,8 +601,8 @@ static int config_delete(git_config_backend *cfg, const char *name)
601601static int config_delete_multivar (git_config_backend * cfg , const char * name , const char * regexp )
602602{
603603 diskfile_backend * b = (diskfile_backend * )cfg ;
604- refcounted_strmap * map ;
605- git_strmap * values ;
604+ diskfile_entries * map ;
605+ git_strmap * entry_map ;
606606 char * key ;
607607 regex_t preg ;
608608 int result ;
@@ -611,20 +611,20 @@ static int config_delete_multivar(git_config_backend *cfg, const char *name, con
611611 if ((result = git_config__normalize_name (name , & key )) < 0 )
612612 return result ;
613613
614- if ((map = refcounted_strmap_take (& b -> header )) == NULL )
614+ if ((map = diskfile_entries_take (& b -> header )) == NULL )
615615 return -1 ;
616- values = b -> header .values -> values ;
616+ entry_map = b -> header .entries -> map ;
617617
618- pos = git_strmap_lookup_index (values , key );
618+ pos = git_strmap_lookup_index (entry_map , key );
619619
620- if (!git_strmap_valid_index (values , pos )) {
621- refcounted_strmap_free (map );
620+ if (!git_strmap_valid_index (entry_map , pos )) {
621+ diskfile_entries_free (map );
622622 git__free (key );
623623 giterr_set (GITERR_CONFIG , "could not find key '%s' to delete" , name );
624624 return GIT_ENOTFOUND ;
625625 }
626626
627- refcounted_strmap_free (map );
627+ diskfile_entries_free (map );
628628
629629 result = p_regcomp (& preg , regexp , REG_EXTENDED );
630630 if (result != 0 ) {
@@ -777,7 +777,7 @@ static void backend_readonly_free(git_config_backend *_backend)
777777 if (backend == NULL )
778778 return ;
779779
780- refcounted_strmap_free (backend -> header .values );
780+ diskfile_entries_free (backend -> header .entries );
781781 git_mutex_free (& backend -> header .values_mutex );
782782 git__free (backend );
783783}
@@ -787,7 +787,7 @@ static int config_readonly_open(git_config_backend *cfg, git_config_level_t leve
787787 diskfile_readonly_backend * b = (diskfile_readonly_backend * ) cfg ;
788788 diskfile_backend * src = b -> snapshot_from ;
789789 diskfile_header * src_header = & src -> header ;
790- refcounted_strmap * src_map ;
790+ diskfile_entries * entries ;
791791 int error ;
792792
793793 if (!src_header -> parent .readonly && (error = config_refresh (& src_header -> parent )) < 0 )
@@ -797,9 +797,9 @@ static int config_readonly_open(git_config_backend *cfg, git_config_level_t leve
797797 GIT_UNUSED (level );
798798 GIT_UNUSED (repo );
799799
800- if ((src_map = refcounted_strmap_take (src_header )) == NULL )
800+ if ((entries = diskfile_entries_take (src_header )) == NULL )
801801 return -1 ;
802- b -> header .values = src_map ;
802+ b -> header .entries = entries ;
803803
804804 return 0 ;
805805}
0 commit comments