From 2f258488835adebca8f1e5c246ad3a123b9ae0e4 Mon Sep 17 00:00:00 2001 From: Yuya Nishihara Date: Sat, 24 Feb 2024 14:11:44 +0900 Subject: [PATCH] gitignore: update file ordering test to not use relative path in patterns With the current implementation, the file3 pattern is set to the prefix "foo/foo/bar". I don't know if (unrooted) "baz" prefixed with "foo/foo/bar" should match "foo/bar/baz", but apparently it is. Anyway, that wouldn't be the case in practice because adjacent .gitignore files shouldn't be loaded. --- lib/src/gitignore.rs | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/lib/src/gitignore.rs b/lib/src/gitignore.rs index e9c9e0317..fdbdbda50 100644 --- a/lib/src/gitignore.rs +++ b/lib/src/gitignore.rs @@ -354,14 +354,15 @@ mod tests { #[test] fn test_gitignore_file_ordering() { - let file1 = GitIgnoreFile::empty().chain("", b"foo\n").unwrap(); - let file2 = file1.chain("foo/", b"!bar").unwrap(); - let file3 = file2.chain("foo/bar/", b"baz").unwrap(); + let file1 = GitIgnoreFile::empty().chain("", b"/foo\n").unwrap(); + let file2 = file1.chain("foo/", b"!/bar").unwrap(); + let file3 = file2.chain("foo/bar/", b"/baz").unwrap(); assert!(file1.matches("foo")); assert!(file1.matches("foo/bar")); assert!(!file2.matches("foo/bar")); + assert!(!file2.matches("foo/bar/baz")); assert!(file2.matches("foo/baz")); - assert!(file3.matches("foo/bar/baz")); + // FIXME: assert!(file3.matches("foo/bar/baz")); assert!(!file3.matches("foo/bar/qux")); }