Skip to main content

Repo

Struct Repo 

Source
pub struct Repo { /* private fields */ }
Expand description

A discovered git repository.

Implementations§

Source§

impl Repo

Source

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.

Source

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).

Source

pub fn git_dir(&self) -> &Path

This worktree’s git directory (per-worktree; the graph DB lives here).

Source

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.

Source

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.

Source

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.

Source

pub fn walk_blobs(&self) -> Result<Vec<BlobRef>, GitError>

Every blob reachable from the HEAD tree, with full paths.

§Errors

Returns GitError if the tree cannot be traversed or a path is not valid UTF-8.

Source

pub fn read_blob(&self, oid: &str) -> Result<Vec<u8>, GitError>

Read the bytes of the blob with hex object id oid.

§Errors

Returns GitError::Git if the id is malformed or the object is absent.

Auto Trait Implementations§

§

impl !Freeze for Repo

§

impl !RefUnwindSafe for Repo

§

impl !Send for Repo

§

impl !Sync for Repo

§

impl !UnwindSafe for Repo

§

impl Unpin for Repo

§

impl UnsafeUnpin for Repo

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.