[DNM] Support safe.bareRepository=explicit for .gitconfig #8106
+38
−11
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.
Close #8068
Motivation:
Git has add
safe.bareRepository=explicit
to opt-in mitigations for buried bare repos attack since2.38.0
.Also some Git GUI app(SourceTree) is enforcing the new rule which breaking the building system including SwiftPM here.
See https://github.com/justinsteven/advisories/blob/main/2022_git_buried_bare_repos_and_fsmonitor_various_abuses.md
for detail.
Modifications:
Add
--git-dir
explicitly for bareRepo.Result:
When
safe.bareRepository=explicit
is enabled globally on .gitconfig. SwiftPM resolve dependency successfully.Steps to verify
SPMBareTest.zip
git config set safe.bareRepository explicit --global
.SPMBareTest.zip
and unzip it.cd SPMBareTest && swift package resolve
.Context
Other package manager system tracking the issue:
safe.bareRepository explicit
Git config composer/composer#11855