pub struct GitRepo { /* private fields */ }Implementations§
Source§impl GitRepo
impl GitRepo
Sourcepub fn open(path: &Path) -> Result<Self>
pub fn open(path: &Path) -> Result<Self>
Open a git repository. path may be the work-tree root (contains .git/)
or the bare .git directory itself.
Sourcepub fn resolve_ref(&self, name: &str) -> Result<GitHash>
pub fn resolve_ref(&self, name: &str) -> Result<GitHash>
Resolve any ref name (e.g. "HEAD", "refs/heads/main", or a bare hex hash).
Sourcepub fn read_object(&self, hash: &GitHash) -> Result<RawObject>
pub fn read_object(&self, hash: &GitHash) -> Result<RawObject>
Read and verify an object by hash, from a loose file or a packfile.
Loose objects are tried first; if absent, every packfile is searched
(resolving OFS_DELTA/REF_DELTA chains). A truly missing object yields
GitError::ObjectNotFound; an unsupported pack index version yields
the distinct GitError::PackfileUnsupported — never a misleading
not-found.
Sourcepub fn read_commit(&self, hash: &GitHash) -> Result<CommitObject>
pub fn read_commit(&self, hash: &GitHash) -> Result<CommitObject>
Read and parse a commit object.
Sourcepub fn read_tree(&self, hash: &GitHash) -> Result<TreeObject>
pub fn read_tree(&self, hash: &GitHash) -> Result<TreeObject>
Read and parse a tree object.
Sourcepub fn read_blob(&self, hash: &GitHash) -> Result<Vec<u8>>
pub fn read_blob(&self, hash: &GitHash) -> Result<Vec<u8>>
Read a blob object and return its raw bytes.
Sourcepub fn walk_commits(
&self,
from: GitHash,
) -> impl Iterator<Item = Result<CommitObject>> + '_
pub fn walk_commits( &self, from: GitHash, ) -> impl Iterator<Item = Result<CommitObject>> + '_
Walk the commit ancestry chain, newest-first (first-parent only).
Sourcepub fn reflog(&self, refname: &str) -> Result<Vec<ReflogEntry>>
pub fn reflog(&self, refname: &str) -> Result<Vec<ReflogEntry>>
Read the reflog for refname (e.g. "HEAD", "refs/heads/main").
Returns an empty vec when the log file is absent (git creates one only after the ref first moves), never an error for mere absence.
§Errors
Propagates a non-NotFound I/O error encountered reading the log file.