@ 261027.5

261023.5 · 7155f6408d370e699795dc75e954635abfaf08a6

ignore: treat dotfiles ending in a dot as hidden (#3564)

`file_name()` returned `None` for any path ending in `.` on Unix, which was meant to cover the `.` and `..` components but also matched real names like `.foo.`. The hidden check then found no file name and treated those files as visible. Only a final component that is exactly `.` or `..` has no file name now.

PR #3564

reading declarations

Changes to crates/ignore/src/walk.rs. All files

crates/ignore/src/walk.rs

@@ -2397,6 +2397,41 @@ mod tests {         );     } +    // Names that start with a `.` are hidden, even when they also end in a+    // `.`. A trailing `.` must not be confused with a `.` or `..` component.+    //+    // Windows doesn't allow file names that end in a `.`.+    #[cfg(unix)]+    #[test]+    fn hidden_with_trailing_dot() {+        let td = tmpdir();+        wfile(td.path().join("visible."), "");+        wfile(td.path().join(".hidden"), "");+        wfile(td.path().join(".hidden."), "");+        wfile(td.path().join(".hidden.."), "");+        wfile(td.path().join("..."), "");+        mkdirp(td.path().join(".dir."));+        wfile(td.path().join(".dir./inner"), "");++        assert_paths(td.path(), &WalkBuilder::new(td.path()), &["visible."]);++        let mut builder = WalkBuilder::new(td.path());+        builder.hidden(false);+        assert_paths(+            td.path(),+            &builder,+            &[+                ".dir.",+                ".dir./inner",+                ".hidden",+                ".hidden.",+                ".hidden..",+                "...",+                "visible.",+            ],+        );+    }+     #[test]     fn gitignore_parent() {         let td = tmpdir();