summaryrefslogtreecommitdiff
path: root/src/config.c
diff options
context:
space:
mode:
authorCarlos Martín Nieto <cmn@elego.de>2011-04-04 17:06:31 +0200
committerCarlos Martín Nieto <cmn@elego.de>2011-04-04 17:06:31 +0200
commit2470be13f28c6599d25bf23b61a3f1b369c9f400 (patch)
tree6e80db6b1426fb45ec38b056cae1fa14914207ed /src/config.c
parent0bf8ca8820489ff7e154964771688c74eaf1933d (diff)
downloadlibgit2-2470be13f28c6599d25bf23b61a3f1b369c9f400.tar.gz
config: variable name on its own means true
If a variable name appears on its own in a line, it's assumed the value is true. Store the variable name as NULL in that case. Signed-off-by: Carlos Martín Nieto <cmn@elego.de>
Diffstat (limited to 'src/config.c')
-rw-r--r--src/config.c11
1 files changed, 7 insertions, 4 deletions
diff --git a/src/config.c b/src/config.c
index 93f15fb08..bd0886e8d 100644
--- a/src/config.c
+++ b/src/config.c
@@ -270,8 +270,8 @@ static int config_set(git_config *cfg, const char *name, const char *value)
*/
existing = cvar_list_find(cfg->vars, name);
if (existing != NULL) {
- char *tmp = git__strdup(value);
- if (tmp == NULL)
+ char *tmp = value ? git__strdup(value) : NULL;
+ if (tmp == NULL && value != NULL)
return GIT_ENOMEM;
free(existing->value);
@@ -297,8 +297,8 @@ static int config_set(git_config *cfg, const char *name, const char *value)
goto out;
}
- var->value = git__strdup(value);
- if(var->value == NULL){
+ var->value = value ? git__strdup(value) : NULL;
+ if(var->value == NULL && value != NULL){
error = GIT_ENOMEM;
cvar_free(var);
goto out;
@@ -1060,6 +1060,9 @@ static int parse_variable(git_config *cfg, char **var_name, char **var_value)
}
*var_value = tmp;
+ } else {
+ /* If thre is no value, boolean true is assumed */
+ *var_value = NULL;
}
out: