summaryrefslogtreecommitdiff
path: root/config.c
diff options
context:
space:
mode:
authorJohannes Schindelin <Johannes.Schindelin@gmx.de>2005-11-20 20:22:19 (GMT)
committerJunio C Hamano <junkio@cox.net>2005-11-21 22:04:28 (GMT)
commitb17e659dd4007cb1d3eb5ac32b524c0c5ab59601 (patch)
tree1a2d1ce9be64d0c7709f56079957eccdac8bd87e /config.c
parent3dd94e3b2e2f5b00512273f96ab5628c742c112c (diff)
downloadgit-b17e659dd4007cb1d3eb5ac32b524c0c5ab59601.zip
git-b17e659dd4007cb1d3eb5ac32b524c0c5ab59601.tar.gz
git-b17e659dd4007cb1d3eb5ac32b524c0c5ab59601.tar.bz2
Allow hierarchical section names
A .git/config like follows becomes valid with this patch: [remote.junio] url = git://git.kernel.org/pub/scm/git/git.git pull = master:junio todo:todo +pu:pu [remote.ibook] url = ibook:git/ pull = master:ibook push = master:quetzal (This patch only does the ini file thing, git-fetch and friends still ignore these values). Signed-off-by: Johannes Schindelin <Johannes.Schindelin@gmx.de> Signed-off-by: Junio C Hamano <junkio@cox.net>
Diffstat (limited to 'config.c')
-rw-r--r--config.c19
1 files changed, 10 insertions, 9 deletions
diff --git a/config.c b/config.c
index e78520b..357c1ca 100644
--- a/config.c
+++ b/config.c
@@ -143,7 +143,7 @@ static int get_base_var(char *name)
return -1;
if (c == ']')
return baselen;
- if (!isalnum(c))
+ if (!isalnum(c) && c != '.')
return -1;
if (baselen > MAXNAME / 2)
return -1;
@@ -405,28 +405,29 @@ int git_config_set_multivar(const char* key, const char* value,
int fd;
char* config_file = strdup(git_path("config"));
char* lock_file = strdup(git_path("config.lock"));
-
- store.multi_replace = multi_replace;
+ const char* last_dot = strrchr(key, '.');
/*
* Since "key" actually contains the section name and the real
* key name separated by a dot, we have to know where the dot is.
*/
- for (store.baselen = 0;
- key[store.baselen] != '.' && key[store.baselen];
- store.baselen++);
- if (!key[store.baselen] || !key[store.baselen+1]) {
+
+ if (last_dot == NULL) {
fprintf(stderr, "key does not contain a section: %s\n", key);
return 2;
}
+ store.baselen = last_dot - key;
+
+ store.multi_replace = multi_replace;
/*
* Validate the key and while at it, lower case it for matching.
*/
store.key = (char*)malloc(strlen(key)+1);
for (i = 0; key[i]; i++)
- if (i != store.baselen && (!isalnum(key[i]) ||
- (i == store.baselen+1 && !isalpha(key[i])))) {
+ if (i != store.baselen &&
+ ((!isalnum(key[i]) && key[i] != '.') ||
+ (i == store.baselen+1 && !isalpha(key[i])))) {
fprintf(stderr, "invalid key: %s\n", key);
free(store.key);
return 1;