summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/repository.c6
-rw-r--r--tests/repo/config.c19
2 files changed, 22 insertions, 3 deletions
diff --git a/src/repository.c b/src/repository.c
index fccc16faa..744bd9860 100644
--- a/src/repository.c
+++ b/src/repository.c
@@ -538,19 +538,19 @@ static int load_config(
git_buf_free(&config_path);
if (global_config_path != NULL &&
- (error = git_config_add_file_ondisk(
+ (error = git_config_add_file_ondisk_gently(
cfg, global_config_path, GIT_CONFIG_LEVEL_GLOBAL, 0)) < 0 &&
error != GIT_ENOTFOUND)
goto on_error;
if (xdg_config_path != NULL &&
- (error = git_config_add_file_ondisk(
+ (error = git_config_add_file_ondisk_gently(
cfg, xdg_config_path, GIT_CONFIG_LEVEL_XDG, 0)) < 0 &&
error != GIT_ENOTFOUND)
goto on_error;
if (system_config_path != NULL &&
- (error = git_config_add_file_ondisk(
+ (error = git_config_add_file_ondisk_gently(
cfg, system_config_path, GIT_CONFIG_LEVEL_SYSTEM, 0)) < 0 &&
error != GIT_ENOTFOUND)
goto on_error;
diff --git a/tests/repo/config.c b/tests/repo/config.c
index 2e7be37aa..c0597b92c 100644
--- a/tests/repo/config.c
+++ b/tests/repo/config.c
@@ -51,6 +51,25 @@ void test_repo_config__open_missing_global(void)
git_sysdir_global_shutdown();
}
+void test_repo_config__inaccessible_global(void)
+{
+ git_repository *repo;
+
+ cl_git_pass(git_libgit2_opts(
+ GIT_OPT_SET_SEARCH_PATH, GIT_CONFIG_LEVEL_GLOBAL, path.ptr));
+ cl_git_pass(git_libgit2_opts(
+ GIT_OPT_SET_SEARCH_PATH, GIT_CONFIG_LEVEL_SYSTEM, path.ptr));
+ cl_git_pass(git_libgit2_opts(
+ GIT_OPT_SET_SEARCH_PATH, GIT_CONFIG_LEVEL_XDG, path.ptr));
+
+ cl_must_pass(p_chmod(path.ptr, 0000));
+
+ cl_git_pass(git_repository_open(&repo, "empty_standard_repo"));
+ git_repository_free(repo);
+
+ cl_must_pass(p_chmod(path.ptr, 0777));
+}
+
void test_repo_config__open_missing_global_with_separators(void)
{
git_repository *repo;