Skip to content

Commit bb8bc4b

Browse files
committed
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.
1 parent 9e3fb59 commit bb8bc4b

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

tests/config/write.c

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -722,3 +722,26 @@ void test_config_write__repeated(void)
722722

723723
git_config_free(cfg);
724724
}
725+
726+
void test_config_write__preserve_case(void)
727+
{
728+
const char *filename = "config-preserve-case";
729+
git_config *cfg;
730+
git_buf result = GIT_BUF_INIT;
731+
const char *expected = "[sOMe]\n" \
732+
"\tThInG = foo\n" \
733+
"\tOtheR = thing\n";
734+
735+
cl_git_pass(git_config_open_ondisk(&cfg, filename));
736+
cl_git_pass(git_config_set_string(cfg, "sOMe.ThInG", "foo"));
737+
cl_git_pass(git_config_set_string(cfg, "SomE.OtheR", "thing"));
738+
git_config_free(cfg);
739+
740+
cl_git_pass(git_config_open_ondisk(&cfg, filename));
741+
742+
cl_git_pass(git_futils_readbuffer(&result, filename));
743+
cl_assert_equal_s(expected, result.ptr);
744+
git_buf_free(&result);
745+
746+
git_config_free(cfg);
747+
}

0 commit comments

Comments
 (0)