Commit eca9e1cfec2be5a55401290de9eb944bcb54c867

Edward Thomson 2022-02-22T07:17:12

Merge pull request #6228 from libgit2/ethomson/win32_systemdirs win32: `find_system_dirs` does not return `GIT_ENOTFOUND`

diff --git a/src/win32/findfile.c b/src/win32/findfile.c
index 516391d..725a901 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 46fa06a..52c1784 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
+}