git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Junio C Hamano <gitster@pobox.com>
To: Andreas Ericsson <ae@op5.se>
Cc: Git Mailing List <git@vger.kernel.org>
Subject: Re: [PATCH 1/2] config api: Add git_config_magic_int()
Date: Tue, 12 Feb 2008 13:41:35 -0800	[thread overview]
Message-ID: <7vir0t3l9s.fsf@gitster.siamese.dyndns.org> (raw)
In-Reply-To: 47B15701.8040803@op5.se

Andreas Ericsson <ae@op5.se> writes:

> +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".

  reply	other threads:[~2008-02-12 21:43 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-02-12  8:21 [PATCH 1/2] config api: Add git_config_magic_int() Andreas Ericsson
2008-02-12 21:41 ` Junio C Hamano [this message]
2008-02-13 13:58   ` Andreas Ericsson

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=7vir0t3l9s.fsf@gitster.siamese.dyndns.org \
    --to=gitster@pobox.com \
    --cc=ae@op5.se \
    --cc=git@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).