Safe-guard the Windows code a bit more against getenv() problems #127
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
We saw a couple of getenv() cleanups, where we now immediately duplicate the return value of
getenv()
in order to avoid problems. However, I am really uncomfortable with the current value (30) ofGETENV_MAX_RETAIN
incompat/mingw.c
: it strikes me as low, given that the average number ofgetenv()
call per Git process in Git's test suite is already 40.I'd really like to increase it, even if it won't help problems where
getenv()
is called in a loop whose number of iteration depends on user input (like the problem fixed in 6776a84 (diff: ensure correct lifetime of external_diff_cmd, 2019-01-11)). It will still fend off plenty of other cases, I believe.And yes, it's in my TODOs to look back over those getenv() issues after v2.21.0 (see git-for-windows#2019 for my progress).