pub trait Vcs: Send {
Show 24 methods
// Required methods
fn git_dir(&self) -> Result<PathBuf, VcsError>;
fn head(&self) -> Result<HeadInfo, VcsError>;
fn status(&self) -> Result<StatusModel, VcsError>;
fn working_tree_diff(&self) -> Result<DiffModel, VcsError>;
fn commit_diff(&self, oid: &str) -> Result<DiffModel, VcsError>;
fn range_diff(
&self,
oldest_oid: &str,
newest_oid: &str,
) -> Result<DiffModel, VcsError>;
fn log(&self, limit: usize) -> Result<Vec<LogEntry>, VcsError>;
fn branches(&self) -> Result<Vec<BranchInfo>, VcsError>;
fn stage(&self, rel: &Path) -> Result<(), VcsError>;
fn stage_hunk(&self, rel: &Path, hunk: &HunkId) -> Result<(), VcsError>;
fn unstage(&self, rel: &Path) -> Result<(), VcsError>;
fn unstage_hunk(&self, rel: &Path, hunk: &HunkId) -> Result<(), VcsError>;
fn discard(&self, rel: &Path) -> Result<(), VcsError>;
fn commit(&self, message: &str) -> Result<String, VcsError>;
fn head_message(&self) -> Result<String, VcsError>;
fn amend(
&self,
message: Option<&str>,
use_index: bool,
) -> Result<String, VcsError>;
fn create_branch(&self, name: &str, checkout: bool) -> Result<(), VcsError>;
fn delete_branch(&self, name: &str) -> Result<(), VcsError>;
fn checkout(&self, name: &str) -> Result<(), VcsError>;
fn stash_push(&self, message: Option<&str>) -> Result<(), VcsError>;
fn stash_pop(&self) -> Result<(), VcsError>;
fn network_argv(&self, op: NetworkOp) -> Vec<String>;
fn workdir(&self) -> Result<PathBuf, VcsError>;
fn remote_url(&self, name: &str) -> Result<Option<String>, VcsError>;
}Required Methods§
Sourcefn git_dir(&self) -> Result<PathBuf, VcsError>
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.
Sourcefn status(&self) -> Result<StatusModel, VcsError>
fn status(&self) -> Result<StatusModel, VcsError>
Untracked / unstaged / staged sections as separate diff models.
Sourcefn working_tree_diff(&self) -> Result<DiffModel, VcsError>
fn working_tree_diff(&self) -> Result<DiffModel, VcsError>
HEAD vs workdir+index including untracked files: the review view.
Sourcefn commit_diff(&self, oid: &str) -> Result<DiffModel, VcsError>
fn commit_diff(&self, oid: &str) -> Result<DiffModel, VcsError>
Changes a single commit introduced over its first parent.
Sourcefn range_diff(
&self,
oldest_oid: &str,
newest_oid: &str,
) -> Result<DiffModel, VcsError>
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.
Sourcefn log(&self, limit: usize) -> Result<Vec<LogEntry>, VcsError>
fn log(&self, limit: usize) -> Result<Vec<LogEntry>, VcsError>
History from HEAD, newest first.
Sourcefn stage(&self, rel: &Path) -> Result<(), VcsError>
fn stage(&self, rel: &Path) -> Result<(), VcsError>
Stage a whole file (worktree deletions become staged deletions).
Sourcefn stage_hunk(&self, rel: &Path, hunk: &HunkId) -> Result<(), VcsError>
fn stage_hunk(&self, rel: &Path, hunk: &HunkId) -> Result<(), VcsError>
Stage one hunk out of the unstaged (or untracked) changes of a file.
Sourcefn unstage(&self, rel: &Path) -> Result<(), VcsError>
fn unstage(&self, rel: &Path) -> Result<(), VcsError>
Reset a file’s index entry back to HEAD, keeping the worktree.
Sourcefn unstage_hunk(&self, rel: &Path, hunk: &HunkId) -> Result<(), VcsError>
fn unstage_hunk(&self, rel: &Path, hunk: &HunkId) -> Result<(), VcsError>
Remove one staged hunk from the index, keeping the worktree.
Sourcefn discard(&self, rel: &Path) -> Result<(), VcsError>
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).
Sourcefn commit(&self, message: &str) -> Result<String, VcsError>
fn commit(&self, message: &str) -> Result<String, VcsError>
Commit the index; returns the new commit id.
Sourcefn head_message(&self) -> Result<String, VcsError>
fn head_message(&self) -> Result<String, VcsError>
Full message of the HEAD commit, for amend/reword editor templates.
Sourcefn amend(
&self,
message: Option<&str>,
use_index: bool,
) -> Result<String, VcsError>
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.
fn create_branch(&self, name: &str, checkout: bool) -> Result<(), VcsError>
Sourcefn delete_branch(&self, name: &str) -> Result<(), VcsError>
fn delete_branch(&self, name: &str) -> Result<(), VcsError>
Refused for the currently checked-out branch.
fn checkout(&self, name: &str) -> Result<(), VcsError>
Sourcefn stash_push(&self, message: Option<&str>) -> Result<(), VcsError>
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.
Sourcefn stash_pop(&self) -> Result<(), VcsError>
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.
Sourcefn network_argv(&self, op: NetworkOp) -> Vec<String>
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", …].
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".