Skip to main content

global_attributes_file

Function global_attributes_file 

Source
pub fn global_attributes_file(config: &File) -> Option<PathBuf>
Expand description

The global attributes file, resolved the way git resolves it.

Reading core.attributesFile verbatim is not enough, and the gap is not cosmetic: it is a source in git’s attribute stack, so a line in it can put text back on a path this tool encrypts — and git then converts the ciphertext. Measured on git 2.55, 2 MB, the line living in ~/.config/git/attributes while the same line in the tree is refused: git add exited 0, 27 CR bytes were eaten out of the blob, the commit succeeded and the checkout left no file at all. The refusal in crate::commands::filter and the gate in status both resolve the stack correctly; they simply were not being handed this file, so both reported a healthy repository over a destroyed one.

Git’s rule, measured on 2.55 rather than read from the documentation — the five shapes are a table test in this module:

core.attributesFilewhat git reads
unset$XDG_CONFIG_HOME/git/attributes, else $HOME/.config/git/attributes
~/name, ~user/nameexpanded, exactly as core.excludesFile is
an absolute paththat path
emptynothing — and no XDG fallback either

Returns the path whether or not it exists; a missing file is an empty source to the resolver, which is what git does with one too.