]> git.proxmox.com Git - cargo.git/commit - tests/testsuite/metadata.rs
Auto merge of #9186 - weihanglo:issue-9054, r=alexcrichton
authorbors <bors@rust-lang.org>
Sat, 1 May 2021 15:35:48 +0000 (15:35 +0000)
committerbors <bors@rust-lang.org>
Sat, 1 May 2021 15:35:48 +0000 (15:35 +0000)
commitdb741ac733f3744c2d7ee593d5a01b18e6158b69
tree2f1597e32220410d33e9340ca2bf35c88402ee25
parent468314fc82f2b0b6b549156085f22b2c7556ed86
parent153146ecc5264f3066caf314b37c8091c0eb7595
Auto merge of #9186 - weihanglo:issue-9054, r=alexcrichton

Respect Cargo.toml `[package.exclude]` even not in a git repo.

May resolves #9054

This bug (or feature?) has been lingering for a while. #7680 fixed the `cargo package` part but `cargo vendor` is still affected by the heuristic rule of ignoring dotfiles. ~~I propose to drop the rule and include dotfiles by default even if the package is not under git-controlled~~. See below.

## Updated: Changes Summary

`cargo vendor` vendors dependencies without git-controlled but `cargo package` often runs under a VCS like git. [These lines](https://github.com/rust-lang/cargo/blob/1ca930b/src/cargo/sources/path.rs#L161-L168) are where they diverges: `fn list_files_walk_except_dot_files_and_dirs` builds [its own ignore instance], which cannot merge with other filter rules from `[package.exclude]`. This causes some patterns to not work as expected, such as re-including file after ignoring dotfiles `[.*, !negated_file]`.

To make re-include (negate) rule works, this patch adds the excluding dotfiles rule directly into the `package.exclude` ignore instance if **_no include option nor git repo exists_**. Other old behaviors should not change in this patch.

[its own ignore instance]: https://github.com/rust-lang/cargo/blob/1ca930b6/src/cargo/sources/path.rs#L364-L366
src/cargo/sources/path.rs