Enum gix_config::Source

source ·
pub enum Source {
    GitInstallation,
    System,
    Git,
    User,
    Local,
    Worktree,
    Env,
    Cli,
    Api,
    EnvOverride,
}
Expand description

A list of known sources for git configuration in order of ascending precedence.

This means values from the first one will be overridden by values in the second one, and so forth. Note that included files via include.path and includeIf.<condition>.path inherit their source.

Variants§

§

GitInstallation

A special configuration file that ships with the git installation, and is thus tied to the used git binary.

§

System

System-wide configuration path. This is defined as $(prefix)/etc/gitconfig (where prefix is the git-installation directory).

§

Git

A platform defined location for where a user’s git application configuration should be located. If $XDG_CONFIG_HOME is not set or empty, $HOME/.config/git/config will be used on unix.

§

User

This is usually ~/.gitconfig on unix.

§

Local

The configuration of the repository itself, located in .git/config.

§

Worktree

Configuration specific to a worktree as created with git worktree and typically located in $GIT_DIR/config.worktree if extensions.worktreeConfig is enabled.

§

Env

Values parsed from the environment using GIT_CONFIG_COUNT, GIT_CONFIG_KEY_N and GIT_CONFIG_VALUE_N where N is incremented from 0 up to the value of GIT_CONFIG_COUNT.

§

Cli

Values set from the command-line, typically controlled by the user running a program.

§

Api

Entirely internal from a programmatic source, and can be used to have (near final) say in configuration values.

§

EnvOverride

Values obtained from specific environment variables that override values in the git configuration.

For example, HTTP_PROXY overrides http.proxy, no matter where it is specified, and thus controls the value similar to how it’s done in git.

Implementations§

source§

impl Source

source

pub const fn kind(self) -> Kind

Return true if the source indicates a location within a file of a repository.

source

pub fn storage_location( self, env_var: &mut dyn FnMut(&str) -> Option<OsString>, ) -> Option<Cow<'static, Path>>

Returns the location at which a file of this type would be stored, or None if there is no notion of persistent storage for this source, with env_var to obtain environment variables. Note that the location can be relative for repository-local sources like Local and Worktree, and the caller has to known which base it is relative to, namely the common_dir in the Local case and the git_dir in the Worktree case. Be aware that depending on environment overrides, multiple scopes might return the same path, which should only be loaded once nonetheless.

With env_var it becomes possible to prevent accessing environment variables entirely to comply with gix-sec permissions for example.

Trait Implementations§

source§

impl Clone for Source

source§

fn clone(&self) -> Source

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for Source

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl From<Source> for Metadata

source§

fn from(source: Source) -> Self

Converts to this type from the input type.
source§

impl Hash for Source

source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
source§

impl Ord for Source

source§

fn cmp(&self, other: &Source) -> Ordering

This method returns an Ordering between self and other. Read more
1.21.0 · source§

fn max(self, other: Self) -> Self
where Self: Sized,

Compares and returns the maximum of two values. Read more
1.21.0 · source§

fn min(self, other: Self) -> Self
where Self: Sized,

Compares and returns the minimum of two values. Read more
1.50.0 · source§

fn clamp(self, min: Self, max: Self) -> Self
where Self: Sized + PartialOrd,

Restrict a value to a certain interval. Read more
source§

impl PartialEq for Source

source§

fn eq(&self, other: &Source) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl PartialOrd for Source

source§

fn partial_cmp(&self, other: &Source) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · source§

fn lt(&self, other: &Rhs) -> bool

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · source§

fn le(&self, other: &Rhs) -> bool

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · source§

fn gt(&self, other: &Rhs) -> bool

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · source§

fn ge(&self, other: &Rhs) -> bool

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
source§

impl Copy for Source

source§

impl Eq for Source

source§

impl StructuralPartialEq for Source

Auto Trait Implementations§

§

impl Freeze for Source

§

impl RefUnwindSafe for Source

§

impl Send for Source

§

impl Sync for Source

§

impl Unpin for Source

§

impl UnwindSafe for Source

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> CloneToUninit for T
where T: Clone,

source§

unsafe fn clone_to_uninit(&self, dst: *mut T)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

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

source§

impl<T> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.