Skip to content

Commit

Permalink
cargo-new should not add ignore rule on Cargo.lock inside subdirs
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
weihanglo committed Feb 11, 2022
1 parent 227f4c4 commit 3e71240
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/cargo/ops/cargo_new.rs
Original file line number Diff line number Diff line change
Expand Up @@ -716,7 +716,7 @@ fn mk(config: &Config, opts: &MkOptions<'_>) -> CargoResult<()> {
let mut ignore = IgnoreList::new();
ignore.push("/target", "^target/", "target");
if !opts.bin {
ignore.push("Cargo.lock", "glob:Cargo.lock", "Cargo.lock,*/Cargo.lock");
ignore.push("/Cargo.lock", "^Cargo.lock$", "Cargo.lock");
}

let vcs = opts.version_control.unwrap_or_else(|| {
Expand Down

0 comments on commit 3e71240

Please sign in to comment.