Skip to content

Commit 424a29c

Browse files
pks-tgitster
authored andcommitted
builtin/config: move option array around
Move around the option array. This will help us with a follow-up commit that introduces subcommands to git-config(1). Signed-off-by: Patrick Steinhardt <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent a78b462 commit 424a29c

File tree

1 file changed

+48
-48
lines changed

1 file changed

+48
-48
lines changed

builtin/config.c

Lines changed: 48 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -135,54 +135,6 @@ static int option_parse_type(const struct option *opt, const char *arg,
135135
return 0;
136136
}
137137

138-
static struct option builtin_config_options[] = {
139-
OPT_GROUP(N_("Config file location")),
140-
OPT_BOOL(0, "global", &use_global_config, N_("use global config file")),
141-
OPT_BOOL(0, "system", &use_system_config, N_("use system config file")),
142-
OPT_BOOL(0, "local", &use_local_config, N_("use repository config file")),
143-
OPT_BOOL(0, "worktree", &use_worktree_config, N_("use per-worktree config file")),
144-
OPT_STRING('f', "file", &given_config_source.file, N_("file"), N_("use given config file")),
145-
OPT_STRING(0, "blob", &given_config_source.blob, N_("blob-id"), N_("read config from given blob object")),
146-
OPT_GROUP(N_("Action")),
147-
OPT_BIT(0, "get", &actions, N_("get value: name [value-pattern]"), ACTION_GET),
148-
OPT_BIT(0, "get-all", &actions, N_("get all values: key [value-pattern]"), ACTION_GET_ALL),
149-
OPT_BIT(0, "get-regexp", &actions, N_("get values for regexp: name-regex [value-pattern]"), ACTION_GET_REGEXP),
150-
OPT_BIT(0, "get-urlmatch", &actions, N_("get value specific for the URL: section[.var] URL"), ACTION_GET_URLMATCH),
151-
OPT_BIT(0, "replace-all", &actions, N_("replace all matching variables: name value [value-pattern]"), ACTION_REPLACE_ALL),
152-
OPT_BIT(0, "add", &actions, N_("add a new variable: name value"), ACTION_ADD),
153-
OPT_BIT(0, "unset", &actions, N_("remove a variable: name [value-pattern]"), ACTION_UNSET),
154-
OPT_BIT(0, "unset-all", &actions, N_("remove all matches: name [value-pattern]"), ACTION_UNSET_ALL),
155-
OPT_BIT(0, "rename-section", &actions, N_("rename section: old-name new-name"), ACTION_RENAME_SECTION),
156-
OPT_BIT(0, "remove-section", &actions, N_("remove a section: name"), ACTION_REMOVE_SECTION),
157-
OPT_BIT('l', "list", &actions, N_("list all"), ACTION_LIST),
158-
OPT_BOOL(0, "fixed-value", &fixed_value, N_("use string equality when comparing values to 'value-pattern'")),
159-
OPT_BIT('e', "edit", &actions, N_("open an editor"), ACTION_EDIT),
160-
OPT_BIT(0, "get-color", &actions, N_("find the color configured: slot [default]"), ACTION_GET_COLOR),
161-
OPT_BIT(0, "get-colorbool", &actions, N_("find the color setting: slot [stdout-is-tty]"), ACTION_GET_COLORBOOL),
162-
OPT_GROUP(N_("Type")),
163-
OPT_CALLBACK('t', "type", &type, N_("type"), N_("value is given this type"), option_parse_type),
164-
OPT_CALLBACK_VALUE(0, "bool", &type, N_("value is \"true\" or \"false\""), TYPE_BOOL),
165-
OPT_CALLBACK_VALUE(0, "int", &type, N_("value is decimal number"), TYPE_INT),
166-
OPT_CALLBACK_VALUE(0, "bool-or-int", &type, N_("value is --bool or --int"), TYPE_BOOL_OR_INT),
167-
OPT_CALLBACK_VALUE(0, "bool-or-str", &type, N_("value is --bool or string"), TYPE_BOOL_OR_STR),
168-
OPT_CALLBACK_VALUE(0, "path", &type, N_("value is a path (file or directory name)"), TYPE_PATH),
169-
OPT_CALLBACK_VALUE(0, "expiry-date", &type, N_("value is an expiry date"), TYPE_EXPIRY_DATE),
170-
OPT_GROUP(N_("Other")),
171-
OPT_BOOL('z', "null", &end_nul, N_("terminate values with NUL byte")),
172-
OPT_BOOL(0, "name-only", &omit_values, N_("show variable names only")),
173-
OPT_BOOL(0, "includes", &respect_includes_opt, N_("respect include directives on lookup")),
174-
OPT_BOOL(0, "show-origin", &show_origin, N_("show origin of config (file, standard input, blob, command line)")),
175-
OPT_BOOL(0, "show-scope", &show_scope, N_("show scope of config (worktree, local, global, system, command)")),
176-
OPT_STRING(0, "default", &default_value, N_("value"), N_("with --get, use default value when missing entry")),
177-
OPT_STRING(0, "comment", &comment_arg, N_("value"), N_("human-readable comment string (# will be prepended as needed)")),
178-
OPT_END(),
179-
};
180-
181-
static NORETURN void usage_builtin_config(void)
182-
{
183-
usage_with_options(builtin_config_usage, builtin_config_options);
184-
}
185-
186138
static void check_argc(int argc, int min, int max)
187139
{
188140
if (argc >= min && argc <= max)
@@ -671,6 +623,54 @@ static char *default_user_config(void)
671623
return strbuf_detach(&buf, NULL);
672624
}
673625

