pub struct Repository {
pub git_dir: PathBuf,
pub work_tree: Option<PathBuf>,
pub odb: Odb,
}Expand description
A handle to an open Git repository.
Fields§
§git_dir: PathBufAbsolute path to the git directory (.git/ or bare repo root).
work_tree: Option<PathBuf>Absolute path to the working tree, or None for bare repos.
odb: OdbLoose object database.
Implementations§
Source§impl Repository
impl Repository
Sourcepub fn open(git_dir: &Path, work_tree: Option<&Path>) -> Result<Self>
pub fn open(git_dir: &Path, work_tree: Option<&Path>) -> Result<Self>
Open a repository from an explicit git-dir and optional work-tree.
§Errors
Returns Error::NotARepository if git_dir does not look like a
valid git directory (missing objects/, HEAD, etc.).
Sourcepub fn discover(start: Option<&Path>) -> Result<Self>
pub fn discover(start: Option<&Path>) -> Result<Self>
Discover the repository starting from start (defaults to cwd if None).
Checks GIT_DIR first; if set, uses it directly. Otherwise walks up
the directory tree looking for .git (regular directory or gitfile).
§Errors
Returns Error::NotARepository if no repository can be found.
Sourcepub fn index_path(&self) -> PathBuf
pub fn index_path(&self) -> PathBuf
Path to the index file.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Repository
impl RefUnwindSafe for Repository
impl Send for Repository
impl Sync for Repository
impl Unpin for Repository
impl UnsafeUnpin for Repository
impl UnwindSafe for Repository
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more