Skip to content

Commit 57210a6

Browse files
SRabbeliergitster
authored andcommitted
config: add --local option
This is a shorthand similar to --system but instead uses the config file of the current repository. Signed-off-by: Sverre Rabbelier <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 64fdc08 commit 57210a6

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

builtin/config.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ static char delim = '=';
2020
static char key_delim = ' ';
2121
static char term = '\n';
2222

23-
static int use_global_config, use_system_config;
23+
static int use_global_config, use_system_config, use_local_config;
2424
static const char *given_config_file;
2525
static int actions, types;
2626
static const char *get_color_slot, *get_colorbool_slot;
@@ -51,6 +51,7 @@ static struct option builtin_config_options[] = {
5151
OPT_GROUP("Config file location"),
5252
OPT_BOOLEAN(0, "global", &use_global_config, "use global config file"),
5353
OPT_BOOLEAN(0, "system", &use_system_config, "use system config file"),
54+
OPT_BOOLEAN(0, "local", &use_local_config, "use repository config file"),
5455
OPT_STRING('f', "file", &given_config_file, "FILE", "use given config file"),
5556
OPT_GROUP("Action"),
5657
OPT_BIT(0, "get", &actions, "get value: name [value-regex]", ACTION_GET),
@@ -342,7 +343,7 @@ int cmd_config(int argc, const char **argv, const char *unused_prefix)
342343
builtin_config_usage,
343344
PARSE_OPT_STOP_AT_NON_OPTION);
344345

345-
if (use_global_config + use_system_config + !!given_config_file > 1) {
346+
if (use_global_config + use_system_config + use_local_config + !!given_config_file > 1) {
346347
error("only one config file at a time.");
347348
usage_with_options(builtin_config_usage, builtin_config_options);
348349
}
@@ -358,6 +359,8 @@ int cmd_config(int argc, const char **argv, const char *unused_prefix)
358359
}
359360
else if (use_system_config)
360361
config_exclusive_filename = git_etc_gitconfig();
362+
else if (use_local_config)
363+
config_exclusive_filename = git_pathdup("config");
361364
else if (given_config_file) {
362365
if (!is_absolute_path(given_config_file) && prefix)
363366
config_exclusive_filename = prefix_filename(prefix,

0 commit comments

Comments
 (0)