pub struct Repo { /* private fields */ }Expand description
A discovered repository.
Implementations§
Source§impl Repo
impl Repo
Sourcepub fn discover(start: &Path) -> Result<Self>
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.
Sourcepub fn discover_from_cwd() -> Result<Self>
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.
Sourcepub fn common_dir(&self) -> &Path
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.
Sourcepub fn key_path(&self) -> PathBuf
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.
Sourcepub fn config_path(&self) -> PathBuf
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.
Sourcepub fn xcrypt_config_path(&self) -> PathBuf
pub fn xcrypt_config_path(&self) -> PathBuf
The versioned list of what to encrypt.
Sourcepub fn attributes_path(&self) -> PathBuf
pub fn attributes_path(&self) -> PathBuf
The attributes file git reads.
Sourcepub fn load_key(&self) -> Result<MasterKey>
pub fn load_key(&self) -> Result<MasterKey>
Loads the repository key.
§Errors
Error::NoKey when the repository is locked or was never initialised.
Sourcepub fn relative<'a>(&self, path: &'a Path) -> Option<&'a Path>
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.
Sourcepub fn work_trees(&self) -> Vec<PathBuf>
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.