Skip to main content

config_set_many

Function config_set_many 

Source
pub fn config_set_many(
    cwd: &Path,
    entries: &[(&str, &str)],
) -> Result<(), GitError>
Expand description

Batched variant of config_set: applies every (key, value) entry to the local config in a single read / parse / lock / write cycle.

For each entry the helper enforces single-value semantics:

  • If the key has exactly one existing value and it already equals value, no change is made for that entry.
  • Otherwise, every existing value for the key is removed and a single value is pushed. This cleans up legacy multi-valued state left behind by older versions that used --add semantics here (see #198).

If none of the entries require a change the file is not rewritten, so re-running install on an already-installed repo touches no bytes.

ยงErrors

Returns GitError::ConfigKeyParse for a malformed dotted key, GitError::ConfigInvalidValueName if a value name is rejected by gix-config, GitError::ConfigInvalidSectionName if a section name is rejected, GitError::Discover if the repository cannot be located, GitError::ConfigParse if the existing config cannot be parsed, GitError::ConfigLock if the lock cannot be acquired, or GitError::Io for other file I/O failures.