mirror of
https://git.proxmox.com/git/libgit2
synced 2025-08-12 02:57:24 +00:00
Merge pull request #1771 from nvloff/write_empty_config_value
config: allow setting empty string as value
This commit is contained in:
commit
7f7ebe13c4
@ -1304,6 +1304,9 @@ static char *escape_value(const char *ptr)
|
|||||||
assert(ptr);
|
assert(ptr);
|
||||||
|
|
||||||
len = strlen(ptr);
|
len = strlen(ptr);
|
||||||
|
if (!len)
|
||||||
|
return git__calloc(1, sizeof(char));
|
||||||
|
|
||||||
git_buf_grow(&buf, len);
|
git_buf_grow(&buf, len);
|
||||||
|
|
||||||
while (*ptr != '\0') {
|
while (*ptr != '\0') {
|
||||||
|
@ -242,3 +242,20 @@ void test_config_write__can_set_a_value_to_NULL(void)
|
|||||||
|
|
||||||
cl_git_sandbox_cleanup();
|
cl_git_sandbox_cleanup();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void test_config_write__can_set_an_empty_value(void)
|
||||||
|
{
|
||||||
|
git_repository *repository;
|
||||||
|
git_config *config;
|
||||||
|
const char * str;
|
||||||
|
|
||||||
|
repository = cl_git_sandbox_init("testrepo.git");
|
||||||
|
cl_git_pass(git_repository_config(&config, repository));
|
||||||
|
|
||||||
|
cl_git_pass(git_config_set_string(config, "core.somevar", ""));
|
||||||
|
cl_git_pass(git_config_get_string(&str, config, "core.somevar"));
|
||||||
|
cl_assert_equal_s(str, "");
|
||||||
|
|
||||||
|
git_config_free(config);
|
||||||
|
cl_git_sandbox_cleanup();
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user