From c23a457e72abe608715ac76f076f47dc42af07a5 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Thu, 30 May 2024 20:31:44 +0200 Subject: Merging upstream version 1.74.1+dfsg1. Signed-off-by: Daniel Baumann --- vendor/gix-glob/tests/fixtures/make_baseline.sh | 0 vendor/gix-glob/tests/parse/mod.rs | 10 ++++++++ vendor/gix-glob/tests/pattern/matching.rs | 32 +++++++++++++++++++++---- vendor/gix-glob/tests/search/pattern.rs | 22 +++++++++++------ vendor/gix-glob/tests/wildmatch/mod.rs | 8 ++++++- 5 files changed, 60 insertions(+), 12 deletions(-) mode change 100644 => 100755 vendor/gix-glob/tests/fixtures/make_baseline.sh (limited to 'vendor/gix-glob/tests') diff --git a/vendor/gix-glob/tests/fixtures/make_baseline.sh b/vendor/gix-glob/tests/fixtures/make_baseline.sh old mode 100644 new mode 100755 diff --git a/vendor/gix-glob/tests/parse/mod.rs b/vendor/gix-glob/tests/parse/mod.rs index fc668d1e6..8377a44f2 100644 --- a/vendor/gix-glob/tests/parse/mod.rs +++ b/vendor/gix-glob/tests/parse/mod.rs @@ -66,11 +66,21 @@ fn leading_exclamation_mark_negates_pattern() { gix_glob::parse(b"!hello"), pat("hello", Mode::NEGATIVE | Mode::NO_SUB_DIR, None) ); + assert_eq!( + gix_glob::Pattern::from_bytes_without_negation(b"!hello"), + pat("!hello", Mode::NO_SUB_DIR, None), + "negation can be disabled entirely" + ); } #[test] fn leading_exclamation_marks_can_be_escaped_with_backslash() { assert_eq!(gix_glob::parse(br"\!hello"), pat("!hello", Mode::NO_SUB_DIR, None)); + assert_eq!( + gix_glob::Pattern::from_bytes_without_negation(br"\!hello"), + pat("\\!hello", Mode::NO_SUB_DIR, Some(0)), + "negation can be disabled entirely, leaving escapes in place" + ); } #[test] diff --git a/vendor/gix-glob/tests/pattern/matching.rs b/vendor/gix-glob/tests/pattern/matching.rs index 8a5208d9a..df29e02dc 100644 --- a/vendor/gix-glob/tests/pattern/matching.rs +++ b/vendor/gix-glob/tests/pattern/matching.rs @@ -68,7 +68,13 @@ fn compare_baseline_with_ours() { ); match std::panic::catch_unwind(|| { let pattern = pat(pattern); - pattern.matches_repo_relative_path(value, basename_start_pos(value), None, *case) + pattern.matches_repo_relative_path( + value, + basename_start_pos(value), + None, + *case, + gix_glob::wildmatch::Mode::NO_MATCH_SLASH_LITERAL, + ) }) { Ok(actual_match) => { if actual_match == is_match { @@ -105,11 +111,23 @@ fn non_dirs_for_must_be_dir_patterns_are_ignored() { ); let path = "hello"; assert!( - !pattern.matches_repo_relative_path(path, None, false.into() /* is-dir */, Case::Sensitive), + !pattern.matches_repo_relative_path( + path.into(), + None, + false.into(), /* is-dir */ + Case::Sensitive, + gix_glob::wildmatch::Mode::NO_MATCH_SLASH_LITERAL + ), "non-dirs never match a dir pattern" ); assert!( - pattern.matches_repo_relative_path(path, None, true.into() /* is-dir */, Case::Sensitive), + pattern.matches_repo_relative_path( + path.into(), + None, + true.into(), /* is-dir */ + Case::Sensitive, + gix_glob::wildmatch::Mode::NO_MATCH_SLASH_LITERAL + ), "dirs can match a dir pattern with the normal rules" ); } @@ -317,7 +335,13 @@ fn match_file<'a>(pattern: &gix_glob::Pattern, path: impl Into<&'a BStr>, case: fn match_path<'a>(pattern: &gix_glob::Pattern, path: impl Into<&'a BStr>, is_dir: Option, case: Case) -> bool { let path = path.into(); - pattern.matches_repo_relative_path(path, basename_start_pos(path), is_dir, case) + pattern.matches_repo_relative_path( + path, + basename_start_pos(path), + is_dir, + case, + gix_glob::wildmatch::Mode::NO_MATCH_SLASH_LITERAL, + ) } fn basename_start_pos(value: &BStr) -> Option { diff --git a/vendor/gix-glob/tests/search/pattern.rs b/vendor/gix-glob/tests/search/pattern.rs index 0313b5564..6b62ee3d2 100644 --- a/vendor/gix-glob/tests/search/pattern.rs +++ b/vendor/gix-glob/tests/search/pattern.rs @@ -18,16 +18,12 @@ mod list { fn bytes_to_patterns(_bytes: &[u8], _source: &Path) -> Vec> { vec![] } - - fn may_use_glob_pattern(_pattern: &gix_glob::Pattern) -> bool { - unreachable!("won't be called") - } } #[test] fn from_bytes_base() { { - let list = List::::from_bytes(&[], "a/b/source", None); + let list = List::::from_bytes(&[], "a/b/source".into(), None); assert_eq!(list.base, None, "no root always means no-base, i.e. globals lists"); assert_eq!( list.source.as_deref(), @@ -52,7 +48,7 @@ mod list { } { - let list = List::::from_bytes(&[], "a/b/source", Some(Path::new("c/"))); + let list = List::::from_bytes(&[], "a/b/source".into(), Some(Path::new("c/"))); assert_eq!( list.base, None, "if root doesn't contain source, it silently skips it as base" @@ -67,7 +63,7 @@ mod list { #[test] fn strip_base_handle_recompute_basename_pos() { - let list = List::::from_bytes(&[], "a/b/source", Some(Path::new(""))); + let list = List::::from_bytes(&[], "a/b/source".into(), Some(Path::new(""))); assert_eq!( list.base.as_ref().expect("set"), "a/b/", @@ -87,4 +83,16 @@ mod list { "otherwise the basename is recomputed, case folding is effective" ); } + + #[test] + fn from_file() { + let mut buf = Vec::new(); + for path in [ + Path::new(".").join("non-existing-dir").join("pattern-file"), + Path::new("file").to_owned(), + ] { + let list = List::::from_file(path, None, false, &mut buf).expect("no io error"); + assert!(list.is_none(), "the file does not exist"); + } + } } diff --git a/vendor/gix-glob/tests/wildmatch/mod.rs b/vendor/gix-glob/tests/wildmatch/mod.rs index 11fbd664b..b4b198ec7 100644 --- a/vendor/gix-glob/tests/wildmatch/mod.rs +++ b/vendor/gix-glob/tests/wildmatch/mod.rs @@ -367,7 +367,13 @@ impl Display for MatchResult { } fn match_file_path(pattern: &gix_glob::Pattern, path: &str, case: Case) -> bool { - pattern.matches_repo_relative_path(path, basename_of(path), false.into() /* is_dir */, case) + pattern.matches_repo_relative_path( + path.into(), + basename_of(path), + false.into(), /* is_dir */ + case, + gix_glob::wildmatch::Mode::NO_MATCH_SLASH_LITERAL, + ) } fn basename_of(path: &str) -> Option { path.rfind('/').map(|pos| pos + 1) -- cgit v1.2.3