Commit 9df69223b13f59032fd295124666c6a5627a450a

Edward Thomson 2020-05-23T11:42:19

config: test that unreadable files are treated as notfound

diff --git a/tests/config/read.c b/tests/config/read.c
index 008dfd9..ba97302 100644
--- a/tests/config/read.c
+++ b/tests/config/read.c
@@ -849,6 +849,23 @@ void test_config_read__invalid_quoted_third_section(void)
 	git_config_free(cfg);
 }
 
+void test_config_read__unreadable_file_ignored(void)
+{
+	git_buf buf = GIT_BUF_INIT;
+	git_config *cfg;
+	int ret;
+
+	cl_set_cleanup(&clean_test_config, NULL);
+	cl_git_mkfile("./testconfig", "[some] var = value\n[some \"OtheR\"] var = value");
+	cl_git_pass(p_chmod("./testconfig", 0));
+
+	ret = git_config_open_ondisk(&cfg, "./test/config");
+	cl_assert(ret == 0 || ret == GIT_ENOTFOUND);
+
+	git_config_free(cfg);
+	git_buf_dispose(&buf);
+}
+
 void test_config_read__single_line(void)
 {
 	git_buf buf = GIT_BUF_INIT;