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 <srabbelier@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Sverre Rabbelier committed
Aug 3, 2010 at 20:59 UTC
57210a678a8bedd222bf4478eeb0a664d9dd5369
1 file changed
+5
-2
builtin/config.c
+5
-2
@@ -20,7 +20,7 @@ static char delim = '=';
20
static char key_delim = ' ';
21
static char term = '\n';
22
23
-static int use_global_config, use_system_config;
23
+static int use_global_config, use_system_config, use_local_config;
24
static const char *given_config_file;
25
static int actions, types;
26
static const char *get_color_slot, *get_colorbool_slot;
@@ -51,6 +51,7 @@ static struct option builtin_config_options[] = {
51
OPT_GROUP("Config file location"),
52
OPT_BOOLEAN(0, "global", &use_global_config, "use global config file"),
53
OPT_BOOLEAN(0, "system", &use_system_config, "use system config file"),
54
+ OPT_BOOLEAN(0, "local", &use_local_config, "use repository config file"),
55
OPT_STRING('f', "file", &given_config_file, "FILE", "use given config file"),
56
OPT_GROUP("Action"),
57
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)
343
builtin_config_usage,
344
PARSE_OPT_STOP_AT_NON_OPTION);
345
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) {
347
error("only one config file at a time.");
348
usage_with_options(builtin_config_usage, builtin_config_options);
349
}
@@ -358,6 +359,8 @@ int cmd_config(int argc, const char **argv, const char *unused_prefix)
359
}
360
else if (use_system_config)
361
config_exclusive_filename = git_etc_gitconfig();
362
+ else if (use_local_config)
363
+ config_exclusive_filename = git_pathdup("config");
364
else if (given_config_file) {
365
if (!is_absolute_path(given_config_file) && prefix)
366
config_exclusive_filename = prefix_filename(prefix,