Repository navigation
[9.4.0] Materialize stripped Git repository contents (#30321) - #33054
Merged
Merged
Conversation
Similar to `http_archive`'s `add_prefix` attribute, this allows git repos to be cloned into a given subdirectory. Fixes bazelbuild#25453 See bazelbuild#25453 . This also further aligns the attributes of `http_archive` with `git_repository` > 1. Has this been discussed in a design doc or issue? (Please link it) See bazelbuild#25453 > 2. Is the change backward compatible? Yes - an attribute is added. It is optional to use. > 3. If it's a breaking change, what is the migration plan? N/A - [X] I have added tests for the new use cases (if any). - [X] I have updated the documentation (if applicable). RELNOTES[NEW]: Add `add_prefix` attribute to `git_repository` to allow cloning repositories into a given subdirectory prefix Closes bazelbuild#29453. PiperOrigin-RevId: 910704876 Change-Id: I3a916322254c5e6c91d82f000d084c6fc4fc8331
git_repository keeps a complete checkout under .tmp_git_root and symlinks the selected strip_prefix entries into the repository root. Recursive package discovery can then see discarded sibling packages, and traversal or an escaping directory symlink can expose data outside the checkout. Complete Git operations before stripping, reject paths that escape the checkout or resolve into Git metadata, and move only the selected subtree into place. Remove discarded entries and .git, preserve add_prefix and patch behavior, and cover recursive queries, collisions, and escape cases. Fixes bazelbuild#26628. — Description updated by Codex, on Tamir’s behalf. Closes bazelbuild#30321 COPYBARA_INTEGRATE_REVIEW=bazelbuild#30321 from tamird:tamird/fix-git-strip-prefix e4df189 PiperOrigin-RevId: 978535521 Change-Id: I6937876c24f417901bcce9f42a0600fe391b0651
Contributor
Author
|
Replaces #32981. As discussed, this first cherry-picks #29453 (
Verified locally: |
git_repository checks add_prefix containment with a raw string prefix. A normalized path can therefore select a sibling whose name shares the checkout-root prefix, and the worker deletes that sibling before fetching. Require a path-component boundary (or the root itself) and cover the destructive sibling case with a sentinel regression. Follow-up to bazelbuild#29453. Closes bazelbuild#30309. PiperOrigin-RevId: 969773896 Change-Id: I7e9fbd29625c4c8c3ec3e056c13745cdfefe929c
meteorcloudy
approved these changes
Dec 2, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
git_repository keeps a complete checkout under .tmp_git_root and
symlinks the selected strip_prefix entries into the repository root.
Recursive package discovery can then see discarded sibling packages,
and traversal or an escaping directory symlink can expose data outside
the checkout.
Complete Git operations before stripping, reject paths that escape the
checkout or resolve into Git metadata, and move only the selected
subtree into place. Remove discarded entries and .git, preserve
add_prefix and patch behavior, and cover recursive queries, collisions,
and escape cases.
Fixes #26628.
— Description updated by Codex, on Tamir’s behalf.