On Tue, 9 May 2006, Junio C Hamano wrote: > > If we are shooting for "let's not do this again", I do not think > (4) without some quoting convention is good enough. Today, we > are talking about branch names so we could give them artificial > limits, which could be weaker than what we already have on the > branch names, but we would later regret that, when we start > wanting to have other names in the configuration (e.g. people's > names). Here's my suggestion as a patch. NOTE! This patch could be applied right now, and to all the branches (to make 1.x, 1.2.x and 1.3.x all support the _syntax_). Even if nothing actually uses it. It just makes the syntax be [section<space>+"<randomstring>"] where the only rule for "randomstring" is that it can't contain a newline, and if you really want to insert a double-quote, you do it with \". It turns that into the section name "secion.randomstring". So you could use this for things like [email "torvalds@xxxxxxxx"] name = Linus Torvalds if you wanted to do the "email->name" conversion as part of the config file format (I'm not claiming that is sensible, I'm just giving it as an insane example). That would show up as the association email.torvalds@xxxxxxxxxxxxx -> Linus Torvalds which is easy to parse (the "." in the email _looks_ ambiguous, but it isn't: you know that there will always be a single key-name, so you find the key name with "strrchr(name, '.')" and things are entirely unambiguous). Now, it doesn't do any repo-config stuff, since the whole point of this is to make this a legal syntax, not actually start _using_ it yet. If people think this is an acceptable syntax, then pls apply to everything, and worry about usage later. Linus --- diff --git a/config.c b/config.c index 0f518c9..f3b74e0 100644 --- a/config.c +++ b/config.c @@ -134,6 +134,41 @@ static int get_value(config_fn_t fn, cha return fn(name, value); } +static int get_extended_base_var(char *name, int baselen, int c) +{ + do { + if (c == '\n') + return -1; + c = get_next_char(); + } while (isspace(c)); + + /* We require the format to be '[base "extension"]' */ + if (c != '"') + return -1; + name[baselen++] = '.'; + + for (;;) { + int c = get_next_char(); + if (c == '\n') + return -1; + if (c == '"') + break; + if (c == '\\') { + c = get_next_char(); + if (c == '\n') + return -1; + } + name[baselen++] = c; + if (baselen > MAXNAME / 2) + return -1; + } + + /* Final ']' */ + if (get_next_char() != ']') + return -1; + return baselen; +} + static int get_base_var(char *name) { int baselen = 0; @@ -144,6 +179,8 @@ static int get_base_var(char *name) return -1; if (c == ']') return baselen; + if (isspace(c)) + return get_extended_base_var(name, baselen, c); if (!isalnum(c) && c != '.') return -1; if (baselen > MAXNAME / 2) - : 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