pub struct ThreadSafeRepository {
    pub refs: RefStore,
    pub objects: OwnShared<Store>,
    pub work_tree: Option<PathBuf>,
    pub common_dir: Option<PathBuf>,
    /* private fields */
}
Expand description

An instance with access to everything a git repository entails, best imagined as container implementing Sync + Send for most for system resources required to interact with a git repository which are loaded in once the instance is created.

Use this type to reference it in a threaded context for creation the creation of a thread-local Repositories.

Note that this type purposefully isn’t very useful until it is converted into a thread-local repository with to_thread_local(), it’s merely meant to be able to exist in a Sync context.

Fields

refs: RefStore

A store for references to point at objects

objects: OwnShared<Store>
Available on crate feature unstable only.

A store for objects that contain data

work_tree: Option<PathBuf>

The path to the worktree at which to find checked out files

common_dir: Option<PathBuf>

The path to the common directory if this is a linked worktree repository or it is otherwise set.

Implementations

Return the kind of repository, either bare or one with a work tree.

Add thread-local state to an easy-to-use thread-local repository for the most convenient API.

The path to the .git directory itself, or equivalent if this is a bare repository.

Return the path to the repository itself, containing objects, references, configuration, and more.

Synonymous to path().

Return the path to the working directory if this is not a bare repository.

Return the path to the directory containing all objects.

Open a git repository at the given path, possibly expanding it to path/.git if path is a work tree dir.

Open a git repository at the given path, possibly expanding it to path/.git if path is a work tree dir, and use options for fine-grained control.

Note that you should use crate::discover() if security should be adjusted by ownership.

Try to open a git repository in fallback_directory (can be worktree or .git directory) only if there is no override from of the gitdir using git environment variables.

Use the trust_map to apply options depending in the trust level for directory or the directory it’s overridden with. The .git directory whether given or computed is used for trust checks.

Note that this will read various GIT_* environment variables to check for overrides, and is probably most useful when implementing custom hooks.

Create a repository with work-tree within directory, creating intermediate directories as needed.

Fails without action if there is already a .git repository inside of directory, but won’t mind if the directory otherwise is non-empty.

Similar to init, but allows to determine how exactly to open the newly created repository.

Try to open a git repository in directory and search upwards through its parents until one is found, using default trust options which matters in case the found repository isn’t owned by the current user.

Try to open a git repository in directory and search upwards through its parents until one is found, while applying options. Then use the trust_map to determine which of our own repository options to use for instantiations.

Note that trust overrides in the trust_map are not effective here and we will always override it with the determined trust value. This is a precaution as the API user is unable to actually know if the directory that is discovered can indeed be trusted (or else they’d have to implement the discovery themselves and be sure that no attacker ever gets access to a directory structure. The cost of this is a permission check, which seems acceptable).

Try to open a git repository directly from the environment. If that fails, discover upwards from directory until one is found, while applying discovery options from the environment.

Try to open a git repository directly from the environment, which reads GIT_DIR if it is set. If unset, discover upwards from directory until one is found, while applying options with overrides from the environment which includes:

  • GIT_DISCOVERY_ACROSS_FILESYSTEM
  • GIT_CEILING_DIRECTORIES

Finally, use the trust_map to determine which of our own repository options to use based on the trust level of the effective repository directory.

Trait Implementations

Formats the value using the given formatter. Read more

Converts to this type from the input type.

Converts to this type from the input type.

Converts to this type from the input type.

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason. 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.