Struct git2::Config [] [src]

pub struct Config { /* fields omitted */ }

A structure representing a git configuration key/value store

Methods

impl Config
[src]

[src]

Allocate a new configuration object

This object is empty, so you have to add a file to it before you can do anything with it.

[src]

Create a new config instance containing a single on-disk file

[src]

Open the global, XDG and system configuration files

Utility wrapper that finds the global, XDG and system configuration files and opens them into a single prioritized config object that can be used when accessing default config data outside a repository.

[src]

Locate the path to the global configuration file

The user or global configuration file is usually located in $HOME/.gitconfig.

This method will try to guess the full path to that file, if the file exists. The returned path may be used on any method call to load the global configuration file.

This method will not guess the path to the xdg compatible config file (.config/git/config).

[src]

Locate the path to the system configuration file

If /etc/gitconfig doesn't exist, it will look for %PROGRAMFILES%

[src]

Locate the path to the global xdg compatible configuration file

The xdg compatible configuration file is usually located in $HOME/.config/git/config.

[src]

Add an on-disk config file instance to an existing config

The on-disk file pointed at by path will be opened and parsed; it's expected to be a native Git config file following the default Git config syntax (see man git-config).

Further queries on this config object will access each of the config file instances in order (instances with a higher priority level will be accessed first).

[src]

Delete a config variable from the config file with the highest level (usually the local one).

[src]

Get the value of a boolean config variable.

All config files will be looked into, in the order of their defined level. A higher level means a higher priority. The first occurrence of the variable will be returned here.

[src]

Get the value of an integer config variable.

All config files will be looked into, in the order of their defined level. A higher level means a higher priority. The first occurrence of the variable will be returned here.

[src]

Get the value of an integer config variable.

All config files will be looked into, in the order of their defined level. A higher level means a higher priority. The first occurrence of the variable will be returned here.

[src]

Get the value of a string config variable.

This is the same as get_bytes except that it may return Err if the bytes are not valid utf-8.

[src]

Get the value of a string config variable as a byte slice.

This method will return an error if this Config is not a snapshot.

[src]

Get the value of a string config variable as an owned string.

An error will be returned if the config value is not valid utf-8.

[src]

Get the value of a path config variable as an owned .

[src]

Get the ConfigEntry for a config variable.

[src]

Iterate over all the config variables

If glob is Some, then the iterator will only iterate over all variables whose name matches the pattern.

Example

use git2::Config;

let cfg = Config::new().unwrap();

for entry in &cfg.entries(None).unwrap() {
    let entry = entry.unwrap();
    println!("{} => {}", entry.name().unwrap(), entry.value().unwrap());
}

[src]

Open the global/XDG configuration file according to git's rules

Git allows you to store your global configuration at $HOME/.config or $XDG_CONFIG_HOME/git/config. For backwards compatability, the XDG file shouldn't be used unless the use has created it explicitly. With this function you'll open the correct one to write to.

[src]

Build a single-level focused config object from a multi-level one.

The returned config object can be used to perform get/set/delete operations on a single specific level.

[src]

Set the value of a boolean config variable in the config file with the highest level (usually the local one).

[src]

Set the value of an integer config variable in the config file with the highest level (usually the local one).

[src]

Set the value of an integer config variable in the config file with the highest level (usually the local one).

[src]

Set the value of an multivar config variable in the config file with the highest level (usually the local one).

[src]

Set the value of a string config variable in the config file with the highest level (usually the local one).

[src]

Create a snapshot of the configuration

Create a snapshot of the current state of a configuration, which allows you to look into a consistent view of the configuration for looking up complex values (e.g. a remote, submodule).

[src]

Parse a string as a bool. Interprets "true", "yes", "on", 1, or any non-zero number as true. Interprets "false", "no", "off", 0, or an empty string as false.

[src]

Parse a string as an i32; handles suffixes like k, M, or G, and multiplies by the appropriate power of 1024.

[src]

Parse a string as an i64; handles suffixes like k, M, or G, and multiplies by the appropriate power of 1024.

Trait Implementations

impl Drop for Config
[src]

[src]

Executes the destructor for this type. Read more