@@ -78,15 +78,14 @@ static char term = '\n';
78
78
static int use_global_config , use_system_config , use_local_config ;
79
79
static int use_worktree_config ;
80
80
static struct git_config_source given_config_source ;
81
- static int actions , type ;
81
+ static int type ;
82
82
static char * default_value ;
83
83
static int end_nul ;
84
84
static int respect_includes_opt = -1 ;
85
85
static struct config_options config_options ;
86
86
static int show_origin ;
87
87
static int show_scope ;
88
88
static int fixed_value ;
89
- static const char * comment_arg ;
90
89
91
90
#define ACTION_GET (1<<0)
92
91
#define ACTION_GET_ALL (1<<1)
@@ -772,33 +771,6 @@ static void handle_nul(void) {
772
771
OPT_BOOL(0, "show-origin", &show_origin, N_("show origin of config (file, standard input, blob, command line)")), \
773
772
OPT_BOOL(0, "show-scope", &show_scope, N_("show scope of config (worktree, local, global, system, command)"))
774
773
775
- static struct option builtin_config_options [] = {
776
- CONFIG_LOCATION_OPTIONS ,
777
- OPT_GROUP (N_ ("Action" )),
778
- OPT_CMDMODE (0 , "get" , & actions , N_ ("get value: name [<value-pattern>]" ), ACTION_GET ),
779
- OPT_CMDMODE (0 , "get-all" , & actions , N_ ("get all values: key [<value-pattern>]" ), ACTION_GET_ALL ),
780
- OPT_CMDMODE (0 , "get-regexp" , & actions , N_ ("get values for regexp: name-regex [<value-pattern>]" ), ACTION_GET_REGEXP ),
781
- OPT_CMDMODE (0 , "get-urlmatch" , & actions , N_ ("get value specific for the URL: section[.var] URL" ), ACTION_GET_URLMATCH ),
782
- OPT_CMDMODE (0 , "replace-all" , & actions , N_ ("replace all matching variables: name value [<value-pattern>]" ), ACTION_REPLACE_ALL ),
783
- OPT_CMDMODE (0 , "add" , & actions , N_ ("add a new variable: name value" ), ACTION_ADD ),
784
- OPT_CMDMODE (0 , "unset" , & actions , N_ ("remove a variable: name [<value-pattern>]" ), ACTION_UNSET ),
785
- OPT_CMDMODE (0 , "unset-all" , & actions , N_ ("remove all matches: name [<value-pattern>]" ), ACTION_UNSET_ALL ),
786
- OPT_CMDMODE (0 , "rename-section" , & actions , N_ ("rename section: old-name new-name" ), ACTION_RENAME_SECTION ),
787
- OPT_CMDMODE (0 , "remove-section" , & actions , N_ ("remove a section: name" ), ACTION_REMOVE_SECTION ),
788
- OPT_CMDMODE ('l' , "list" , & actions , N_ ("list all" ), ACTION_LIST ),
789
- OPT_CMDMODE ('e' , "edit" , & actions , N_ ("open an editor" ), ACTION_EDIT ),
790
- OPT_CMDMODE (0 , "get-color" , & actions , N_ ("find the color configured: slot [<default>]" ), ACTION_GET_COLOR ),
791
- OPT_CMDMODE (0 , "get-colorbool" , & actions , N_ ("find the color setting: slot [<stdout-is-tty>]" ), ACTION_GET_COLORBOOL ),
792
- CONFIG_TYPE_OPTIONS ,
793
- CONFIG_DISPLAY_OPTIONS ,
794
- OPT_GROUP (N_ ("Other" )),
795
- OPT_STRING (0 , "default" , & default_value , N_ ("value" ), N_ ("with --get, use default value when missing entry" )),
796
- OPT_STRING (0 , "comment" , & comment_arg , N_ ("value" ), N_ ("human-readable comment string (# will be prepended as needed)" )),
797
- OPT_BOOL (0 , "fixed-value" , & fixed_value , N_ ("use string equality when comparing values to 'value-pattern'" )),
798
- OPT_BOOL (0 , "includes" , & respect_includes_opt , N_ ("respect include directives on lookup" )),
799
- OPT_END (),
800
- };
801
-
802
774
static int cmd_config_list (int argc , const char * * argv , const char * prefix )
803
775
{
804
776
struct option opts [] = {
@@ -1059,12 +1031,40 @@ static int cmd_config_edit(int argc, const char **argv, const char *prefix)
1059
1031
1060
1032
static int cmd_config_actions (int argc , const char * * argv , const char * prefix )
1061
1033
{
1034
+ const char * comment_arg = NULL ;
1035
+ int actions = 0 ;
1036
+ struct option opts [] = {
1037
+ CONFIG_LOCATION_OPTIONS ,
1038
+ OPT_GROUP (N_ ("Action" )),
1039
+ OPT_CMDMODE (0 , "get" , & actions , N_ ("get value: name [<value-pattern>]" ), ACTION_GET ),
1040
+ OPT_CMDMODE (0 , "get-all" , & actions , N_ ("get all values: key [<value-pattern>]" ), ACTION_GET_ALL ),
1041
+ OPT_CMDMODE (0 , "get-regexp" , & actions , N_ ("get values for regexp: name-regex [<value-pattern>]" ), ACTION_GET_REGEXP ),
1042
+ OPT_CMDMODE (0 , "get-urlmatch" , & actions , N_ ("get value specific for the URL: section[.var] URL" ), ACTION_GET_URLMATCH ),
1043
+ OPT_CMDMODE (0 , "replace-all" , & actions , N_ ("replace all matching variables: name value [<value-pattern>]" ), ACTION_REPLACE_ALL ),
1044
+ OPT_CMDMODE (0 , "add" , & actions , N_ ("add a new variable: name value" ), ACTION_ADD ),
1045
+ OPT_CMDMODE (0 , "unset" , & actions , N_ ("remove a variable: name [<value-pattern>]" ), ACTION_UNSET ),
1046
+ OPT_CMDMODE (0 , "unset-all" , & actions , N_ ("remove all matches: name [<value-pattern>]" ), ACTION_UNSET_ALL ),
1047
+ OPT_CMDMODE (0 , "rename-section" , & actions , N_ ("rename section: old-name new-name" ), ACTION_RENAME_SECTION ),
1048
+ OPT_CMDMODE (0 , "remove-section" , & actions , N_ ("remove a section: name" ), ACTION_REMOVE_SECTION ),
1049
+ OPT_CMDMODE ('l' , "list" , & actions , N_ ("list all" ), ACTION_LIST ),
1050
+ OPT_CMDMODE ('e' , "edit" , & actions , N_ ("open an editor" ), ACTION_EDIT ),
1051
+ OPT_CMDMODE (0 , "get-color" , & actions , N_ ("find the color configured: slot [<default>]" ), ACTION_GET_COLOR ),
1052
+ OPT_CMDMODE (0 , "get-colorbool" , & actions , N_ ("find the color setting: slot [<stdout-is-tty>]" ), ACTION_GET_COLORBOOL ),
1053
+ CONFIG_TYPE_OPTIONS ,
1054
+ CONFIG_DISPLAY_OPTIONS ,
1055
+ OPT_GROUP (N_ ("Other" )),
1056
+ OPT_STRING (0 , "default" , & default_value , N_ ("value" ), N_ ("with --get, use default value when missing entry" )),
1057
+ OPT_STRING (0 , "comment" , & comment_arg , N_ ("value" ), N_ ("human-readable comment string (# will be prepended as needed)" )),
1058
+ OPT_BOOL (0 , "fixed-value" , & fixed_value , N_ ("use string equality when comparing values to 'value-pattern'" )),
1059
+ OPT_BOOL (0 , "includes" , & respect_includes_opt , N_ ("respect include directives on lookup" )),
1060
+ OPT_END (),
1061
+ };
1062
1062
char * value = NULL , * comment = NULL ;
1063
1063
int flags = 0 ;
1064
1064
int ret = 0 ;
1065
1065
struct key_value_info default_kvi = KVI_INIT ;
1066
1066
1067
- argc = parse_options (argc , argv , prefix , builtin_config_options ,
1067
+ argc = parse_options (argc , argv , prefix , opts ,
1068
1068
builtin_config_usage ,
1069
1069
PARSE_OPT_STOP_AT_NON_OPTION );
1070
1070
0 commit comments