pub struct Vcs(/* private fields */);Expand description
The version control system used to read file contents from history.
Supports Git and Jujutsu (jj). Use Vcs::git(), Vcs::jj(), or
Vcs::detect().
Implementations§
Source§impl Vcs
impl Vcs
Sourcepub fn git() -> Result<Self, VcsEnvError>
pub fn git() -> Result<Self, VcsEnvError>
Creates a Git VCS using the $GIT environment variable or
"git".
Returns an error if the $GIT environment variable is set
but is not valid UTF-8.
Sourcepub fn jj() -> Result<Self, VcsEnvError>
pub fn jj() -> Result<Self, VcsEnvError>
Creates a Jujutsu VCS using the $JJ environment variable
or "jj".
Returns an error if the $JJ environment variable is set
but is not valid UTF-8.
Sourcepub fn detect(repo_root: &Utf8Path) -> Result<Self, VcsDetectError>
pub fn detect(repo_root: &Utf8Path) -> Result<Self, VcsDetectError>
Detects the appropriate VCS for a repository.
repo_root must be the repository root.
Detection order:
- If a
.jjpath exists, returns jj (including colocated mode where both.jjand.gitexist). - If a
.gitpath exists, returns git. (.gitmay be a directory or a file, as in worktrees and submodules.) - Otherwise, returns an error.
Sourcepub fn is_shallow_clone(
&self,
repo_root: &Utf8Path,
) -> Result<bool, ShallowCloneError>
pub fn is_shallow_clone( &self, repo_root: &Utf8Path, ) -> Result<bool, ShallowCloneError>
Checks if the repository at repo_root is a shallow clone.
For Git, runs git rev-parse --is-shallow-repository.
For Jujutsu, resolves the underlying Git store using
jj git root --ignore-working-copy and checks for a shallow
marker file there.
Sourcepub fn read_git_stub_contents(
&self,
stub: &GitStub,
repo_root: &Utf8Path,
) -> Result<Vec<u8>, ReadContentsError>
pub fn read_git_stub_contents( &self, stub: &GitStub, repo_root: &Utf8Path, ) -> Result<Vec<u8>, ReadContentsError>
Reads the contents of the file referenced by a git stub.
For Git, runs git cat-file blob <commit>:<path>.
For Jujutsu, runs jj file show --revision <commit> <path>.