-
-
Notifications
You must be signed in to change notification settings - Fork 346
Unset other env vars related to GIT_DIR
for fixtures
#1581
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
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?)
d7ae44f
to
9d4dd12
Compare
This has the `git config -l ...` invocation `gix-path` uses to find a configuration file to treat as associated with the `git` installation remove more environment variables related to `GIT_DIR` besides `GIT_COMMON_DIR`. The new removals probably don't make a difference, because they are only used if `GIT_DIR` is either unset or set to a location that actually has a Git repository (that `git` is willing to use). Unsetting these others is thus more to make clear that they have no effect than to prevent them from having an effect, though various versions and downstream releases of `git` exist, so it's narrowly possible that this is also avoiding a problem somewhere, I guess. This change is motivated by my realization in 9d4dd12 (GitoxideLabs#1581) that it could be slightly beneficial. Other differences between the variables unset here and in `gix-testtools` remain due to the differences described in that commit message.
This has the `git config -l ...` invocation `gix-path` uses to find a configuration file to treat as associated with the `git` installation remove more environment variables related to `GIT_DIR` besides `GIT_COMMON_DIR`. The new removals probably don't make a difference, because they are only used if `GIT_DIR` is either unset or set to a location that actually has a Git repository (that `git` is willing to use). Unsetting these others is thus more to make clear that they have no effect than to prevent them from having an effect, though various versions and downstream releases of `git` exist, so it's narrowly possible that this is also avoiding a problem somewhere, I guess. This change is motivated by my realization in 9d4dd12 (GitoxideLabs#1581) that it could be slightly beneficial. Other differences between the variables unset here and in `gix-testtools` remain due to the differences described in that commit message.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is great, thanks a lot!
On another note, it's interesting to wonder if, or to what extend, gitoxide
should respect such environment variables. If they are undocumented, the answer is not at all, but otherwise they would need to be given some consideration.
Facilities exist to control which environment variables gitoxide
uses, and methods exist to respect environment variables specifically, and maybe some of that can be extended should there be any need.
I've noticed this PR has been open for a while since being approved. Was auto-merge intended to have picked it up? |
Strange, I completely missed this one (and your message) :/. |
This could happen if you accidentally unsubscribed from notifications on this PR specifically, which I have found is easy to do on the Android app. But that wouldn't have an effect on auto-merge. All pushes here (including force pushes) substantially preceded the approving review, so I don't know what would cause that. But it may be that I am misunderstanding the circumstances required for auto-merge to take effect. |
This removes other environment variables that have an effect conceptually related to
GIT_DIR
even whenGIT_DIR
is not set. Most of them change wheregit
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.Significant further details are in the commit message, in case they are of interest now or in the future. I did not add tests because the likelihood that there is a mistake here that new tests would find is low, and because tests that go beyond effectively repeating the changes to the code under test would effectively run into the concerns described in #1577 or #1578.