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

Re: [PATCH 1/2] config api: Add git_config_magic_int()

From
Junio C Hamano <gitster@pobox.com>
Date
Feb 12, 2008, 21:41 UTC
Message-ID
<7vir0t3l9s.fsf@gitster.siamese.dyndns.org>
In-Reply-To
<47B15701.8040803@op5.se>
Andreas Ericsson <ae@op5.se> writes:
Show 8 quoted lines
> +int git_config_magic_int(const char *name, const char *value,
> +			 const char *magic_value, int magic_setting)
> +{
> +	if (value && !strcasecmp(value, magic_value))
> +		return magic_setting;
> +
> +	return git_config_int(name, value);
> +}
I do not think this has much to do with any "magic".

An instruction "use 0 threads" when taken literally would mean "do not use any CPU" which would not make much sense. In that sense, giving a magic meaning of "guess an appropriate value" to 0 may be a good idea. A valid alternative would be to make 0 mean the same thing as 1, but that is much more boring ;-)

But if you did so, that means "var = 0" invokes the same magic as "var = auto". The magic lives in "0", and not in "auto".

I think the direction your patch leads us is good, but I think it should allow an array of symbolic ways to spell values to be useful, that is:

	struct config_symbolic_int {
        	const char *name;
                int value;
	};
        int git_config_symbolic_int(const char *var, const char *value,
				    struct config_symbolic_int *);
That way, you can have
	{ { "high", 9 }, { "default", 0 }, { "low", 1 } };
and say things like "zlevel = high|default|low".
Previous: Andreas EricssonNext: Andreas Ericsson
Message 2 of 3 in “config api: Add git_config_magic_int()”
  1. 1/2 config api: Add git_config_magic_int()Andreas Ericsson, Feb 12, 2008
  2. Junio C HamanoFeb 12, 2008
  3. Andreas EricssonFeb 13, 2008

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.