1use std::path::Path;
11use std::process::Command;
12
13pub fn check(root_path: &Path, bad: &mut bool) {
14 let stat_output = Command::new("git")
15 .arg("-C")
16 .arg(root_path)
17 .args(["ls-files", "-z"])
18 .output()
19 .unwrap()
20 .stdout;
21 for filename in stat_output.split(|&b| b == 0) {
22 match str::from_utf8(filename) {
23 Err(_) => tidy_error!(
24 bad,
25 r#"non-UTF8 file names are not supported: "{}""#,
26 String::from_utf8_lossy(filename),
27 ),
28 Ok(name) if name.chars().any(|c| c.is_control()) => tidy_error!(
29 bad,
30 r#"control characters are not supported in file names: "{}""#,
31 String::from_utf8_lossy(filename),
32 ),
33 Ok(name) if name.contains(':') => tidy_error!(
34 bad,
35 r#"":" is not supported in file names because of Windows compatibility: "{name}""#,
36 ),
37 _ => (),
38 }
39 }
40}