[8.0.0] Make git_repository()
ignore GIT_
env vars
#24300
Merged
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.
This ensures that this repository rule cannot be influenced by these environment variables, particularly
GIT_DIR
, keeping the operation limited to the directory specified by therepository_ctx
.In particular, this ensures that calling Bazel (e.g.
bazel test
) from within a Git hook will work reliably. Git hooks setGIT_DIR
(among others), which can cause the repository rule's invocations ofgit
to misbehave. https://git-scm.com/docs/githooksWhen using Git worktrees and calling Bazel from a Git hook, it has been observed that
git_repository()
will not only fail, but will also setcore.bare = true
, breaking the user's clone.Fixes #24199.
Closes #24204.
PiperOrigin-RevId: 695642299
Change-Id: Id81e32194117cd8996408b236a6a88a20b14910b
Commit 89115d9