Commit 0a8728622ecf77ce4185139761b31f0c6f77f04e

Edward Thomson 2021-09-20T14:00:36

Merge pull request #6063 from libgit2/ethomson/win32_envvar win32: allow empty environment variables

1
2
3
4
5
6
7
8
9
10
11
12
13
diff --git a/src/util.c b/src/util.c
index c7af296..9b0c45c 100644
--- a/src/util.c
+++ b/src/util.c
@@ -755,7 +755,7 @@ int git__getenv(git_buf *out, const char *name)
 
 	if (value_len)
 		error = git_buf_put_w(out, wide_value, value_len);
-	else if (GetLastError() == ERROR_ENVVAR_NOT_FOUND)
+	else if (GetLastError() == ERROR_SUCCESS || GetLastError() == ERROR_ENVVAR_NOT_FOUND)
 		error = GIT_ENOTFOUND;
 	else
 		git_error_set(GIT_ERROR_OS, "could not read environment variable '%s'", name);