8000 config: return `GIT_ENOTFOUND` for missing programdata by ethomson · Pull Request #6547 · libgit2/libgit2 · GitHub
[go: up one dir, main page]

Skip to content

config: return GIT_ENOTFOUND for missing programdata #6547

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 12, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed 8000 to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions src/libgit2/config.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 ((error = git_sysdir_find_programdata_file(path, GIT_CONFIG_FILENAME_PROGRAMDATA)) < 0)
return 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 (git_fs_path_owner_is(&is_safe, path->ptr, owner_level) < 0)
return -1;

if (!is_safe) {
Expand Down
11 changes: 11 additions & 0 deletions tests/libgit2/config/find.c
Original file line number Diff line number Diff line change
@@ -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));
}
0