diff options
author | Johannes Schindelin <johannes.schindelin@gmx.de> | 2019-10-04 08:09:30 -0700 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2019-10-06 09:07:44 +0900 |
commit | 61d1d92aa4785090213e89566e01e342f60d9b92 (patch) | |
tree | 2dd361dbad18bf32b0351388f20e056224836a22 /contrib | |
parent | msvc: handle DEVELOPER=1 (diff) | |
download | tgif-61d1d92aa4785090213e89566e01e342f60d9b92.tar.xz |
msvc: work around a bug in GetEnvironmentVariable()
The return value of that function is 0 both for variables that are
unset, as well as for variables whose values are empty. To discern those
two cases, one has to call `GetLastError()`, whose return value is
`ERROR_ENVVAR_NOT_FOUND` and `ERROR_SUCCESS`, respectively.
Except that it is not actually set to `ERROR_SUCCESS` in the latter
case, apparently, but the last error value seems to be simply unchanged.
To work around this, let's just re-set the last error value just before
inspecting the environment variable.
This fixes a problem that triggers failures in t3301-notes.sh (where we
try to override config settings by passing empty values for certain
environment variables).
This problem is hidden in the MINGW build by the fact that older
MSVC runtimes (such as the one used by MINGW builds) have a `calloc()`
that re-sets the last error value in case of success, while newer
runtimes set the error value only if `NULL` is returned by that
function.
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'contrib')
0 files changed, 0 insertions, 0 deletions