Merge pull request #6547 from libgit2/ethomson/programdata

config: return `GIT_ENOTFOUND` for missing programdata
This commit is contained in:
Edward Thomson
2023-04-12 11:59:20 +01:00
committed by GitHub
2 changed files with 16 additions and 2 deletions

View File

@@ -1174,9 +1174,12 @@ int git_config__find_programdata(git_str *path)
GIT_FS_PATH_OWNER_CURRENT_USER |
GIT_FS_PATH_OWNER_ADMINISTRATOR;
bool is_safe;
int error;
if (git_sysdir_find_programdata_file(path, GIT_CONFIG_FILENAME_PROGRAMDATA) < 0 ||
git_fs_path_owner_is(&is_safe, path->ptr, owner_level) < 0)
if ((error = git_sysdir_find_programdata_file(path, GIT_CONFIG_FILENAME_PROGRAMDATA)) < 0)
return error;
if (git_fs_path_owner_is(&is_safe, path->ptr, owner_level) < 0)
return -1;
if (!is_safe) {

View File

@@ -0,0 +1,11 @@
#include "clar_libgit2.h"
void test_config_find__one(void)
{
git_buf buf = GIT_BUF_INIT;
cl_git_fail_with(GIT_ENOTFOUND, git_config_find_global(&buf));
cl_git_fail_with(GIT_ENOTFOUND, git_config_find_xdg(&buf));
cl_git_fail_with(GIT_ENOTFOUND, git_config_find_system(&buf));
cl_git_fail_with(GIT_ENOTFOUND, git_config_find_programdata(&buf));
}