8000 Merge pull request #6547 from libgit2/ethomson/programdata · libgit2/libgit2@ae49d55 · GitHub
[go: up one dir, main page]

Skip to content

Commit ae49d55

Browse files
authored
Merge pull request #6547 from libgit2/ethomson/programdata
config: return `GIT_ENOTFOUND` for missing programdata
2 parents 51f3e0a + 54bcafe commit ae49d55

File tree

2 files changed

+16
-2
lines changed

2 files changed

+16
-2
lines changed

src/libgit2/config.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1174,9 +1174,12 @@ int git_config__find_programdata(git_str *path)
11741174
GIT_FS_PATH_OWNER_CURRENT_USER |
11751175
GIT_FS_PATH_OWNER_ADMINISTRATOR;
11761176
bool is_safe;
1177+
int error;
1178+
1179+
if ((error = git_sysdir_find_programdata_file(path, GIT_CONFIG_FILENAME_PROGRAMDATA)) < 0)
1180+
return error;
11771181

1178-
if (git_sysdir_find_programdata_file(path, GIT_CONFIG_FILENAME_PROGRAMDATA) < 0 ||
1179-
git_fs_path_owner_is(&is_safe, path->ptr, owner_level) < 0)
1182+
if (git_fs_path_owner_is(&is_safe, path->ptr, owner_level) < 0)
11801183
return -1;
11811184

11821185
if (!is_safe) {

tests/libgit2/config/find.c

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
#include "clar_libgit2.h"
2+
3+
void test_config_find__one(void)
4+
{
5+
git_buf buf = GIT_BUF_INIT;
6+
7+
cl_git_fail_with(GIT_ENOTFOUND, git_config_find_global(&buf));
8+
cl_git_fail_with(GIT_ENOTFOUND, git_config_find_xdg(&buf));
9+
cl_git_fail_with(GIT_ENOTFOUND, git_config_find_system(&buf));
10+
cl_git_fail_with(GIT_ENOTFOUND, git_config_find_programdata(&buf));
11+
}

0 commit comments

Comments
 (0)
0