Skip to content

Commit cbf6bfc

Browse files
committed
Fix tidy on untracked files with special character
Previously, the tidy tool would fault if an untracked file had a space or other special characters in its name. If there was an untracked file "foo bar", it would include the quoting in it's path and split on the first space, giving output like this: `skip untracked path "foo during rustfmt invocations`
1 parent 492e57c commit cbf6bfc

File tree

1 file changed

+10
-7
lines changed

1 file changed

+10
-7
lines changed

src/bootstrap/src/core/build_steps/format.rs

+10-7
Original file line numberDiff line numberDiff line change
@@ -142,14 +142,17 @@ pub fn format(build: &Builder<'_>, check: bool, paths: &[PathBuf]) {
142142
};
143143
if in_working_tree {
144144
let untracked_paths_output = output(
145-
build.config.git().arg("status").arg("--porcelain").arg("--untracked-files=normal"),
145+
build
146+
.config
147+
.git()
148+
.arg("status")
149+
.arg("--porcelain")
150+
.arg("-z")
151+
.arg("--untracked-files=normal"),
152+
);
153+
let untracked_paths = untracked_paths_output.split_terminator('\0').filter_map(
154+
|entry| entry.strip_prefix("?? "), // returns None if the prefix doesn't match
146155
);
147-
let untracked_paths = untracked_paths_output
148-
.lines()
149-
.filter(|entry| entry.starts_with("??"))
150-
.map(|entry| {
151-
entry.split(' ').nth(1).expect("every git status entry should list a path")
152-
});
153156
let mut untracked_count = 0;
154157
for untracked_path in untracked_paths {
155158
println!("skip untracked path {untracked_path} during rustfmt invocations");

0 commit comments

Comments
 (0)