ok/jj
1
0
Fork 0
forked from mirrors/jj

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.
This commit is contained in:
Yuya Nishihara 2024-02-24 14:11:44 +09:00
parent c5cc6bf501
commit 2f25848883

View file

@ -354,14 +354,15 @@ mod tests {
#[test] #[test]
fn test_gitignore_file_ordering() { fn test_gitignore_file_ordering() {
let file1 = GitIgnoreFile::empty().chain("", b"foo\n").unwrap(); let file1 = GitIgnoreFile::empty().chain("", b"/foo\n").unwrap();
let file2 = file1.chain("foo/", b"!bar").unwrap(); let file2 = file1.chain("foo/", b"!/bar").unwrap();
let file3 = file2.chain("foo/bar/", b"baz").unwrap(); let file3 = file2.chain("foo/bar/", b"/baz").unwrap();
assert!(file1.matches("foo")); assert!(file1.matches("foo"));
assert!(file1.matches("foo/bar")); assert!(file1.matches("foo/bar"));
assert!(!file2.matches("foo/bar")); assert!(!file2.matches("foo/bar"));
assert!(!file2.matches("foo/bar/baz"));
assert!(file2.matches("foo/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")); assert!(!file3.matches("foo/bar/qux"));
} }