pub struct GitVcs { /* private fields */ }Implementations§
Source§impl GitVcs
impl GitVcs
Sourcepub fn open_with_settings(
root: &Path,
settings: &DiffSettings,
) -> Result<Self, VcsError>
pub fn open_with_settings( root: &Path, settings: &DiffSettings, ) -> Result<Self, VcsError>
Open with a custom context, line-diff algorithm and indent heuristic
(config keys ui.context_lines, diff.algorithm, diff.indent_heuristic).
Trait Implementations§
Source§impl Vcs for GitVcs
impl Vcs for GitVcs
Source§fn has_index(&self) -> bool
fn has_index(&self) -> bool
Whether this backend has a staging area at all: true for git; jj has
none, so its whole working copy reads as
StatusModel::staged and
the UI drops staging entirely.Source§fn native_git_checkout(&self) -> bool
fn native_git_checkout(&self) -> bool
Whether a raw
git/forge CLI command (git switch, gh pr checkout)
may check out a branch directly: true for plain git; jj’s own
operation log and working-copy snapshot would never see a write made
this way, so a checkout there must go through Vcs::checkout instead.Source§fn 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.Source§fn status(&self) -> Result<StatusModel, VcsError>
fn status(&self) -> Result<StatusModel, VcsError>
Untracked / unstaged / staged sections as separate diff models.
Source§fn 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.
Source§fn tree_to_workdir_diff(&self, base_oid: &str) -> Result<DiffModel, VcsError>
fn tree_to_workdir_diff(&self, base_oid: &str) -> Result<DiffModel, VcsError>
Vcs::working_tree_diff taken from an arbitrary base commit instead
of HEAD, so uncommitted work shows alongside the commits since base.Source§fn 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.
Source§fn tree_diff(
&self,
base_oid: &str,
newest_oid: &str,
) -> Result<DiffModel, VcsError>
fn tree_diff( &self, base_oid: &str, newest_oid: &str, ) -> Result<DiffModel, VcsError>
Diff between two trees as-is (
git diff <base> <newest> semantics);
with base a merge base this is a PR-style three-dot diff.Source§fn merge_base(&self, a: &str, b: &str) -> Result<String, VcsError>
fn merge_base(&self, a: &str, b: &str) -> Result<String, VcsError>
Best common ancestor of two commits.
Source§fn resolve(&self, revision: &str) -> Result<String, VcsError>
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>
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>
fn log(&self, limit: usize) -> Result<Vec<LogEntry>, VcsError>
History from HEAD, newest first.
Source§fn default_branch(&self, remote: &str) -> Result<Option<String>, VcsError>
fn default_branch(&self, remote: &str) -> Result<Option<String>, VcsError>
The branch a pull request merges into by default;
None when the
repository offers no answer.Source§fn commits_between(
&self,
base: &str,
head: &str,
) -> Result<Vec<LogEntry>, VcsError>
fn commits_between( &self, base: &str, head: &str, ) -> Result<Vec<LogEntry>, VcsError>
Commits reachable from
head but not base, newest first: what a
pull request from head would carry.Source§fn unpushed(&self, limit: usize) -> Result<Option<Vec<LogEntry>>, VcsError>
fn unpushed(&self, limit: usize) -> Result<Option<Vec<LogEntry>>, VcsError>
Commits on HEAD that no remote-tracking branch contains, newest first,
at most
limit of them: work that exists only on this machine. None
when the repository has no remote-tracking refs, where being pushed has
no meaning yet. Asking the remotes rather than the configured upstream
is what makes the answer true: an upstream may be another local branch,
or a stale ref from before the last fetch. limit bounds a walk that is
otherwise the whole history whenever no remote ref sits on it.Source§fn blame(&self, rel: &Path) -> Result<Vec<BlameSpan>, VcsError>
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. Lines the worktree added since the last commit come back as one
span of their own, owned by no commit.Source§fn read_at(&self, rev: &str, path: &str) -> Result<Option<String>, VcsError>
fn read_at(&self, rev: &str, path: &str) -> Result<Option<String>, VcsError>
One file’s content as recorded in
rev’s tree, None when that tree
has no such path. Lets a review pinned to one tree (a commit, a
range’s newest, a PR’s head) resolve a walkthrough’s anchors against
what it actually shows, rather than whatever the worktree holds now.Source§fn read_blob(&self, oid: &str) -> Result<Option<Vec<u8>>, VcsError>
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>
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
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: the caller is refining a
guess, so there is nothing to report and nothing to recover.Source§fn branches(&self) -> Result<Vec<BranchInfo>, VcsError>
fn branches(&self) -> Result<Vec<BranchInfo>, VcsError>
Local branches, their divergence left unresolved.
Source§fn divergence(&self, branch: &str) -> Result<Option<(usize, usize)>, VcsError>
fn divergence(&self, branch: &str) -> Result<Option<(usize, usize)>, VcsError>
How far
branch stands from its upstream, as (ahead, behind), or
None when it tracks nothing.Source§fn all_branches(&self) -> Result<Vec<String>, VcsError>
fn all_branches(&self) -> Result<Vec<String>, VcsError>
Local and remote-tracking branch names, for pickers that name a
revision rather than check one out.
Source§fn stage(&self, rel: &Path) -> Result<(), VcsError>
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>
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>
fn stage_everything(&self) -> Result<(), VcsError>
Stage every change in the worktree, deletions and untracked files
included. Resolved against the repository as it is now, so a file
edited since the caller last looked is still caught.
Source§fn unstage_everything(&self) -> Result<(), VcsError>
fn unstage_everything(&self) -> Result<(), VcsError>
Reset the whole index back to HEAD, keeping the worktree.
Source§fn 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.
Source§fn 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.
Source§fn 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).
Source§fn commit(&self, message: &str) -> Result<String, VcsError>
fn commit(&self, message: &str) -> Result<String, VcsError>
Commit the index; returns the new commit id.
Source§fn head_message(&self) -> Result<String, VcsError>
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>
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>
Source§fn 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>
Source§fn 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.Source§fn 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.
Source§fn network_argv(&self, op: NetworkOp) -> Result<Vec<String>, VcsError>
fn network_argv(&self, op: NetworkOp) -> Result<Vec<String>, VcsError>
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. The jj backend returns ["jj", "git", …]
for a fetch; push and pull would move git’s refs behind jj’s back, so
it rejects every push/pull variant instead.Source§fn remote_url(&self, name: &str) -> Result<Option<String>, VcsError>
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>
fn remotes(&self) -> Result<Vec<String>, VcsError>
Names of every configured remote, for multi-remote CI detection.
Source§fn set_diff_algorithm(&self, algorithm: DiffAlgorithm, indent_heuristic: bool)
fn set_diff_algorithm(&self, algorithm: DiffAlgorithm, indent_heuristic: bool)
Switch the line-diff algorithm every diff this instance computes from
now on uses (config keys
diff.algorithm, diff.indent_heuristic).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> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more