summaryrefslogtreecommitdiff
path: root/config.c
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@osdl.org>2006-10-30 08:25:36 -0800
committerJunio C Hamano <junkio@cox.net>2006-10-30 19:39:12 -0800
commit38c5afa87e24756f0465e24c2b7018de62e4bfc1 (patch)
tree2db1eca9400781b4ea41413c34764641d114c39e /config.c
parent83877f8d92b2050eb668dc3351277e57779a8f05 (diff)
downloadgit-38c5afa87e24756f0465e24c2b7018de62e4bfc1.tar.gz
Allow '-' in config variable names
I need this in order to allow aliases of the same form as "ls-tree", "rev-parse" etc, so that I can use [alias] my-cat=--paginate cat-file -p to add a "git my-cat" command. Signed-off-by: Linus Torvalds <torvalds@osdl.org> Signed-off-by: Junio C Hamano <junkio@cox.net>
Diffstat (limited to 'config.c')
-rw-r--r--config.c11
1 files changed, 8 insertions, 3 deletions
diff --git a/config.c b/config.c
index e8f0caf7cf..3cae3901aa 100644
--- a/config.c
+++ b/config.c
@@ -103,6 +103,11 @@ static char *parse_value(void)
}
}
+static inline int iskeychar(int c)
+{
+ return isalnum(c) || c == '-';
+}
+
static int get_value(config_fn_t fn, char *name, unsigned int len)
{
int c;
@@ -113,7 +118,7 @@ static int get_value(config_fn_t fn, char *name, unsigned int len)
c = get_next_char();
if (c == EOF)
break;
- if (!isalnum(c))
+ if (!iskeychar(c))
break;
name[len++] = tolower(c);
if (len >= MAXNAME)
@@ -181,7 +186,7 @@ static int get_base_var(char *name)
return baselen;
if (isspace(c))
return get_extended_base_var(name, baselen, c);
- if (!isalnum(c) && c != '.')
+ if (!iskeychar(c) && c != '.')
return -1;
if (baselen > MAXNAME / 2)
return -1;
@@ -573,7 +578,7 @@ int git_config_set_multivar(const char* key, const char* value,
dot = 1;
/* Leave the extended basename untouched.. */
if (!dot || i > store.baselen) {
- if (!isalnum(c) || (i == store.baselen+1 && !isalpha(c))) {
+ if (!iskeychar(c) || (i == store.baselen+1 && !isalpha(c))) {
fprintf(stderr, "invalid key: %s\n", key);
free(store.key);
ret = 1;