Commit bb8bc4b8 by Carlos Martín Nieto

config: add failing test for preserving case when writing keys

While most parts of a configuration key are case-insensitive, we should still be
case-preserving and write down whatever string the caller provided.
parent 9e3fb594
...@@ -722,3 +722,26 @@ void test_config_write__repeated(void) ...@@ -722,3 +722,26 @@ void test_config_write__repeated(void)
git_config_free(cfg); git_config_free(cfg);
} }
void test_config_write__preserve_case(void)
{
const char *filename = "config-preserve-case";
git_config *cfg;
git_buf result = GIT_BUF_INIT;
const char *expected = "[sOMe]\n" \
"\tThInG = foo\n" \
"\tOtheR = thing\n";
cl_git_pass(git_config_open_ondisk(&cfg, filename));
cl_git_pass(git_config_set_string(cfg, "sOMe.ThInG", "foo"));
cl_git_pass(git_config_set_string(cfg, "SomE.OtheR", "thing"));
git_config_free(cfg);
cl_git_pass(git_config_open_ondisk(&cfg, filename));
cl_git_pass(git_futils_readbuffer(&result, filename));
cl_assert_equal_s(expected, result.ptr);
git_buf_free(&result);
git_config_free(cfg);
}
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