Skip to content

Commit 997a6d5

Browse files
committed
Stop ignoring .rs.bk files; rustfmt hasn't generated them in years
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.
1 parent b35bb1b commit 997a6d5

File tree

3 files changed

+1
-4
lines changed

3 files changed

+1
-4
lines changed

Diff for: src/cargo/ops/cargo_new.rs

-1
Original file line numberDiff line numberDiff line change
@@ -581,7 +581,6 @@ fn mk(config: &Config, opts: &MkOptions<'_>) -> CargoResult<()> {
581581
// both `ignore` and `hgignore` are in sync.
582582
let mut ignore = IgnoreList::new();
583583
ignore.push("/target", "^target/");
584-
ignore.push("**/*.rs.bk", "glob:*.rs.bk");
585584
if !opts.bin {
586585
ignore.push("Cargo.lock", "glob:Cargo.lock");
587586
}

Diff for: tests/testsuite/init.rs

-2
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,6 @@ fn simple_git_ignore_exists() {
9494
#already existing elements were commented out\n\
9595
\n\
9696
#/target\n\
97-
**/*.rs.bk\n\
9897
Cargo.lock\n",
9998
);
10099

@@ -123,7 +122,6 @@ fn git_ignore_exists_no_conflicting_entries() {
123122
#Added by cargo\n\
124123
\n\
125124
/target\n\
126-
**/*.rs.bk\n\
127125
Cargo.lock\n",
128126
);
129127
}

Diff for: tests/testsuite/new.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ fn simple_git() {
9191
.unwrap()
9292
.read_to_string(&mut contents)
9393
.unwrap();
94-
assert_eq!(contents, "/target\n**/*.rs.bk\nCargo.lock\n",);
94+
assert_eq!(contents, "/target\nCargo.lock\n",);
9595

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

0 commit comments

Comments
 (0)