pub struct GitVfs { /* private fields */ }Expand description
Git-aware filesystem backend.
Wraps LocalFs for file operations while tracking git repository state. All file operations go through the local filesystem, with git operations available through dedicated methods.
Implementations§
Source§impl GitVfs
impl GitVfs
Sourcepub fn open(path: impl Into<PathBuf>) -> Result<Self, GitError>
pub fn open(path: impl Into<PathBuf>) -> Result<Self, GitError>
Open an existing git repository.
The path should point to a directory containing a .git folder
(or the .git folder itself for bare repos).
Sourcepub fn clone(url: &str, path: impl Into<PathBuf>) -> Result<Self, GitError>
pub fn clone(url: &str, path: impl Into<PathBuf>) -> Result<Self, GitError>
Clone a repository from a URL.
Sourcepub fn init(path: impl Into<PathBuf>) -> Result<Self, GitError>
pub fn init(path: impl Into<PathBuf>) -> Result<Self, GitError>
Initialize a new git repository.
Sourcepub fn status(&self) -> Result<Vec<FileStatus>, GitError>
pub fn status(&self) -> Result<Vec<FileStatus>, GitError>
Get the current status of the working tree.
Sourcepub fn status_summary(&self) -> Result<StatusSummary, GitError>
pub fn status_summary(&self) -> Result<StatusSummary, GitError>
Get a simplified status summary.
Sourcepub fn add(&self, pathspec: &[&str]) -> Result<(), GitError>
pub fn add(&self, pathspec: &[&str]) -> Result<(), GitError>
Add files to the git index (staging area).
Supports glob patterns (e.g., “.rs”, “src/**/.rs”).
Sourcepub fn reset_path(&self, path: &Path) -> Result<(), GitError>
pub fn reset_path(&self, path: &Path) -> Result<(), GitError>
Remove a file from the index (unstage).
Sourcepub fn commit(
&self,
message: &str,
author: Option<&str>,
) -> Result<Oid, GitError>
pub fn commit( &self, message: &str, author: Option<&str>, ) -> Result<Oid, GitError>
Create a commit with the staged changes.
Sourcepub fn log(&self, count: usize) -> Result<Vec<LogEntry>, GitError>
pub fn log(&self, count: usize) -> Result<Vec<LogEntry>, GitError>
Get recent commit log entries.
Sourcepub fn checkout(&self, target: &str) -> Result<(), GitError>
pub fn checkout(&self, target: &str) -> Result<(), GitError>
Checkout a branch or commit.
If force is true, overwrites local changes. If false, fails if there
are uncommitted changes that would be overwritten.
Sourcepub fn checkout_with_options(
&self,
target: &str,
force: bool,
) -> Result<(), GitError>
pub fn checkout_with_options( &self, target: &str, force: bool, ) -> Result<(), GitError>
Checkout with explicit force option.
If force is false, checkout will fail if there are uncommitted changes
that would be overwritten by the checkout.
Sourcepub fn worktrees(&self) -> Result<Vec<WorktreeInfo>, GitError>
pub fn worktrees(&self) -> Result<Vec<WorktreeInfo>, GitError>
List all worktrees attached to this repository.
Returns the main worktree plus any linked worktrees.
Sourcepub fn worktree_add(
&self,
name: &str,
path: &Path,
committish: Option<&str>,
) -> Result<WorktreeInfo, GitError>
pub fn worktree_add( &self, name: &str, path: &Path, committish: Option<&str>, ) -> Result<WorktreeInfo, GitError>
Add a new worktree.
Creates a new worktree at path with the given name.
The committish parameter accepts:
- Local branch names (
feature,main) - Remote tracking branches (
origin/main) - Commit SHAs (
abc1234) - Tags (
v1.0.0) - Any git revision (
HEAD~3)
If committish is None, creates a new branch with the worktree name.
Sourcepub fn worktree_remove(&self, name: &str, force: bool) -> Result<(), GitError>
pub fn worktree_remove(&self, name: &str, force: bool) -> Result<(), GitError>
Remove a worktree.
The worktree must not be locked and must be prunable (no uncommitted changes).
Use force to remove even if it has changes.
Sourcepub fn worktree_lock(
&self,
name: &str,
reason: Option<&str>,
) -> Result<(), GitError>
pub fn worktree_lock( &self, name: &str, reason: Option<&str>, ) -> Result<(), GitError>
Lock a worktree to prevent it from being pruned.
Sourcepub fn worktree_prune(&self) -> Result<usize, GitError>
pub fn worktree_prune(&self) -> Result<usize, GitError>
Prune stale worktree information.
Removes worktree entries that no longer exist on disk.