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_settings( root: &Path, settings: &DiffSettings, ) -> Result<Self, VcsError>

Source

pub fn open_jj_store( git_dir: &Path, root: &Path, settings: &DiffSettings, ) -> Result<Self, VcsError>

The bare git store of a jj repo with no .git of its own, its worktree set to root.

Trait Implementations§

Source§

impl Vcs for GitVcs

Source§

fn has_index(&self) -> bool

Whether this backend has a staging area. jj has none, so its whole working copy reads as StatusModel::staged.
Source§

fn native_git_checkout(&self) -> bool

Whether a raw git/forge CLI command may check out a branch. False for jj, whose operation log would miss the write, so we go through Vcs::checkout there.
Source§

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

Resolved metadata directory. In a linked worktree this is the gitdir the .git file points at.
Source§

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

Source§

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

Source§

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

HEAD vs index + worktree, untracked files included.
Source§

fn tree_to_workdir_diff(&self, base_oid: &str) -> Result<DiffModel, VcsError>

Vcs::working_tree_diff taken from base_oid.
Source§

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

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

fn tree_diff( &self, base_oid: &str, newest_oid: &str, ) -> Result<DiffModel, VcsError>

git diff <base> <newest>; with base a merge base this is a three-dot diff.
Source§

fn merge_base(&self, a: &str, b: &str) -> Result<String, VcsError>

Source§

fn resolve(&self, revision: &str) -> Result<String, VcsError>

Resolve a revision (oid, ref name, remote ref) to a full commit oid.
Source§

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

git diff <oldest>^..<newest>. A root oldest diffs from the empty tree.
Source§

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

History from HEAD, or from every branch, remote branch and tag with all_branches, newest first and each commit before its parents.
Source§

fn default_branch(&self, remote: &str) -> Result<Option<String>, VcsError>

The branch a pull request merges into by default, if the repo says.
Source§

fn commits_between( &self, base: &str, head: &str, ) -> Result<Vec<LogEntry>, VcsError>

Commits reachable from head but not base, newest first.
Source§

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

Commits on HEAD that no remote-tracking branch contains, newest first, at most limit. None when the repo has no remote-tracking refs. We ask the remotes since a configured upstream may be a local branch or a stale ref.
Source§

fn blame(&self, rel: &Path) -> Result<Vec<BlameSpan>, VcsError>

Last commit to touch each line of rel as the worktree has it, in line order. Uncommitted lines come back as spans owned by no commit.
Source§

fn read_at(&self, rev: &str, path: &str) -> Result<Option<String>, VcsError>

One file’s content in rev’s tree, None when the tree lacks it.
Source§

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

A blob’s raw bytes by its hex id (a crate::model::BlobIds side), None when the object store has no such blob.
Source§

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

Every tracked file, repo-relative and sorted. This is the index, so a staged new file is tracked and an untracked one is not.
Source§

fn attr(&self, rel: &Path, name: &str) -> bool

Whether the repo’s git attributes set name to true for rel. Unreadable attribute files read as unset.
Source§

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

Local branches, their divergence left unresolved.
Source§

fn divergence(&self, branch: &str) -> Result<Option<(usize, usize)>, VcsError>

(ahead, behind) against the upstream, None when branch tracks nothing.
Source§

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

Local and remote-tracking branch names.
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 stage_everything(&self) -> Result<(), VcsError>

Stage every change in the worktree, deletions and untracked files included.
Source§

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

Reset the whole index back to HEAD, keeping the worktree.
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 commit_message(&self, oid: &str) -> Result<String, VcsError>

Full message of the commit oid.
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; false keeps HEAD’s tree (a pure reword).
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, leaving untracked files in place like git stash. message None lets the backend label it.
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) -> Result<Vec<String>, VcsError>

Argv for a network op, run in Vcs::workdir so the backend’s own CLI handles credentials. jj pushes bookmarks with jj git push and pulls with jj git fetch, then Vcs::rebase_onto_remote.
Source§

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

Source§

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

Source§

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

Source§

fn set_diff_algorithm(&self, algorithm: DiffAlgorithm, indent_heuristic: bool)

Set the line-diff algorithm for every later diff of this instance.
Source§

fn read_jj_view(&self, _log_limit: usize) -> Result<Option<JjView>, VcsError>

jj’s view, covering log_limit commits of history; None outside a jj repo. It costs two jj runs, so callers ask from a worker, and this handle adopts it.
Source§

fn adopt_jj_view(&self, _view: JjView)

Take a view another handle read, with no subprocess.
Source§

fn commit_paths( &self, _message: &str, _paths: &[String], ) -> Result<String, VcsError>

Commit only paths (files or folders) of the working copy, which jj can do with no index; returns the new commit id.
Source§

fn change(&self, _op: &ChangeOp) -> Result<(), VcsError>

A jj change verb; git has none.
Source§

fn pull_target(&self) -> Result<Option<PullTarget>, VcsError>

What a jj pull fetches and rebases onto, read fresh; None outside jj or with no local bookmark under @.
Source§

fn rebase_onto_remote( &self, _bookmark: &str, _remote: &str, ) -> Result<PullOutcome, VcsError>

After a fetch, rebase @’s branch onto bookmark@remote when that moved.

Auto Trait Implementations§

§

impl !Freeze for GitVcs

§

impl !RefUnwindSafe for GitVcs

§

impl !Sync for GitVcs

§

impl Send for GitVcs

§

impl Unpin for GitVcs

§

impl UnsafeUnpin for GitVcs

§

impl UnwindSafe for GitVcs

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.