Skip to main content

GitVcs

Struct GitVcs 

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

Implementations§

Source§

impl GitVcs

Source

pub fn open(root: &Path) -> Result<Self, VcsError>

Source

pub fn open_with_context( root: &Path, context_lines: u32, ) -> Result<Self, VcsError>

Open with a custom number of context lines around diff hunks.

Trait Implementations§

Source§

impl Vcs for GitVcs

Source§

fn git_dir(&self) -> Result<PathBuf, VcsError>

Resolved repository metadata directory. In a plain repo this is <root>/.git; in a linked worktree <root>/.git is a gitlink file and this resolves to the external gitdir it points at.
Source§

fn head(&self) -> Result<HeadInfo, VcsError>

Current branch, commit, and upstream.
Source§

fn status(&self) -> Result<StatusModel, VcsError>

Untracked / unstaged / staged sections as separate diff models.
Source§

fn working_tree_diff(&self) -> Result<DiffModel, VcsError>

HEAD vs workdir+index including untracked files: the review view.
Source§

fn commit_diff(&self, oid: &str) -> Result<DiffModel, VcsError>

Changes a single commit introduced over its first parent.
Source§

fn range_diff( &self, oldest_oid: &str, newest_oid: &str, ) -> Result<DiffModel, VcsError>

Combined diff of a contiguous commit range, from the first parent of oldest to newest (git diff <oldest>^..<newest> semantics). When oldest is a root commit its first-parent tree is the empty tree, so the range includes everything oldest introduced.
Source§

fn log(&self, limit: usize) -> Result<Vec<LogEntry>, VcsError>

History from HEAD, newest first.
Source§

fn branches(&self) -> Result<Vec<BranchInfo>, VcsError>

Local branches.
Source§

fn stage(&self, rel: &Path) -> Result<(), VcsError>

Stage a whole file (worktree deletions become staged deletions).
Source§

fn stage_hunk(&self, rel: &Path, hunk: &HunkId) -> Result<(), VcsError>

Stage one hunk out of the unstaged (or untracked) changes of a file.
Source§

fn unstage(&self, rel: &Path) -> Result<(), VcsError>

Reset a file’s index entry back to HEAD, keeping the worktree.
Source§

fn unstage_hunk(&self, rel: &Path, hunk: &HunkId) -> Result<(), VcsError>

Remove one staged hunk from the index, keeping the worktree.
Source§

fn discard(&self, rel: &Path) -> Result<(), VcsError>

Throw away worktree changes only; an untracked file is deleted. Refused while the file has staged changes (unstage first).
Source§

fn commit(&self, message: &str) -> Result<String, VcsError>

Commit the index; returns the new commit id.
Source§

fn head_message(&self) -> Result<String, VcsError>

Full message of the HEAD commit, for amend/reword editor templates.
Source§

fn amend( &self, message: Option<&str>, use_index: bool, ) -> Result<String, VcsError>

Amend HEAD, returning the new commit id. message None reuses HEAD’s message (extend); Some rewords it. use_index true folds the staged index into the new tree (extend/amend); false keeps HEAD’s tree (a pure reword). Local-only — no network.
Source§

fn create_branch(&self, name: &str, checkout: bool) -> Result<(), VcsError>

Source§

fn delete_branch(&self, name: &str) -> Result<(), VcsError>

Refused for the currently checked-out branch.
Source§

fn checkout(&self, name: &str) -> Result<(), VcsError>

Source§

fn stash_push(&self, message: Option<&str>) -> Result<(), VcsError>

Stash tracked changes (staged + unstaged), reverting the worktree to HEAD; untracked files are left in place, matching git stash. message None lets the backend label it. Local-only — no network.
Source§

fn stash_pop(&self) -> Result<(), VcsError>

Restore the most recent stash and drop it. Refused when there is no stash or the pop would conflict.
Source§

fn network_argv(&self, op: NetworkOp) -> Vec<String>

Argv to run for a network op, e.g. ["git", "push"]. The binary runs this in Vcs::workdir so the backend’s own CLI handles credentials; diffler never touches them. A future jj backend returns ["jj", …].
Source§

fn workdir(&self) -> Result<PathBuf, VcsError>

Working directory to run Vcs::network_argv in.
Source§

fn remote_url(&self, name: &str) -> Result<Option<String>, VcsError>

URL of the named remote (e.g. origin), if it exists. Used to detect the CI provider’s host without shelling out.
Source§

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

Names of every configured remote, for multi-remote CI detection.

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