Skip to content

Commit 9cab5e8

Browse files
pks-tgitster
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 7d5387e commit 9cab5e8

File tree

1 file changed

+23
-25
lines changed

1 file changed

+23
-25
lines changed

builtin/config.c

Lines changed: 23 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -87,30 +87,6 @@ static int show_origin;
8787
static int show_scope;
8888
static int fixed_value;
8989

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-
11490
#define TYPE_BOOL 1
11591
#define TYPE_INT 2
11692
#define TYPE_BOOL_OR_INT 3
@@ -1031,6 +1007,24 @@ static int cmd_config_edit(int argc, const char **argv, const char *prefix)
10311007

10321008
static int cmd_config_actions(int argc, const char **argv, const char *prefix)
10331009
{
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+
};
10341028
const char *comment_arg = NULL;
10351029
int actions = 0;
10361030
struct option opts[] = {
@@ -1147,7 +1141,11 @@ static int cmd_config_actions(int argc, const char **argv, const char *prefix)
11471141

11481142
comment = git_config_prepare_comment_string(comment_arg);
11491143

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))
11511149
setup_auto_pager("config", 1);
11521150

11531151
if (actions == ACTION_LIST) {

0 commit comments

Comments
 (0)