626+
static struct option builtin_config_options[] = {
627+
OPT_GROUP(N_("Config file location")),
628+
OPT_BOOL(0, "global", &use_global_config, N_("use global config file")),
629+
OPT_BOOL(0, "system", &use_system_config, N_("use system config file")),
630+
OPT_BOOL(0, "local", &use_local_config, N_("use repository config file")),
631+
OPT_BOOL(0, "worktree", &use_worktree_config, N_("use per-worktree config file")),
632+
OPT_STRING('f', "file", &given_config_source.file, N_("file"), N_("use given config file")),
633+
OPT_STRING(0, "blob", &given_config_source.blob, N_("blob-id"), N_("read config from given blob object")),
634+
OPT_GROUP(N_("Action")),
635+
OPT_BIT(0, "get", &actions, N_("get value: name [value-pattern]"), ACTION_GET),
636+
OPT_BIT(0, "get-all", &actions, N_("get all values: key [value-pattern]"), ACTION_GET_ALL),
637+
OPT_BIT(0, "get-regexp", &actions, N_("get values for regexp: name-regex [value-pattern]"), ACTION_GET_REGEXP),
638+
OPT_BIT(0, "get-urlmatch", &actions, N_("get value specific for the URL: section[.var] URL"), ACTION_GET_URLMATCH),
639+
OPT_BIT(0, "replace-all", &actions, N_("replace all matching variables: name value [value-pattern]"), ACTION_REPLACE_ALL),
640+
OPT_BIT(0, "add", &actions, N_("add a new variable: name value"), ACTION_ADD),
641+
OPT_BIT(0, "unset", &actions, N_("remove a variable: name [value-pattern]"), ACTION_UNSET),
642+
OPT_BIT(0, "unset-all", &actions, N_("remove all matches: name [value-pattern]"), ACTION_UNSET_ALL),
643+
OPT_BIT(0, "rename-section", &actions, N_("rename section: old-name new-name"), ACTION_RENAME_SECTION),
644+
OPT_BIT(0, "remove-section", &actions, N_("remove a section: name"), ACTION_REMOVE_SECTION),
645+
OPT_BIT('l', "list", &actions, N_("list all"), ACTION_LIST),
646+
OPT_BOOL(0, "fixed-value", &fixed_value, N_("use string equality when comparing values to 'value-pattern'")),
647+
OPT_BIT('e', "edit", &actions, N_("open an editor"), ACTION_EDIT),
648+
OPT_BIT(0, "get-color", &actions, N_("find the color configured: slot [default]"), ACTION_GET_COLOR),
649+
OPT_BIT(0, "get-colorbool", &actions, N_("find the color setting: slot [stdout-is-tty]"), ACTION_GET_COLORBOOL),
650+
OPT_GROUP(N_("Type")),
651+
OPT_CALLBACK('t', "type", &type, N_("type"), N_("value is given this type"), option_parse_type),
652+
OPT_CALLBACK_VALUE(0, "bool", &type, N_("value is \"true\" or \"false\""), TYPE_BOOL),
653+
OPT_CALLBACK_VALUE(0, "int", &type, N_("value is decimal number"), TYPE_INT),
654+
OPT_CALLBACK_VALUE(0, "bool-or-int", &type, N_("value is --bool or --int"), TYPE_BOOL_OR_INT),
655+
OPT_CALLBACK_VALUE(0, "bool-or-str", &type, N_("value is --bool or string"), TYPE_BOOL_OR_STR),
656+
OPT_CALLBACK_VALUE(0, "path", &type, N_("value is a path (file or directory name)"), TYPE_PATH),
657+
OPT_CALLBACK_VALUE(0, "expiry-date", &type, N_("value is an expiry date"), TYPE_EXPIRY_DATE),
658+
OPT_GROUP(N_("Other")),
659+
OPT_BOOL('z', "null", &end_nul, N_("terminate values with NUL byte")),
660+
OPT_BOOL(0, "name-only", &omit_values, N_("show variable names only")),
661+
OPT_BOOL(0, "includes", &respect_includes_opt, N_("respect include directives on lookup")),
662+
OPT_BOOL(0, "show-origin", &show_origin, N_("show origin of config (file, standard input, blob, command line)")),
663+
OPT_BOOL(0, "show-scope", &show_scope, N_("show scope of config (worktree, local, global, system, command)")),
664+
OPT_STRING(0, "default", &default_value, N_("value"), N_("with --get, use default value when missing entry")),
665+
OPT_STRING(0, "comment", &comment_arg, N_("value"), N_("human-readable comment string (# will be prepended as needed)")),
666+
OPT_END(),
667+
};
668+
669+
static NORETURN void usage_builtin_config(void)
670+
{
671+
usage_with_options(builtin_config_usage, builtin_config_options);
672+
}
673+
674674
int cmd_config(int argc, const char **argv, const char *prefix)
675675
{
676676
int nongit = !startup_info->have_repository;

0 commit comments

Comments
 (0)