Skip to content

Commit

Permalink
Fix tidy on untracked files with special character
Browse files Browse the repository at this point in the history
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`
  • Loading branch information
majaha committed Nov 23, 2023
1 parent 492e57c commit cbf6bfc
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions src/bootstrap/src/core/build_steps/format.rs
Original file line number Diff line number Diff line change
Expand Up @@ -142,14 +142,17 @@ pub fn format(build: &Builder<'_>, check: bool, paths: &[PathBuf]) {
};
if in_working_tree {
let untracked_paths_output = output(
build.config.git().arg("status").arg("--porcelain").arg("--untracked-files=normal"),
build
.config
.git()
.arg("status")
.arg("--porcelain")
.arg("-z")
.arg("--untracked-files=normal"),
);
let untracked_paths = untracked_paths_output.split_terminator('\0').filter_map(
|entry| entry.strip_prefix("?? "), // returns None if the prefix doesn't match
);
let untracked_paths = untracked_paths_output
.lines()
.filter(|entry| entry.starts_with("??"))
.map(|entry| {
entry.split(' ').nth(1).expect("every git status entry should list a path")
});
let mut untracked_count = 0;
for untracked_path in untracked_paths {
println!("skip untracked path {untracked_path} during rustfmt invocations");
Expand Down

0 comments on commit cbf6bfc

Please sign in to comment.