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.
diff --git a/tests/config/write.c b/tests/config/write.c
index 56ef2e9..01b018b 100644
--- a/tests/config/write.c
+++ b/tests/config/write.c
@@ -722,3 +722,26 @@ void test_config_write__repeated(void)
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);
+}