Description
Doing cargo init
in an existing git repository will either create a new .gitignore
or append to an existing one. However if we already have a .gitignore
file with both /target
and **/*.rs.bk
ignored, cargo init
will still add these to the existing file.
Steps
$ mkdir foo && cd foo
$ git init
$ echo "/target\n**/*.rs.bk" > .gitignore
$ cargo init
The new .gitignore
will now contain
/target
**/*.rs.bk
/target
**/*.rs.bk
Possible Solution(s)
Before creating or adding to the existing .gitignore
, we could perhaps check the contents and only add what is missing. Looks like the code handling this is
cargo/src/cargo/ops/cargo_new.rs
Lines 460 to 465 in 485670b
cargo/src/cargo/ops/cargo_new.rs
Lines 471 to 476 in 485670b
cargo/src/cargo/ops/cargo_new.rs
Lines 482 to 487 in 485670b
Version: cargo 1.31.0-nightly (2d0863f 2018-10-20)