git config: don't allow multiple config file locations
authorFelipe Contreras <felipe.contreras@gmail.com>
Sat, 21 Feb 2009 00:49:26 +0000 (02:49 +0200)
committerJunio C Hamano <gitster@pobox.com>
Sun, 22 Feb 2009 04:37:44 +0000 (20:37 -0800)
Either --global, --system, or --file can be used, but not any
combination.

Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
builtin-config.c

index 08a77cd..d037e47 100644 (file)
@@ -316,6 +316,11 @@ int cmd_config(int argc, const char **argv, const char *unused_prefix)
        argc = parse_options(argc, argv, builtin_config_options, builtin_config_usage,
                             PARSE_OPT_STOP_AT_NON_OPTION);
 
+       if (use_global_config + use_system_config + !!given_config_file > 1) {
+               error("only one config file at a time.");
+               usage_with_options(builtin_config_usage, builtin_config_options);
+       }
+
        if (use_global_config) {
                char *home = getenv("HOME");
                if (home) {