diff options
author | Edward Thomson <ethomson@edwardthomson.com> | 2022-02-21 16:13:52 +0000 |
---|---|---|
committer | Edward Thomson <ethomson@edwardthomson.com> | 2022-02-26 12:59:16 -0500 |
commit | 377ec9bfe7d84aad1ac23206144b7cdb7f867df2 (patch) | |
tree | bec61f3ebf6eefd2a9a44fac2c64a2e36ea5b58e | |
parent | 5d9f2aff9423a0395fd909312e2cfd7085552fd8 (diff) | |
download | libgit2-377ec9bfe7d84aad1ac23206144b7cdb7f867df2.tar.gz |
win32: `find_system_dirs` does not return `GIT_ENOTFOUND`
Allow for no Git for Windows installation. When there is no GfW found
in the path or registry, `git_win32__find_system_dirs` would return a
`GIT_ENOTFOUND`. Callers were not expecting this. Since this is no
error, we simply return `0` so that callers can move on with their
lives.
-rw-r--r-- | src/win32/findfile.c | 2 | ||||
-rw-r--r-- | tests/win32/systemdir.c | 10 |
2 files changed, 11 insertions, 1 deletions
diff --git a/src/win32/findfile.c b/src/win32/findfile.c index 516391d7f..725a90167 100644 --- a/src/win32/findfile.c +++ b/src/win32/findfile.c @@ -222,7 +222,7 @@ int git_win32__find_system_dirs(git_str *out, const char *subdir) has_regdir = (find_sysdir_in_registry(regdir) == 0); if (!has_pathdir && !has_regdir) - return GIT_ENOTFOUND; + return 0; /* * Usually the git in the path is the same git in the registry, diff --git a/tests/win32/systemdir.c b/tests/win32/systemdir.c index 46fa06a50..52c1784a1 100644 --- a/tests/win32/systemdir.c +++ b/tests/win32/systemdir.c @@ -326,3 +326,13 @@ void test_win32_systemdir__prefers_path_to_registry(void) git_config_free(cfg); #endif } + +void test_win32_systemdir__no_git_installed(void) +{ +#ifdef GIT_WIN32 + git_str out = GIT_STR_INIT; + + cl_git_pass(git_win32__find_system_dirs(&out, "etc")); + cl_assert_equal_s(out.ptr, ""); +#endif +} |