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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Junio C Hamano wrote:
Andreas Ericsson <ae@xxxxxx> 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".

Good idea. I'll look into it right away. I sorely need a break from
coding backends for webapps anyway. I'll send this one separately and
then tack 2/2 onto the builtin-pack-objects patch thing. That one
should probably be a /3 series anyway, when I come to think of it.

--
Andreas Ericsson                   andreas.ericsson@xxxxxx
OP5 AB                             www.op5.se
Tel: +46 8-230225                  Fax: +46 8-230231
-
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux