Skip to main content

render_lines

Function render_lines 

Source
pub fn render_lines(config: &Config, rendering: Rendering) -> Vec<String>
Expand description

Renders the per-pattern lines for config.

An encrypted path gets -text diff=git-xcrypt; a path a negation took back out gets !text !diff, which restores git’s defaults for it. Leaving the negation unrendered would keep -text on a file that is stored in the clear, so git would stop managing its line endings.

Two resolution rules have to be reconciled, and each one dictates part of the layout:

  • Selection is last match, in both. git takes the last matching line and so does Config::decide, so the two kinds of line are emitted strictly in the order of .git-xcrypt. Grouping them by kind — negations last, as an earlier version did — silently inverted !secrets/README.md written above secrets/, leaving an encrypted file without -text.
  • binary is sticky in Config::decide and positional in git. A declaration anywhere suppresses the diff driver for the path, so those patterns get a trailing -diff line: last, and naming only diff, so the -text established above it survives.

Finally, the files needed to bootstrap — see crate::rules::declaration::is_never_encrypted — get their defaults back if any pattern reached them, because they are stored in the clear whatever the patterns say.

Within each group the order is the input’s, so the section is a pure function of the configuration and two runs produce the same file.