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: boolThe 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
impl Config
Sourcepub fn parse(text: &str) -> Result<Self>
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.
Sourcepub fn load(path: &Path) -> Result<Self>
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.
Sourcepub fn patterns(&self) -> Vec<PatternView<'_>>
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.
Sourcepub fn decide(&self, path: &[u8]) -> Decision
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.
Sourcepub fn negated(&self, path: &[u8]) -> bool
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.
Sourcepub fn decide_ignoring_exclusions(&self, path: &[u8]) -> Decision
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.