Skip to content

Commit 21e047d

Browse files
stefanbellergitster
authored andcommitted
config parsing options: allow one flag multiple times
This task emerged from b04ba2b (parse-options: deprecate OPT_BOOLEAN, 2011-09-27). This commit introduces a change for the users, after this patch you can pass one of the config level flags multiple times: Before: $ git config --global --global --list error: only one config file at a time. usage: ... Afterwards this will work. This is due to the following check in the code: if (use_global_config + use_system_config + use_local_config + !!given_config_file + !!given_config_blob > 1) { error("only one config file at a time."); usage_with_options(builtin_config_usage, builtin_config_options); } With OPT_BOOL instead of OPT_BOOLEAN the variables use_global_config, use_system_config, use_local_config will only have the value 0 if the command line option was not passed or 1 no matter how often the respective command line option was passed. Signed-off-by: Stefan Beller <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent c83e8c1 commit 21e047d

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

builtin/config.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,9 @@ static int respect_includes = -1;
5050

5151
static struct option builtin_config_options[] = {
5252
OPT_GROUP(N_("Config file location")),
53-
OPT_BOOLEAN(0, "global", &use_global_config, N_("use global config file")),
54-
OPT_BOOLEAN(0, "system", &use_system_config, N_("use system config file")),
55-
OPT_BOOLEAN(0, "local", &use_local_config, N_("use repository config file")),
53+
OPT_BOOL(0, "global", &use_global_config, N_("use global config file")),
54+
OPT_BOOL(0, "system", &use_system_config, N_("use system config file")),
55+
OPT_BOOL(0, "local", &use_local_config, N_("use repository config file")),
5656
OPT_STRING('f', "file", &given_config_file, N_("file"), N_("use given config file")),
5757
OPT_STRING(0, "blob", &given_config_blob, N_("blob-id"), N_("read config from given blob object")),
5858
OPT_GROUP(N_("Action")),

0 commit comments

Comments
 (0)