git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH 5/8] config: Disallow multiple config file locations.

From
Felipe Contreras <felipe.contreras@gmail.com>
Date
Feb 15, 2009, 12:44 UTC
Message-ID
<94a0d4530902150444t6e4dcd3btda79aaa0efebfe62@mail.gmail.com>
In-Reply-To
<alpine.DEB.1.00.0902151324530.10279@pacific.mpi-cbg.de>

On Sun, Feb 15, 2009 at 2:26 PM, Johannes Schindelin <Johannes.Schindelin@gmx.de> wrote:

Show 35 quoted lines
> Hi,
>
> On Sun, 15 Feb 2009, Felipe Contreras wrote:
>
>> Either --global, --system, or --file should be used, but not any
>> combination.
>>
>> Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
>> ---
>>  builtin-config.c |   10 ++++++++++
>>  1 files changed, 10 insertions(+), 0 deletions(-)
>>
>> diff --git a/builtin-config.c b/builtin-config.c
>> index 83f8b74..e744ad8 100644
>> --- a/builtin-config.c
>> +++ b/builtin-config.c
>> @@ -314,6 +314,16 @@ int cmd_config(int argc, const char **argv, const char *unused_prefix)
>>
>>       argc = parse_options(argc, argv, builtin_config_options, builtin_config_usage, 0);
>>
>> +     {
>> +             int config_file_count = use_global_config + use_system_config;
>> +             if (given_config_file)
>> +                     config_file_count++;
>> +             if (config_file_count > 1) {
>> +                     error("only one config file at a time.");
>> +                     usage_with_options(builtin_config_usage, builtin_config_options);
>> +             }
>> +     }
>
> Hmm.  Is this a convoluted way to write
>
>        if (use_global_config + use_system_config + !!given_config_file > 1)
>
> or am I misunderstanding anything?
Ah, much better. (the !!foo trick is new to me)
-- 
Felipe Contreras


From 1ef7e251a2ab24f213af3022dd0a98785c8127b7 Mon Sep 17 00:00:00 2001
From: Felipe Contreras <felipe.contreras@gmail.com>
Date: Sun, 15 Feb 2009 10:46:03 +0200
Subject: [PATCH 5/8] config: Disallow multiple config file locations.

Either --global, --system, or --file should be used, but not any
combination.

Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
---
 builtin-config.c |    5 +++++
 1 files changed, 5 insertions(+), 0 deletions(-)

diff --git a/builtin-config.c b/builtin-config.c
index 30de93e..cdd8a12 100644
--- a/builtin-config.c
+++ b/builtin-config.c
@@ -313,6 +313,11 @@ int cmd_config(int argc, const char **argv, const char *unused_prefix)
 
 	argc = parse_options(argc, argv, builtin_config_options, builtin_config_usage, 0);
 
+	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) {
-- 
1.6.1.3
Previous: Johannes SchindelinNext: Felipe Contreras
Message 13 of 19 in “config: Trivial rename in preparation for parseopt.”
  1. 1/8 config: Trivial rename in preparation for parseopt.Felipe Contreras, Feb 15, 2009
  2. 2/8 config: Cleanup config file handling.Felipe Contreras, Feb 15, 2009
  3. 3/8 config: Use parseopt.Felipe Contreras, Feb 15, 2009
  4. 4/8 config: Improve variable 'type' handling.Felipe Contreras, Feb 15, 2009
  5. 5/8 config: Disallow multiple config file locations.Felipe Contreras, Feb 15, 2009
  6. 6/8 config: Don't allow extra arguments for -e or -l.Felipe Contreras, Feb 15, 2009
  7. 7/8 config: Don't return negative exit codes.Felipe Contreras, Feb 15, 2009
  8. 8/8 config: Codestyle cleanups.Felipe Contreras, Feb 15, 2009
  9. Johannes SchindelinFeb 15, 2009
  10. Felipe ContrerasFeb 15, 2009
  11. Felipe ContrerasFeb 15, 2009
  12. Johannes SchindelinFeb 15, 2009
  13. Felipe ContrerasFeb 15, 2009
  14. Felipe ContrerasFeb 15, 2009
  15. Johannes SchindelinFeb 15, 2009
  16. Felipe ContrerasFeb 15, 2009
  17. Felipe ContrerasFeb 15, 2009
  18. Jeff KingFeb 15, 2009
  19. Junio C HamanoFeb 16, 2009

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.