@@ -1207,32 +1207,31 @@ int git_config_system(void)
1207
1207
return !git_env_bool ("GIT_CONFIG_NOSYSTEM" , 0 );
1208
1208
}
1209
1209
1210
+ static inline void config_from_file_gently (config_fn_t fn , const char * filename ,
1211
+ void * data , unsigned access_flags , int * ret , int * found ) {
1212
+ if (!filename || access_or_die (filename , R_OK , access_flags ))
1213
+ return ;
1214
+
1215
+ * ret += git_config_from_file (fn , filename , data );
1216
+ (* found )++ ;
1217
+ }
1218
+
1210
1219
int git_config_early (config_fn_t fn , void * data , const char * repo_config )
1211
1220
{
1212
1221
int ret = 0 , found = 0 ;
1213
1222
char * xdg_config = xdg_config_home ("config" );
1214
1223
char * user_config = expand_user_path ("~/.gitconfig" );
1215
1224
1216
- if (git_config_system () && !access_or_die (git_etc_gitconfig (), R_OK , 0 )) {
1217
- ret += git_config_from_file (fn , git_etc_gitconfig (),
1218
- data );
1219
- found += 1 ;
1220
- }
1225
+ if (git_config_system ())
1226
+ config_from_file_gently (fn , git_etc_gitconfig (), data , 0 ,
1227
+ & ret , & found );
1221
1228
1222
- if (xdg_config && !access_or_die (xdg_config , R_OK , ACCESS_EACCES_OK )) {
1223
- ret += git_config_from_file (fn , xdg_config , data );
1224
- found += 1 ;
1225
- }
1226
-
1227
- if (user_config && !access_or_die (user_config , R_OK , ACCESS_EACCES_OK )) {
1228
- ret += git_config_from_file (fn , user_config , data );
1229
- found += 1 ;
1230
- }
1229
+ config_from_file_gently (fn , xdg_config , data , ACCESS_EACCES_OK ,
1230
+ & ret , & found );
1231
+ config_from_file_gently (fn , user_config , data , ACCESS_EACCES_OK ,
1232
+ & ret , & found );
1231
1233
1232
- if (repo_config && !access_or_die (repo_config , R_OK , 0 )) {
1233
- ret += git_config_from_file (fn , repo_config , data );
1234
- found += 1 ;
1235
- }
1234
+ config_from_file_gently (fn , repo_config , data , 0 , & ret , & found );
1236
1235
1237
1236
switch (git_config_from_parameters (fn , data )) {
1238
1237
case -1 : /* error */
0 commit comments