pub struct Repo { /* private fields */ }Expand description
A discovered git repository.
Implementations§
Source§impl Repo
impl Repo
Sourcepub fn discover(path: &Path) -> Result<Self, GitError>
pub fn discover(path: &Path) -> Result<Self, GitError>
Discover the repository containing path (walking upwards to the .git).
§Errors
Returns GitError::Git if no repository is found or it cannot be opened.
Sourcepub fn common_dir(&self) -> &Path
pub fn common_dir(&self) -> &Path
The repository’s common git directory. The cache lives under here so it is shared across linked worktrees (which each have their own git dir).
Sourcepub fn git_dir(&self) -> &Path
pub fn git_dir(&self) -> &Path
This worktree’s git directory (per-worktree; the graph DB lives here).
Sourcepub fn workdir(&self) -> Option<&Path>
pub fn workdir(&self) -> Option<&Path>
The working directory, if this is not a bare repository. The dirty overlay reads uncommitted file contents from here.
Sourcepub fn blob_oid(&self, bytes: &[u8]) -> Result<String, GitError>
pub fn blob_oid(&self, bytes: &[u8]) -> Result<String, GitError>
The hex git blob object id that bytes would have, without writing
anything. Used to detect whether a working-copy file differs from the
committed blob (same content ⇒ same id).
§Errors
Returns GitError::Git if hashing fails.
Sourcepub fn head_tree_id(&self) -> Result<String, GitError>
pub fn head_tree_id(&self) -> Result<String, GitError>
Hex object id of the tree at HEAD.
§Errors
Returns GitError::Git if HEAD cannot be resolved to a tree.