libgit2/libgit2 — pull request #1003 by arrbee (2012-10-19 23:12:02+00:00)
Title: Fix env variable tests with new Win32 path rules

The new Win32 global path search was not working with the environment variable tests. But when I fixed the test, the new code's use of `getenv()` was causing more failures (presumably because of value caching on Windows ???).

This PR fixes the global file lookup to stop calling `getenv()` on Windows and instead always go directly to the Win32 API in a predictable way. I restructured the code but tried to preserve the failure scenarios from the old implementation (i.e. no error to have `%HOME%` and not find the file, but if either of the other variables are set, then ENOTFOUND if they don't contain the file).

This also fixes the `core::env` tests to exercise the new environment variable logic (which should be fairly stable since it is based on msysgit). I don't love that the test is tightly coupled with the internal logic of the function being tested, but without that knowledge of the right environment variables to manipulate, it's pretty hard to test the function.

This should resolve issue #999.