Skip to content

Commit 1cbc960

Browse files
committed
config: add failing test for no newline after section header
1 parent 814e7ac commit 1cbc960

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed

tests/config/read.c

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -759,6 +759,36 @@ void test_config_read__bom(void)
759759
git_buf_dispose(&buf);
760760
}
761761

762+
void test_config_read__single_line(void)
763+
{
764+
git_buf buf = GIT_BUF_INIT;
765+
git_config *cfg;
766+
767+
cl_set_cleanup(&clean_test_config, NULL);
768+
cl_git_mkfile("./testconfig", "[some] var = value\n[some \"OtheR\"] var = value");
769+
cl_git_pass(git_config_open_ondisk(&cfg, "./testconfig"));
770+
cl_git_pass(git_config_get_string_buf(&buf, cfg, "some.var"));
771+
cl_assert_equal_s(buf.ptr, "value");
772+
773+
git_buf_clear(&buf);
774+
cl_git_pass(git_config_get_string_buf(&buf, cfg, "some.OtheR.var"));
775+
cl_assert_equal_s(buf.ptr, "value");
776+
777+
git_config_free(cfg);
778+
cl_git_mkfile("./testconfig", "[some] var = value\n[some \"OtheR\"]var = value");
779+
cl_git_pass(git_config_open_ondisk(&cfg, "./testconfig"));
780+
git_buf_clear(&buf);
781+
cl_git_pass(git_config_get_string_buf(&buf, cfg, "some.var"));
782+
cl_assert_equal_s(buf.ptr, "value");
783+
784+
git_buf_clear(&buf);
785+
cl_git_pass(git_config_get_string_buf(&buf, cfg, "some.OtheR.var"));
786+
cl_assert_equal_s(buf.ptr, "value");
787+
788+
git_config_free(cfg);
789+
git_buf_dispose(&buf);
790+
}
791+
762792
static int read_nosection_cb(const git_config_entry *entry, void *payload) {
763793
int *seen = (int*)payload;
764794
if (strcmp(entry->name, "key") == 0) {

0 commit comments

Comments
 (0)