#![deny(missing_docs, rust_2018_idioms)]
#![forbid(unsafe_code)]
use std::path::PathBuf;
use bitflags::bitflags;
use bstr::BString;
pub use gix_attributes as attributes;
pub mod normalize {
use std::path::PathBuf;
#[derive(Debug, thiserror::Error)]
#[allow(missing_docs)]
pub enum Error {
#[error("The path '{}' is not inside of the worktree '{}'", path.display(), worktree_path.display())]
AbsolutePathOutsideOfWorktree { path: PathBuf, worktree_path: PathBuf },
#[error("The path '{}' leaves the repository", path.display())]
OutsideOfWorktree { path: PathBuf },
}
}
mod pattern;
pub mod search;
pub mod parse;
#[derive(Debug, Default, Copy, Clone, Ord, PartialOrd, Eq, PartialEq)]
pub struct Defaults {
pub signature: MagicSignature,
pub search_mode: SearchMode,
pub literal: bool,
}
pub mod defaults;
#[derive(Debug, Clone)]
pub struct Search {
patterns: Vec<gix_glob::search::pattern::Mapping<search::Spec>>,
pub source: Option<PathBuf>,
all_patterns_are_excluded: bool,
common_prefix_len: usize,
}
#[derive(Default, PartialEq, Eq, Debug, Hash, Ord, PartialOrd, Clone)]
pub struct Pattern {
path: BString,
pub signature: MagicSignature,
pub search_mode: SearchMode,
pub attributes: Vec<gix_attributes::Assignment>,
nil: bool,
prefix_len: usize,
}
bitflags! {
#[derive(Default, PartialEq, Eq, Debug, Hash, Ord, PartialOrd, Clone, Copy)]
pub struct MagicSignature: u32 {
const TOP = 1 << 0;
const ICASE = 1 << 1;
const EXCLUDE = 1 << 2;
const MUST_BE_DIR = 1 << 3;
}
}
#[derive(Default, PartialEq, Eq, Debug, Hash, Ord, PartialOrd, Clone, Copy)]
pub enum SearchMode {
#[default]
ShellGlob,
Literal,
PathAwareGlob,
}
pub fn parse(input: &[u8], default: Defaults) -> Result<Pattern, parse::Error> {
Pattern::from_bytes(input, default)
}