Commit 7f7ebe13 by Russell Belfer

Merge pull request #1771 from nvloff/write_empty_config_value

config: allow setting  empty string as value
parents 5e96f316 c57f6682
...@@ -1304,6 +1304,9 @@ static char *escape_value(const char *ptr) ...@@ -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) ...@@ -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();
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment