Skip to main content

Repo

Struct Repo 

Source
pub struct Repo { /* private fields */ }
Expand description

A discovered repository.

Implementations§

Source§

impl Repo

Source

pub fn discover(start: &Path) -> Result<Self>

Finds the repository containing start, walking upwards.

§Errors

Error::Config when there is no repository, or when it is bare — a bare repository has no working tree, so there is nothing to filter.

Source

pub fn discover_from_cwd() -> Result<Self>

Finds the repository containing the current directory.

§Errors

As Repo::discover, plus Error::Io if the current directory is gone.

Source

pub fn git_dir(&self) -> &Path

The .git directory.

Source

pub fn work_tree(&self) -> &Path

The working tree root.

Source

pub fn common_dir(&self) -> &Path

The directory shared by every worktree — the real .git.

The same as Repo::git_dir outside a linked worktree.

Source

pub fn key_path(&self) -> PathBuf

Where the repository key lives. Never versioned, never committed.

In the common directory, so every linked worktree of a repository reads the same key — the alternative is a per-worktree key, which cannot decrypt what the other worktrees committed.

Source

pub fn config_path(&self) -> PathBuf

The config file git actually reads for this repository.

In the common directory, again: a linked worktree’s own git dir has a config file, but git ignores it unless extensions.worktreeConfig is set. Registering the driver there left git with no filter at all — measured on git 2.55, git add on a secret from a linked worktree exited 0 and stored the plaintext.

Source

pub fn xcrypt_config_path(&self) -> PathBuf

The versioned list of what to encrypt.

Source

pub fn attributes_path(&self) -> PathBuf

The attributes file git reads.

Source

pub fn has_key(&self) -> bool

Whether a repository key is present.

Source

pub fn load_key(&self) -> Result<MasterKey>

Loads the repository key.

§Errors

Error::NoKey when the repository is locked or was never initialised.

Source

pub fn relative<'a>(&self, path: &'a Path) -> Option<&'a Path>

Turns a path inside the working tree into a repository-relative one.

Returns None for a path outside the working tree, which is how callers refuse to act on something that is not part of this repository.

Source

pub fn work_trees(&self) -> Vec<PathBuf>

Every checkout of this repository: this one, the main one, and every linked worktree.

Repo::work_tree answers for the checkout a command was run from, and that is not the same question. A key written into a sibling checkout is as committable as one written into this one — measured on git 2.55, export-key ../linked/k.key from the main checkout put the key in the linked worktree’s git status as ?? k.key, one git add -A from a commit. lock already had to know this geometry to avoid stranding a sibling; the refusal in export-key needs the same list.

Best effort on the pointers, and that is the honest limit: a worktree whose registration this cannot read is not in the list, so a caller uses it to widen a refusal, never to prove a path is safe.

Trait Implementations§

Source§

impl Debug for Repo

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl Freeze for Repo

§

impl RefUnwindSafe for Repo

§

impl Send for Repo

§

impl Sync for Repo

§

impl Unpin for Repo

§

impl UnsafeUnpin for Repo

§

impl UnwindSafe for Repo

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> 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> Same for T

Source§

type Output = T

Should always be Self
Source§

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

Source§

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>,

Source§

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.