That wouldn't help. The thing is designed to not only need no quoting
(except for the _value_), it also is designed to have both section and key
names ignore case. So you really aren't supposed to put things like branch
names (which are potentially case-sensitive, depending on filesystem) in
either.
And we depend on that (and I think it's important - users normally should
_not_ care about capitalization)
So you'd need to literally create a different syntax if you want unquoted
section naming.
Here's a possible syntax/patch. I actually think the quoting makes more
sense in the section name, since you'll usually want several keys under
each branch, so it makes sense to make the _branch_ be the section.
It basically makes it a special case if you have the section name be
marked with quotes, like
["XyZZy"]
and in that case it turns the _real_ section name into the string
"branch.XyZZy", where the important part is that it does this without
changing case or limiting the character set (but it will _not_ allow a
newline) in any way.
So you could have something like
["Origin"]
URL = ...
fetch = master
and it would just turn it into
branch.Origin.url = ...
branch.Origin.fetch = master
etc.
No, I'm not sure this is the best possible syntax. It's just a suggestion.
And it's certainly simple enough.
The downside is that if you start using config files like this, you
literally can't go back to older git versions. They'll refuse to touch
such a config file (rather than just ignoring the new entries) and will
exit with nasty messages. That might be unacceptable.
Instead of quoting with double-quotes, it might be ok to use some
alternate syntax line "[:$branchname:]" which looks visually reasonable,
and has the potential advantage that ':' is already an invalid character
in a branch name, so you don't actually even need any quoting logic at all
at that point.
I think the
["branch"]
...
syntax looks reasonably readable and clean.
Linus
----
diff --git a/config.c b/config.c
index 41066e4..802e326 100644
--- a/config.c
+++ b/config.c
@@ -134,9 +134,44 @@ static int get_value(config_fn_t fn, cha
return fn(name, value);
}
+static int get_branch_name(char *name)
+{
+ int baselen = 7;
+ int quote = 0;
+
+ memcpy(name, "branch.", 7);
+ for (;;) {
+ int c = get_next_char();
+ if (c == EOF)
+ return -1;
+ if (c == '\n')
+ return -1;
+ if (!quote) {
+ if (c == '"')
+ break;
+ if (c == ']')
+ return -1;
+ if (c == '\\') {
+ quote = 1;
+ continue;
+ }
+ }
+ name[baselen++] = c;
+ if (baselen > MAXNAME / 2)
+ return -1;
+ }
+ if (get_next_char() != ']')
+ return -1;
+ return baselen;
+}
+
static int get_base_var(char *name)
{
int baselen = 0;
+ int c = get_next_char();
+
+ if (c == '"')
+ return get_branch_name(name);
for (;;) {
int c = get_next_char();
-
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html