@@ -75,7 +75,6 @@ static char delim = '=';
75
75
static char key_delim = ' ' ;
76
76
static char term = '\n' ;
77
77
78
- static parse_opt_subcommand_fn * subcommand ;
79
78
static int use_global_config , use_system_config , use_local_config ;
80
79
static int use_worktree_config ;
81
80
static struct git_config_source given_config_source ;
@@ -1058,17 +1057,6 @@ static int cmd_config_edit(int argc, const char **argv, const char *prefix)
1058
1057
return show_editor ();
1059
1058
}
1060
1059
1061
- static struct option builtin_subcommand_options [] = {
1062
- OPT_SUBCOMMAND ("list" , & subcommand , cmd_config_list ),
1063
- OPT_SUBCOMMAND ("get" , & subcommand , cmd_config_get ),
1064
- OPT_SUBCOMMAND ("set" , & subcommand , cmd_config_set ),
1065
- OPT_SUBCOMMAND ("unset" , & subcommand , cmd_config_unset ),
1066
- OPT_SUBCOMMAND ("rename-section" , & subcommand , cmd_config_rename_section ),
1067
- OPT_SUBCOMMAND ("remove-section" , & subcommand , cmd_config_remove_section ),
1068
- OPT_SUBCOMMAND ("edit" , & subcommand , cmd_config_edit ),
1069
- OPT_END (),
1070
- };
1071
-
1072
1060
static int cmd_config_actions (int argc , const char * * argv , const char * prefix )
1073
1061
{
1074
1062
char * value = NULL , * comment = NULL ;
@@ -1291,6 +1279,18 @@ static int cmd_config_actions(int argc, const char **argv, const char *prefix)
1291
1279
1292
1280
int cmd_config (int argc , const char * * argv , const char * prefix )
1293
1281
{
1282
+ parse_opt_subcommand_fn * subcommand = NULL ;
1283
+ struct option subcommand_opts [] = {
1284
+ OPT_SUBCOMMAND ("list" , & subcommand , cmd_config_list ),
1285
+ OPT_SUBCOMMAND ("get" , & subcommand , cmd_config_get ),
1286
+ OPT_SUBCOMMAND ("set" , & subcommand , cmd_config_set ),
1287
+ OPT_SUBCOMMAND ("unset" , & subcommand , cmd_config_unset ),
1288
+ OPT_SUBCOMMAND ("rename-section" , & subcommand , cmd_config_rename_section ),
1289
+ OPT_SUBCOMMAND ("remove-section" , & subcommand , cmd_config_remove_section ),
1290
+ OPT_SUBCOMMAND ("edit" , & subcommand , cmd_config_edit ),
1291
+ OPT_END (),
1292
+ };
1293
+
1294
1294
given_config_source .file = xstrdup_or_null (getenv (CONFIG_ENVIRONMENT ));
1295
1295
1296
1296
/*
@@ -1301,10 +1301,10 @@ int cmd_config(int argc, const char **argv, const char *prefix)
1301
1301
* line in case no subcommand was given, which would otherwise confuse
1302
1302
* us when parsing the legacy-style modes that don't use subcommands.
1303
1303
*/
1304
- argc = parse_options (argc , argv , prefix , builtin_subcommand_options , builtin_config_usage ,
1304
+ argc = parse_options (argc , argv , prefix , subcommand_opts , builtin_config_usage ,
1305
1305
PARSE_OPT_SUBCOMMAND_OPTIONAL |PARSE_OPT_KEEP_ARGV0 |PARSE_OPT_KEEP_UNKNOWN_OPT );
1306
1306
if (subcommand ) {
1307
- argc = parse_options (argc , argv , prefix , builtin_subcommand_options , builtin_config_usage ,
1307
+ argc = parse_options (argc , argv , prefix , subcommand_opts , builtin_config_usage ,
1308
1308
PARSE_OPT_SUBCOMMAND_OPTIONAL |PARSE_OPT_KEEP_UNKNOWN_OPT );
1309
1309
return subcommand (argc , argv , prefix );
1310
1310
}
0 commit comments