@@ -1203,32 +1203,31 @@ int git_config_system(void)
12031203 return !git_env_bool ("GIT_CONFIG_NOSYSTEM" , 0 );
12041204}
12051205
1206+ static inline void config_from_file_gently (config_fn_t fn , const char * filename ,
1207+ void * data , unsigned access_flags , int * ret , int * found ) {
1208+ if (!filename || access_or_die (filename , R_OK , access_flags ))
1209+ return ;
1210+
1211+ * ret += git_config_from_file (fn , filename , data );
1212+ (* found )++ ;
1213+ }
1214+
12061215int git_config_early (config_fn_t fn , void * data , const char * repo_config )
12071216{
12081217 int ret = 0 , found = 0 ;
12091218 char * xdg_config = xdg_config_home ("config" );
12101219 char * user_config = expand_user_path ("~/.gitconfig" );
12111220
1212- if (git_config_system () && !access_or_die (git_etc_gitconfig (), R_OK , 0 )) {
1213- ret += git_config_from_file (fn , git_etc_gitconfig (),
1214- data );
1215- found += 1 ;
1216- }
1221+ if (git_config_system ())
1222+ config_from_file_gently (fn , git_etc_gitconfig (), data , 0 ,
1223+ & ret , & found );
12171224
1218- if (xdg_config && !access_or_die (xdg_config , R_OK , ACCESS_EACCES_OK )) {
1219- ret += git_config_from_file (fn , xdg_config , data );
1220- found += 1 ;
1221- }
1222-
1223- if (user_config && !access_or_die (user_config , R_OK , ACCESS_EACCES_OK )) {
1224- ret += git_config_from_file (fn , user_config , data );
1225- found += 1 ;
1226- }
1225+ config_from_file_gently (fn , xdg_config , data , ACCESS_EACCES_OK ,
1226+ & ret , & found );
1227+ config_from_file_gently (fn , user_config , data , ACCESS_EACCES_OK ,
1228+ & ret , & found );
12271229
1228- if (repo_config && !access_or_die (repo_config , R_OK , 0 )) {
1229- ret += git_config_from_file (fn , repo_config , data );
1230- found += 1 ;
1231- }
1230+ config_from_file_gently (fn , repo_config , data , 0 , & ret , & found );
12321231
12331232 switch (git_config_from_parameters (fn , data )) {
12341233 case -1 : /* error */
0 commit comments