You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
fix: Unset other env vars related to GIT_DIR for fixtures
This removes other environment variables that have an effect
conceptually related to `GIT_DIR` even when `GIT_DIR` is not set.
Most of them change where `git` will look for files that are
ordinarily in a repository's `.git` directory. In contrast,
`GIT_WORK_TREE` changes where the working tree is found.
These would rarely be set in the environment in which the tests are
run, but it makes sense to unset them for the same reason as
unsetting `GIT_DIR`, which is already done.
The new `remove_env` calls are roughly in the order in which the
variables they unset are listed in git(1).
This deliberately does not attempt to unset every possible
environment variable that git(1) documents as affecting its
behavior. This is for four reasons:
- Some variables may be set on the test machine without envisioning
this usage, but should still be kept, such as those that cause
more or less traversal than usual to be done. For example, if
`GIT_CEILING_DIRECTORIES` or even `GIT_DISCOVERY_ACROSS_FILESYSTEM`
are set, it may be for a good reason.
- Some variables will have no default unless other variables that
are being modified here are changed again after the changes here.
In particular, `GIT_CONFIG_SYSTEM` only has an effect if
`GIT_CONFIG_NOSYSTEM` is not set. We set `GIT_CONFIG_NOSYSTEM` to
`1`, so if it is unset then a fixture script has unset it, in
which case it is presumably intended that `GIT_CONFIG_SYSTEM`
have some effect (if the fixture script doesn't change/unset it).
- Some variables are useful for extra debugging and make sense to
set when running the test fixtures under foreseeable conditions.
For example, the effects of all `GIT_TRACE*` variables are
intentionally preserved.
- For a few variables, such as `GIT_DEFAULT_HASH`, it is unlikely
that they would be wanted in the test environment, but even more
unlikely that they would be set in that environment without the
intention of experimenting with their effect on fixtures.
However, this is not to say that all environment variables that
would make sense to remove have necessarily been removed.
The removed variables here differ from those removed for the `git`
invocation in `gix-path/src/env/git/mod.rs` for two reasons:
- That is a single `git` invocation for a specific command, so the
environment variables that ought to affect it must be kept, and
others can be removed. But here, arbitrary fixtures need to work,
and they provide almost all of their own environment as needed.
- Setting an unusual value of `GIT_DIR` there that `git` cannot
take to be a usable repository also prevents the variables
that override `GIT_DIR` for specific files from being used. (But
maybe those should be unset there anyway, for clarity?)
0 commit comments