diff options
author | Linus Torvalds <torvalds@osdl.org> | 2006-05-09 12:24:02 -0700 |
---|---|---|
committer | Junio C Hamano <junkio@cox.net> | 2006-05-13 14:00:16 -0700 |
commit | d14f776402d9f7040cc71ff6e3b992b2e019526a (patch) | |
tree | a047cb0c911b3bad3504861341fb1971503c697c /repo-config.c | |
parent | Another config file parsing fix. (diff) | |
download | tgif-d14f776402d9f7040cc71ff6e3b992b2e019526a.tar.xz |
git config syntax updates
This updates the hierarchical section name syntax to
[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". The
"section" part is still case insensitive, but the "randomstring"
part is case sensitive.
So you could use this for things like
[email "torvalds@osdl.org"]
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@osdl.org.name -> 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).
Repo-config is updated to be able to parse the new format, and also
write things out in the new format.
[jc: rolled two patches from Linus and one fix-up from Sean into one,
with additional adjustments for t/t1300 test to check the case
insensitiveness of section base and variable and case sensitiveness
of the extended section part. Then stripped some part off to make
the result applicable to the stale 1.3.X series that does not have
recent enhancements. ]
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Signed-off-by: Sean Estabrooks <seanlkml@sympatico.ca>
Signed-off-by: Junio C Hamano <junkio@cox.net>
Diffstat (limited to 'repo-config.c')
-rw-r--r-- | repo-config.c | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/repo-config.c b/repo-config.c index c5ebb7668a..58b6c5284f 100644 --- a/repo-config.c +++ b/repo-config.c @@ -48,11 +48,13 @@ static int show_config(const char* key_, const char* value_) static int get_value(const char* key_, const char* regex_) { int i; + char *tl; - key = malloc(strlen(key_)+1); - for (i = 0; key_[i]; i++) - key[i] = tolower(key_[i]); - key[i] = 0; + key = strdup(key_); + for (tl=key+strlen(key)-1; tl >= key && *tl != '.'; --tl) + *tl = tolower(*tl); + for (tl=key; *tl && *tl != '.'; ++tl) + *tl = tolower(*tl); if (regex_) { if (regex_[0] == '!') { |