mirror of
https://github.com/rust-lang/cargo.git
synced 2025-12-27 15:47:15 +00:00
### What does this PR try to resolve? Fixes #16148 Fixes #13607 Right now cargo vendor only filters .gitattributes, .gitignore, and .git at the top level of each package. If these files exist in subdirectories, they don't get filtered. This causes problems when the vendored code gets checked into a git repo - git processes those files and modifies them, which breaks checksums. I ran into this when trying to vendor libssh2-sys. The .gitattributes file in libgit2/src/util/ was getting its line endings changed by git, causing checksum failures. ### How should we test and review this PR? This follows the atomic commit pattern: - First commit adds a test showing the current buggy behavior (test passes) - Second commit implements the fix and updates test assertions (test still passes) The fix uses components() to recursively check for .git directories (since they can appear at any path level like deep/nested/.git/config), while using file_name() for .gitattributes and .gitignore files. ### Additional context This should also help with #13607 since it filters .gitignore and .git recursively too. If people actually need git functionality in their vendored deps, they can add rules to their own .gitattributes at the root level.