Skip to main content

GitRepo

Struct GitRepo 

Source
pub struct GitRepo { /* private fields */ }

Implementations§

Source§

impl GitRepo

Source

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.

Source

pub fn head(&self) -> Result<GitHash>

Resolve HEAD to its commit hash.

Source

pub fn resolve_ref(&self, name: &str) -> Result<GitHash>

Resolve any ref name (e.g. "HEAD", "refs/heads/main", or a bare hex hash).

Source

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.

Source

pub fn read_commit(&self, hash: &GitHash) -> Result<CommitObject>

Read and parse a commit object.

Source

pub fn read_tree(&self, hash: &GitHash) -> Result<TreeObject>

Read and parse a tree object.

Source

pub fn read_blob(&self, hash: &GitHash) -> Result<Vec<u8>>

Read a blob object and return its raw bytes.

Source

pub fn walk_commits( &self, from: GitHash, ) -> impl Iterator<Item = Result<CommitObject>> + '_

Walk the commit ancestry chain, newest-first (first-parent only).

Source

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.

Source

pub fn all_objects(&self) -> Result<Vec<GitHash>>

Every object in the store: the union of loose and packed objects, with duplicates removed (an object may be both loose and packed mid-gc).

§Errors

Propagates a GitError from packfile-index enumeration.

Source

pub fn all_refs(&self) -> Vec<(String, GitHash)>

Every ref in the repository as (refname, target_hash) pairs (loose refs/**, packed-refs, and HEAD).

Auto Trait Implementations§

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.