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>
Linus Torvalds committed
Oct 30, 2006 at 08:25 UTC
38c5afa87e24756f0465e24c2b7018de62e4bfc1
1 file changed
+8
-3
config.c
+8
-3
@@ -103,6 +103,11 @@ static char *parse_value(void)
103
}
104
}
105
106
+static inline int iskeychar(int c)
107
+{
108
+ return isalnum(c) || c == '-';
109
+}
110
+
111
static int get_value(config_fn_t fn, char *name, unsigned int len)
112
{
113
int c;
@@ -113,7 +118,7 @@ static int get_value(config_fn_t fn, char *name, unsigned int len)
118
c = get_next_char();
119
if (c == EOF)
120
break;
116
- if (!isalnum(c))
121
+ if (!iskeychar(c))
122
break;
123
name[len++] = tolower(c);
124
if (len >= MAXNAME)
@@ -181,7 +186,7 @@ static int get_base_var(char *name)
186
return baselen;
187
if (isspace(c))
188
return get_extended_base_var(name, baselen, c);
184
- if (!isalnum(c) && c != '.')
189
+ if (!iskeychar(c) && c != '.')
190
return -1;
191
if (baselen > MAXNAME / 2)
192
return -1;
@@ -573,7 +578,7 @@ int git_config_set_multivar(const char* key, const char* value,
578
dot = 1;
579
/* Leave the extended basename untouched.. */
580
if (!dot || i > store.baselen) {
576
- if (!isalnum(c) || (i == store.baselen+1 && !isalpha(c))) {
581
+ if (!iskeychar(c) || (i == store.baselen+1 && !isalpha(c))) {
582
fprintf(stderr, "invalid key: %s\n", key);
583
free(store.key);
584
ret = 1;