builtin/config: move actions into `cmd_config_actions()`
We only use actions in the legacy mode. Convert them to an enum and move them into `cmd_config_actions()` to clearly demonstrate that they are not used anywhere else. Signed-off-by: Patrick Steinhardt <ps@pks.im> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Patrick Steinhardt committed
May 15, 2024 at 08:41 UTC
9cab5e8078c314957395ddb4c198c3320c4e5a91
1 file changed
+23
-25
builtin/config.c
+23
-25
@@ -87,30 +87,6 @@ static int show_origin;
87
static int show_scope;
88
static int fixed_value;
89
90
-#define ACTION_GET (1<<0)
91
-#define ACTION_GET_ALL (1<<1)
92
-#define ACTION_GET_REGEXP (1<<2)
93
-#define ACTION_REPLACE_ALL (1<<3)
94
-#define ACTION_ADD (1<<4)
95
-#define ACTION_UNSET (1<<5)
96
-#define ACTION_UNSET_ALL (1<<6)
97
-#define ACTION_RENAME_SECTION (1<<7)
98
-#define ACTION_REMOVE_SECTION (1<<8)
99
-#define ACTION_LIST (1<<9)
100
-#define ACTION_EDIT (1<<10)
101
-#define ACTION_SET (1<<11)
102
-#define ACTION_SET_ALL (1<<12)
103
-#define ACTION_GET_COLOR (1<<13)
104
-#define ACTION_GET_COLORBOOL (1<<14)
105
-#define ACTION_GET_URLMATCH (1<<15)
106
-
107
-/*
108
- * The actions "ACTION_LIST | ACTION_GET_*" which may produce more than
109
- * one line of output and which should therefore be paged.
110
- */
111
-#define PAGING_ACTIONS (ACTION_LIST | ACTION_GET_ALL | \
112
- ACTION_GET_REGEXP | ACTION_GET_URLMATCH)
113
-
90
#define TYPE_BOOL 1
91
#define TYPE_INT 2
92
#define TYPE_BOOL_OR_INT 3
@@ -1031,6 +1007,24 @@ static int cmd_config_edit(int argc, const char **argv, const char *prefix)
1007
1008
static int cmd_config_actions(int argc, const char **argv, const char *prefix)
1009
{
1010
+ enum {
1011
+ ACTION_GET = (1<<0),
1012
+ ACTION_GET_ALL = (1<<1),
1013
+ ACTION_GET_REGEXP = (1<<2),
1014
+ ACTION_REPLACE_ALL = (1<<3),
1015
+ ACTION_ADD = (1<<4),
1016
+ ACTION_UNSET = (1<<5),
1017
+ ACTION_UNSET_ALL = (1<<6),
1018
+ ACTION_RENAME_SECTION = (1<<7),
1019
+ ACTION_REMOVE_SECTION = (1<<8),
1020
+ ACTION_LIST = (1<<9),
1021
+ ACTION_EDIT = (1<<10),
1022
+ ACTION_SET = (1<<11),
1023
+ ACTION_SET_ALL = (1<<12),
1024
+ ACTION_GET_COLOR = (1<<13),
1025
+ ACTION_GET_COLORBOOL = (1<<14),
1026
+ ACTION_GET_URLMATCH = (1<<15),
1027
+ };
1028
const char *comment_arg = NULL;
1029
int actions = 0;
1030
struct option opts[] = {
@@ -1147,7 +1141,11 @@ static int cmd_config_actions(int argc, const char **argv, const char *prefix)
1141
1142
comment = git_config_prepare_comment_string(comment_arg);
1143
1150
- if (actions & PAGING_ACTIONS)
1144
+ /*
1145
+ * The following actions may produce more than one line of output and
1146
+ * should therefore be paged.
1147
+ */
1148
+ if (actions & (ACTION_LIST | ACTION_GET_ALL | ACTION_GET_REGEXP | ACTION_GET_URLMATCH))
1149
setup_auto_pager("config", 1);
1150
1151
if (actions == ACTION_LIST) {