Skip to content

Commit 9df6922

Browse files
ethomsonpks-t
authored andcommitted
config: test that unreadable files are treated as notfound
1 parent d1409f4 commit 9df6922

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

tests/config/read.c

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -849,6 +849,23 @@ void test_config_read__invalid_quoted_third_section(void)
849849
git_config_free(cfg);
850850
}
851851

852+
void test_config_read__unreadable_file_ignored(void)
853+
{
854+
git_buf buf = GIT_BUF_INIT;
855+
git_config *cfg;
856+
int ret;
857+
858+
cl_set_cleanup(&clean_test_config, NULL);
859+
cl_git_mkfile("./testconfig", "[some] var = value\n[some \"OtheR\"] var = value");
860+
cl_git_pass(p_chmod("./testconfig", 0));
861+
862+
ret = git_config_open_ondisk(&cfg, "./test/config");
863+
cl_assert(ret == 0 || ret == GIT_ENOTFOUND);
864+
865+
git_config_free(cfg);
866+
git_buf_dispose(&buf);
867+
}
868+
852869
void test_config_read__single_line(void)
853870
{
854871
git_buf buf = GIT_BUF_INIT;

0 commit comments

Comments
 (0)