Skip to content

Commit 3e71240

Browse files
committed
cargo-new should not add ignore rule on Cargo.lock inside subdirs
Have traced down the issue. It feel like the original intent is to ignore `Cargo.lock` and `target` at project root but not subdirectories. 1. The original implementation did ignore root `/Cargo.lock`. #321 2. Someday one wanted to support both gitignore and hgingore's syntax and removed the leading slash. #1247 3. Later, one found that we should not ignore `target` other than under root directory and added `/target` back. #4099 4. It turns out that the syntax is not compatible between gitignore and hgignore. Therefore, one started to use hgignore special syntax to handle `Cargo.lock`. #4342 This commit rollbacks to what original implementation tries to do.
1 parent 227f4c4 commit 3e71240

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/cargo/ops/cargo_new.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -716,7 +716,7 @@ fn mk(config: &Config, opts: &MkOptions<'_>) -> CargoResult<()> {
716716
let mut ignore = IgnoreList::new();
717717
ignore.push("/target", "^target/", "target");
718718
if !opts.bin {
719-
ignore.push("Cargo.lock", "glob:Cargo.lock", "Cargo.lock,*/Cargo.lock");
719+
ignore.push("/Cargo.lock", "^Cargo.lock$", "Cargo.lock");
720720
}
721721

722722
let vcs = opts.version_control.unwrap_or_else(|| {

0 commit comments

Comments
 (0)