-
Notifications
You must be signed in to change notification settings - Fork 2.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Cargo init
creates duplicates in .gitignore
#6377
Comments
I'd happily start working on that one as a first contribution. Seems to be quite straight forward. |
Great! Go for it. |
existing ignore files are now checked for duplicates. If the file already contains an entry it is commented out in the section added by cargo. fixes rust-lang#6377
…iles, r=dwijnand avoid duplicates in ignore files Hi, here is my first PR for cargo. It's my take on #6377 with some minor refactoring included, mainly to avoid keeping the two different types of ignore file entries (gitignore and hg) in sync.) Basically, the contents of a ignore file are now read if the file exists and filtered out. To filter out I would propose to just comment the entries that cargo would add out, in that way it is nice to see which duplicates were found and more important _what cargo usually adds_. In that way, a user can modify his ignore file and be sure that he can keep everything that cargo would add. A new ignore file will look like this: ``` /target **/*.rs.bk Cargo.lock", ``` An existing ignore file will be modified like this: ``` /target /some/other/path #Added by cargo # #already existing elements are commented out #/target **/*.rs.bk Cargo.lock ``` Fixes #6377
I'd like to reopen this issue; I'm still seeing this behavior on git when I run |
@Lucretiel That's because this fix hasn't made it way into stable Rust yet. It's in nightly and beta (try |
Oh, sorry, I didn't see the dates that this was so recent. Thank you! |
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
The new
.gitignore
will now containPossible 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 iscargo/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)
The text was updated successfully, but these errors were encountered: