Updated `matches()` function, which now takes the `GetFileMode` trait and returns a
Result. `GetFileMode` is a function that should return the `file_mode`. `matches()`
will go through the patterns and match by path only until it finds a pattern which
does not have `MatchFlag::ANY_FILE_TYPE`, in case it will call the
`get_file_mode`, which will return a `file_mode`. This will ensure that the
`get()` (which in our case executes `stat()`) will only be run once(at most),
every pattern will only be processed once and that the order of the patterns
will be respected. `GetFileMode` is also implemented for `Option<u32>` (so that
we can simply pass options of the `file_mode`) and `u32` (returning
`std::convert::Infallible`, so that we can pass a u32 mode directly).
Signed-off-by: Gabriel Goller <g.goller@proxmox.com>
Git actually skipped the next slash in the pattern. Since we
don't have a Component::Slash currently we'll just add a
flag to `do_match` instead.
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
This is a convenience helper to parse an entry with possible
inversion via a leading exclamation mark and interpreting
trailing slashes to mean `MatchFlag::MATCH_DIRECTORY` and
create a `Pattern` from the string with those characters
stripped off.
This also changes the way `MatchFlag`s are passed to a
builder pattern for convenience.
Also: impl std::ops::Not for MatchType.
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>