@@ -798,6 +798,7 @@ static int cmd_config_get(int argc, const char **argv, const char *prefix)
798
798
OPT_STRING (0 , "default" , & default_value , N_ ("value" ), N_ ("use default value when missing entry" )),
799
799
OPT_END (),
800
800
};
801
+ int ret ;
801
802
802
803
argc = parse_options (argc , argv , prefix , opts , builtin_config_get_usage ,
803
804
PARSE_OPT_STOP_AT_NON_OPTION );
@@ -816,8 +817,11 @@ static int cmd_config_get(int argc, const char **argv, const char *prefix)
816
817
setup_auto_pager ("config" , 1 );
817
818
818
819
if (url )
819
- return get_urlmatch (argv [0 ], url );
820
- return get_value (argv [0 ], value_pattern , flags );
820
+ ret = get_urlmatch (argv [0 ], url );
821
+ else
822
+ ret = get_value (argv [0 ], value_pattern , flags );
823
+
824
+ return ret ;
821
825
}
822
826
823
827
static int cmd_config_set (int argc , const char * * argv , const char * prefix )
@@ -888,6 +892,7 @@ static int cmd_config_unset(int argc, const char **argv, const char *prefix)
888
892
OPT_BIT (0 , "fixed-value" , & flags , N_ ("use string equality when comparing values to value pattern" ), CONFIG_FLAGS_FIXED_VALUE ),
889
893
OPT_END (),
890
894
};
895
+ int ret ;
891
896
892
897
argc = parse_options (argc , argv , prefix , opts , builtin_config_unset_usage ,
893
898
PARSE_OPT_STOP_AT_NON_OPTION );
@@ -900,12 +905,14 @@ static int cmd_config_unset(int argc, const char **argv, const char *prefix)
900
905
check_write ();
901
906
902
907
if ((flags & CONFIG_FLAGS_MULTI_REPLACE ) || value_pattern )
903
- return git_config_set_multivar_in_file_gently (given_config_source .file ,
904
- argv [0 ], NULL , value_pattern ,
905
- NULL , flags );
908
+ ret = git_config_set_multivar_in_file_gently (given_config_source .file ,
909
+ argv [0 ], NULL , value_pattern ,
910
+ NULL , flags );
906
911
else
907
- return git_config_set_in_file_gently (given_config_source .file , argv [0 ],
908
- NULL , NULL );
912
+ ret = git_config_set_in_file_gently (given_config_source .file , argv [0 ],
913
+ NULL , NULL );
914
+
915
+ return ret ;
909
916
}
910
917
911
918
static int cmd_config_rename_section (int argc , const char * * argv , const char * prefix )
@@ -926,11 +933,13 @@ static int cmd_config_rename_section(int argc, const char **argv, const char *pr
926
933
ret = git_config_rename_section_in_file (given_config_source .file ,
927
934
argv [0 ], argv [1 ]);
928
935
if (ret < 0 )
929
- return ret ;
936
+ goto out ;
930
937
else if (!ret )
931
938
die (_ ("no such section: %s" ), argv [0 ]);
939
+ ret = 0 ;
932
940
933
- return 0 ;
941
+ out :
942
+ return ret ;
934
943
}
935
944
936
945
static int cmd_config_remove_section (int argc , const char * * argv , const char * prefix )
@@ -951,11 +960,13 @@ static int cmd_config_remove_section(int argc, const char **argv, const char *pr
951
960
ret = git_config_rename_section_in_file (given_config_source .file ,
952
961
argv [0 ], NULL );
953
962
if (ret < 0 )
954
- return ret ;
963
+ goto out ;
955
964
else if (!ret )
956
965
die (_ ("no such section: %s" ), argv [0 ]);
966
+ ret = 0 ;
957
967
958
- return 0 ;
968
+ out :
969
+ return ret ;
959
970
}
960
971
961
972
static int show_editor (void )
@@ -1199,49 +1210,49 @@ static int cmd_config_actions(int argc, const char **argv, const char *prefix)
1199
1210
}
1200
1211
else if (actions == ACTION_GET ) {
1201
1212
check_argc (argc , 1 , 2 );
1202
- return get_value (argv [0 ], argv [1 ], flags );
1213
+ ret = get_value (argv [0 ], argv [1 ], flags );
1203
1214
}
1204
1215
else if (actions == ACTION_GET_ALL ) {
1205
1216
do_all = 1 ;
1206
1217
check_argc (argc , 1 , 2 );
1207
- return get_value (argv [0 ], argv [1 ], flags );
1218
+ ret = get_value (argv [0 ], argv [1 ], flags );
1208
1219
}
1209
1220
else if (actions == ACTION_GET_REGEXP ) {
1210
1221
show_keys = 1 ;
1211
1222
use_key_regexp = 1 ;
1212
1223
do_all = 1 ;
1213
1224
check_argc (argc , 1 , 2 );
1214
- return get_value (argv [0 ], argv [1 ], flags );
1225
+ ret = get_value (argv [0 ], argv [1 ], flags );
1215
1226
}
1216
1227
else if (actions == ACTION_GET_URLMATCH ) {
1217
1228
check_argc (argc , 2 , 2 );
1218
- return get_urlmatch (argv [0 ], argv [1 ]);
1229
+ ret = get_urlmatch (argv [0 ], argv [1 ]);
1219
1230
}
1220
1231
else if (actions == ACTION_UNSET ) {
1221
1232
check_write ();
1222
1233
check_argc (argc , 1 , 2 );
1223
1234
if (argc == 2 )
1224
- return git_config_set_multivar_in_file_gently (given_config_source .file ,
1225
- argv [0 ], NULL , argv [1 ],
1226
- NULL , flags );
1235
+ ret = git_config_set_multivar_in_file_gently (given_config_source .file ,
1236
+ argv [0 ], NULL , argv [1 ],
1237
+ NULL , flags );
1227
1238
else
1228
- return git_config_set_in_file_gently (given_config_source .file ,
1229
- argv [0 ], NULL , NULL );
1239
+ ret = git_config_set_in_file_gently (given_config_source .file ,
1240
+ argv [0 ], NULL , NULL );
1230
1241
}
1231
1242
else if (actions == ACTION_UNSET_ALL ) {
1232
1243
check_write ();
1233
1244
check_argc (argc , 1 , 2 );
1234
- return git_config_set_multivar_in_file_gently (given_config_source .file ,
1235
- argv [0 ], NULL , argv [1 ],
1236
- NULL , flags | CONFIG_FLAGS_MULTI_REPLACE );
1245
+ ret = git_config_set_multivar_in_file_gently (given_config_source .file ,
1246
+ argv [0 ], NULL , argv [1 ],
1247
+ NULL , flags | CONFIG_FLAGS_MULTI_REPLACE );
1237
1248
}
1238
1249
else if (actions == ACTION_RENAME_SECTION ) {
1239
1250
check_write ();
1240
1251
check_argc (argc , 2 , 2 );
1241
1252
ret = git_config_rename_section_in_file (given_config_source .file ,
1242
1253
argv [0 ], argv [1 ]);
1243
1254
if (ret < 0 )
1244
- return ret ;
1255
+ goto out ;
1245
1256
else if (!ret )
1246
1257
die (_ ("no such section: %s" ), argv [0 ]);
1247
1258
else
@@ -1253,7 +1264,7 @@ static int cmd_config_actions(int argc, const char **argv, const char *prefix)
1253
1264
ret = git_config_rename_section_in_file (given_config_source .file ,
1254
1265
argv [0 ], NULL );
1255
1266
if (ret < 0 )
1256
- return ret ;
1267
+ goto out ;
1257
1268
else if (!ret )
1258
1269
die (_ ("no such section: %s" ), argv [0 ]);
1259
1270
else
@@ -1267,9 +1278,10 @@ static int cmd_config_actions(int argc, const char **argv, const char *prefix)
1267
1278
check_argc (argc , 1 , 2 );
1268
1279
if (argc == 2 )
1269
1280
color_stdout_is_tty = git_config_bool ("command line" , argv [1 ]);
1270
- return get_colorbool (argv [0 ], argc == 2 );
1281
+ ret = get_colorbool (argv [0 ], argc == 2 );
1271
1282
}
1272
1283
1284
+ out :
1273
1285
free (comment );
1274
1286
free (value );
1275
1287
return ret ;
0 commit comments