mirror of
https://git.proxmox.com/git/libgit2
synced 2025-05-06 17:20:22 +00:00
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>
This commit is contained in:
parent
0bf8ca8820
commit
2470be13f2
11
src/config.c
11
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);
|
existing = cvar_list_find(cfg->vars, name);
|
||||||
if (existing != NULL) {
|
if (existing != NULL) {
|
||||||
char *tmp = git__strdup(value);
|
char *tmp = value ? git__strdup(value) : NULL;
|
||||||
if (tmp == NULL)
|
if (tmp == NULL && value != NULL)
|
||||||
return GIT_ENOMEM;
|
return GIT_ENOMEM;
|
||||||
|
|
||||||
free(existing->value);
|
free(existing->value);
|
||||||
@ -297,8 +297,8 @@ static int config_set(git_config *cfg, const char *name, const char *value)
|
|||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
var->value = git__strdup(value);
|
var->value = value ? git__strdup(value) : NULL;
|
||||||
if(var->value == NULL){
|
if(var->value == NULL && value != NULL){
|
||||||
error = GIT_ENOMEM;
|
error = GIT_ENOMEM;
|
||||||
cvar_free(var);
|
cvar_free(var);
|
||||||
goto out;
|
goto out;
|
||||||
@ -1060,6 +1060,9 @@ static int parse_variable(git_config *cfg, char **var_name, char **var_value)
|
|||||||
}
|
}
|
||||||
|
|
||||||
*var_value = tmp;
|
*var_value = tmp;
|
||||||
|
} else {
|
||||||
|
/* If thre is no value, boolean true is assumed */
|
||||||
|
*var_value = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
out:
|
out:
|
||||||
|
Loading…
Reference in New Issue
Block a user