Skip to main content

normalize_config_key

Function normalize_config_key 

Source
pub fn normalize_config_key(key: &str) -> String
Expand description

Canonicalize a config key’s case the way git does: the section and variable names are case-insensitive (lowercased), but the subsection — the middle segment of a <section>.<subsection>.<var> key, e.g. the <name> in remote.<name>.url or the <branch> in branch.<branch>.remote — is case-sensitive and preserved verbatim.

Two-segment keys (user.name, core.autocrlf, …) have no subsection, so both halves are lowercased. The split mirrors apply_section_kv’s splitn(3, '.'), so the canonical form round-trips through it.