pub struct Snapshot<'repo> { /* private fields */ }
Expand description

A platform to access configuration values as read from disk.

Note that these values won’t update even if the underlying file(s) change.

Implementations

Access configuration values, frozen in time, using a key which is a . separated string of up to three tokens, namely section_name.[subsection_name.]value_name, like core.bare or remote.origin.url.

Note that single-value methods always return the last value found, which is the one set most recently in the hierarchy of configuration files, aka ‘last one wins’.

Return the boolean at key, or None if there is no such value or if the value can’t be interpreted as boolean.

For a non-degenerating version, use try_boolean(…).

Note that this method takes the most recent value at key even if it is from a file with reduced trust.

Like boolean(), but it will report an error if the value couldn’t be interpreted as boolean.

Return the resolved integer at key, or None if there is no such value or if the value can’t be interpreted as integer or exceeded the value range.

For a non-degenerating version, use try_integer(…).

Note that this method takes the most recent value at key even if it is from a file with reduced trust.

Like integer(), but it will report an error if the value couldn’t be interpreted as boolean.

Return the string at key, or None if there is no such value.

Note that this method takes the most recent value at key even if it is from a file with reduced trust.

Return the trusted and fully interpolated path at key, or None if there is no such value or if no value was found in a trusted file. An error occurs if the path could not be interpolated to its final value.

Utilities and additional access

Returns the underlying configuration implementation for a complete API, despite being a little less convenient.

It’s expected that more functionality will move up depending on demand.

Returns the configuration for all git-credential helpers from trusted configuration that apply to the given url along with an action preconfigured to invoke the cascade with. This includes url which may be altered to contain a user-name as configured.

These can be invoked to obtain credentials. Note that the url is expected to be the one used to connect to a remote, and thus should already have passed the url-rewrite engine.

Deviation
  • Invalid urls can’t be used to obtain credential helpers as they are rejected early when creating a valid url here.
  • Parsed urls will automatically drop the port if it’s the default, i.e. http://host:80 becomes http://host when parsed. This affects the prompt provided to the user, so that git will use the verbatim url, whereas we use http://host.
  • Upper-case scheme and host will be lower-cased automatically when parsing into a url, so prompts differ compared to git.
  • A difference in prompt might affect the matching of getting existing stored credentials, and it’s a question of this being a feature or a bug.

Trait Implementations

Formats the value using the given formatter. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The alignment of pointer.
The type for initializers.
Initializes a with the given initializer. Read more
Dereferences the given pointer. Read more
Mutably dereferences the given pointer. Read more
Drops the object pointed to by the given pointer. Read more
Should always be Self
The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.