Skip to main content

Config

Struct Config 

Source
pub struct Config {
    pub pointless_eol: Vec<String>,
    pub missing: bool,
    /* private fields */
}
Expand description

A parsed .git-xcrypt.

Fields§

§pointless_eol: Vec<String>

Lines that carry eol= on a path that is never converted.

Pointless rather than dangerous — git itself lets -text win over eol — so it is a warning the caller prints once, not an error.

§missing: bool

The file was not on disk at all.

Kept rather than turned into an error at load time because the two filter directions need opposite answers: check-in must refuse, since “no declaration” is indistinguishable from “the declaration has not been checked out yet” and guessing wrong writes a secret in the clear; check-out must carry on, because a file’s own header already says everything smudge needs and git gives no order in which it writes the working tree.

Implementations§

Source§

impl Config

Source

pub fn parse(text: &str) -> Result<Self>

Parses the contents of a .git-xcrypt file.

§Errors

Error::Config for an unknown attribute, an attribute on a negation, or a pattern gix-glob refuses. Fail closed: a file we do not fully understand must stop the operation, not be half-applied.

Source

pub fn load(path: &Path) -> Result<Self>

Reads and parses the file at path, recording an absent file as such.

An unreadable file is an error here and an absent one is flagged, because neither may end up meaning “encrypt nothing” on the check-in path.

§Errors

Error::Io when the file exists but cannot be read, Error::Config when it cannot be understood.

The failure names the file, which is not decoration on this path. It is reached from the filter, so every git operation in the repository stops until it is fixed, and git’s own accompanying fatal: line names whatever file it was cleaning when this one could not be read — measured on git 2.55, that was an innocent secrets/db.env. A bare stream did not contain valid UTF-8 beside it left nothing pointing at the real culprit.

Source

pub fn patterns(&self) -> Vec<PatternView<'_>>

Every pattern in file order, with the ! stripped from the negations.

File order is what the caller needs rather than a convenience: selection is resolved by last match, so a rendered .gitattributes only agrees with Config::decide if it keeps the lines in the order they were written. Splitting them into “selecting” and “negated” lists loses exactly the information that decides the answer.

Source

pub fn decide(&self, path: &[u8]) -> Decision

What this configuration says about path, given relative to the root.

The path is bytes, not text: on Unix a path is an arbitrary byte string, and lossy decoding would match a file under a name it does not have — which in the pass-through direction means storing a secret in the clear.

Source

pub fn negated(&self, path: &[u8]) -> bool

Whether a negation is what keeps path out of the encrypted set.

status reports such paths in a section of their own rather than leaving them out. A !secrets/README.md under a secrets/ line is a deliberate hole in the declaration, and the founding document is explicit that a deliberate hole must never be an invisible one — silence here reads as “everything under secrets/ is covered”, which is the belief that lets a secret be filed under the exception by mistake.

False for a path no pattern reaches at all: that is not an exception, it is simply a file nobody declared.

Source

pub fn decide_ignoring_exclusions(&self, path: &[u8]) -> Decision

What the patterns alone say, with the bootstrap exclusions set aside.

Only one caller wants this: rendering .gitattributes has to know whether a pattern reaches a file that is_never_encrypted then rescues, because such a file needs a line putting git’s defaults back. Everything else must go through Config::decide.

Trait Implementations§

Source§

impl Debug for Config

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for Config

Source§

fn default() -> Config

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.