Skip to main content

Repo

Struct Repo 

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

Implementations§

Source§

impl Repo

Source

pub fn discover(from: &Path) -> Option<Self>

Discover the repository containing path (buffer path or cwd).

Source

pub fn workdir(&self) -> &Path

Source

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

Remotes as (name, url) pairs — libgit2 config, no spawn.

Source

pub fn head_sha(&self) -> Option<String>

HEAD’s full SHA (permalink base — branch always resolves to SHA).

Source

pub fn head_branch(&self) -> Option<String>

Current branch (short name; detached HEAD gives the sha prefix).

Source

pub fn head_bytes(&self, rel: &Path) -> Option<Vec<u8>>

HEAD’s content for path, if tracked. HEAD’s blob bytes for a repo-relative path (typed, not lossy).

Source

pub fn commit_bytes(&self, sha: &str, rel: &Path) -> Option<Vec<u8>>

A commit’s blob bytes for a repo-relative path.

Source

pub fn index_bytes(&self, rel: &Path) -> Option<Vec<u8>>

The index’s blob bytes for a repo-relative path (reloads — never a stale snapshot).

Source

pub fn merge_base(&self, a: &str, b: &str) -> Option<String>

Merge-base oid of two revisions.

Source

pub fn head_content(&self, path: &Path) -> Option<String>

Source

pub fn index_content(&self, path: &Path) -> Option<String>

The index’s content for path (the staged version), if any.

Source

pub fn staged_hunks(&self, path: &Path) -> Vec<Hunk>

Hunks between HEAD and the index — the STAGED set (0014 wave 4: the four states are HEAD → index → worktree → live document, and every command names its edge).

Source

pub fn unstaged_hunks(&self, path: &Path, content: &str) -> Vec<Hunk>

Hunks between the index and content — the UNSTAGED set (what the gutter shows while you edit). When nothing is staged this equals HEAD↔content, matching pre-0.5 behavior.

Source

pub fn unstage_hunk(&self, rel: &Path, hunk: &Hunk) -> Result<(), String>

Unstage one hunk, STRUCTURED (0018): the staged hunk’s new side is what’s in the index; swap that region for the old side.

Source

pub fn hunks(&self, path: &Path, content: &str) -> Vec<Hunk>

Hunks between HEAD and content for path. Untracked files report a single all-Add hunk.

Source

pub fn commit_file_diff( &self, sha: &str, path: &Path, ) -> Result<FileDiff, String>

One file’s diff at sha vs its first parent, as structured hunks. The delta view’s data (0010 §1) — libgit2, no shell-out, no re-parsing our own text.

Source

pub fn stage_hunk(&self, rel: &Path, hunk: &Hunk) -> Result<(), String>

Stage one hunk, STRUCTURED (0018): read the index blob, swap the hunk’s old-side region for its new-side lines, write the blob back into the index. No patch serialization — path quoting, CRLF, and missing-final-newline can’t go wrong because nothing is serialized. rel is repo-relative.

Auto Trait Implementations§

§

impl !Sync for Repo

§

impl Freeze for Repo

§

impl RefUnwindSafe for Repo

§

impl Send for Repo

§

impl Unpin for Repo

§

impl UnsafeUnpin for Repo

§

impl UnwindSafe 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, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

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.