pub struct Defaults {
pub signature: MagicSignature,
pub search_mode: SearchMode,
pub literal: bool,
}Expand description
Default settings for some fields of a Pattern.
These can be used to represent GIT_*_PATHSPECS environment variables, for example.
Fields§
§signature: MagicSignatureThe default signature.
search_mode: SearchModeThe default search-mode.
Note that even if it’s SearchMode::Literal, the pathspecs will be parsed as usual, but matched verbatim afterwards.
Note that pathspecs can override this the SearchMode::Literal variant with an explicit :(glob) prefix.
literal: boolIf set, the pathspec will not be parsed but used verbatim. Implies SearchMode::Literal for search_mode.
Implementations§
Source§impl Defaults
impl Defaults
Sourcepub fn from_environment(
var: &mut dyn FnMut(&str) -> Option<OsString>,
) -> Result<Self, Error>
pub fn from_environment( var: &mut dyn FnMut(&str) -> Option<OsString>, ) -> Result<Self, Error>
Initialize this instance using information from the environment as
per the official documentation (look for PATHSPECS),
calling var(variable_name) for each variable that should be obtained.
Used environment variables are GIT_GLOB_PATHSPECS, GIT_NOGLOB_PATHSPECS, GIT_LITERAL_PATHSPECS and GIT_ICASE_PATHSPECS.
Note that there are lot of failure modes, and instead of offering lenient parsing, the caller may ignore errors and
use other defaults instead.
§Deviation
Instead of failing if GIT_LITERAL_PATHSPECS is used with glob globals, we ignore these. Also our implementation allows global
icase settings in combination with this setting.