about summary refs log tree commit diff
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2023-11-24 13:16:10 +0000
committerbors <bors@rust-lang.org>2023-11-24 13:16:10 +0000
commitbeebcdeb6fc778c2d082d545554b08183121b42e (patch)
tree492240598c7b190bae65296b6acb7966298b77ec
parentb06258cde4b0dd131cdbf289349ebf51b3b6388a (diff)
parentcbf6bfc452641040609342326808888fad351df3 (diff)
downloadrust-beebcdeb6fc778c2d082d545554b08183121b42e.tar.gz
rust-beebcdeb6fc778c2d082d545554b08183121b42e.zip
Auto merge of #117782 - majaha:tidy_fix, r=onur-ozkan
Fix tidy tripping up on  untracked files with special characters in their name

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`
-rw-r--r--src/bootstrap/src/core/build_steps/format.rs17
1 files changed, 10 insertions, 7 deletions
diff --git a/src/bootstrap/src/core/build_steps/format.rs b/src/bootstrap/src/core/build_steps/format.rs
index 86f1d925f73..e792d38b7ea 100644
--- a/src/bootstrap/src/core/build_steps/format.rs
+++ b/src/bootstrap/src/core/build_steps/format.rs
@@ -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");