Skip to content

Commit

Permalink
Stop ignoring .rs.bk files; rustfmt hasn't generated them in years
Browse files Browse the repository at this point in the history
cargo currently generates a .gitignore file that ignores .rs.bk files,
historically because rustfmt would sometimes generate such files.
However, rustfmt and cargo fmt don't generate backup files by default
(only when requested), and even when requested, they generate .bk files,
not .rs.bk files (as of rustfmt commit
fad903fd14ad0df045dc574cac0717312860c380 in 2017). And nobody seems to
have noticed or complained since then, likely because rustfmt doesn't
generate backup files by default.

rustfmt also plans to deprecate the --backup option entirely, in rustfmt
2.0, and instead always rely on version control to track changes.

In addition, these types of ignores, just like ignores of editor backup
files, don't belong in .gitignore; they belong in people's personal
ignore files, such as ~/.config/git/ignore.  See
https://julien.danjou.info/properly-managing-your-gitignore/ for further
explanation of that.

Given all three of those factors, drop the code to add **/*.rs.bk to
.gitignore, and update tests accordingly.
  • Loading branch information
joshtriplett committed Dec 2, 2019
1 parent b35bb1b commit 997a6d5
Show file tree
Hide file tree
Showing 3 changed files with 1 addition and 4 deletions.
1 change: 0 additions & 1 deletion src/cargo/ops/cargo_new.rs
Original file line number Diff line number Diff line change
Expand Up @@ -581,7 +581,6 @@ fn mk(config: &Config, opts: &MkOptions<'_>) -> CargoResult<()> {
// both `ignore` and `hgignore` are in sync.
let mut ignore = IgnoreList::new();
ignore.push("/target", "^target/");
ignore.push("**/*.rs.bk", "glob:*.rs.bk");
if !opts.bin {
ignore.push("Cargo.lock", "glob:Cargo.lock");
}
Expand Down
2 changes: 0 additions & 2 deletions tests/testsuite/init.rs
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,6 @@ fn simple_git_ignore_exists() {
#already existing elements were commented out\n\
\n\
#/target\n\
**/*.rs.bk\n\
Cargo.lock\n",
);

Expand Down Expand Up @@ -123,7 +122,6 @@ fn git_ignore_exists_no_conflicting_entries() {
#Added by cargo\n\
\n\
/target\n\
**/*.rs.bk\n\
Cargo.lock\n",
);
}
Expand Down
2 changes: 1 addition & 1 deletion tests/testsuite/new.rs
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ fn simple_git() {
.unwrap()
.read_to_string(&mut contents)
.unwrap();
assert_eq!(contents, "/target\n**/*.rs.bk\nCargo.lock\n",);
assert_eq!(contents, "/target\nCargo.lock\n",);

cargo_process("build").cwd(&paths::root().join("foo")).run();
}
Expand Down

0 comments on commit 997a6d5

Please sign in to comment.