pub struct SideRepo {
pub git_dir: PathBuf,
pub work_tree: PathBuf,
pub root_sha: String,
}Expand description
Represents a side repository for a project.
Fields§
§git_dir: PathBufPath to the bare git repository.
work_tree: PathBufPath to the work tree (the main project directory).
root_sha: StringThe initial commit SHA of the main repo (project identifier).
Implementations§
Source§impl SideRepo
impl SideRepo
Sourcepub fn open() -> Result<Self>
pub fn open() -> Result<Self>
Resolve or create a side repo for the current project.
§Errors
Returns an error if not in a git repository or if config files cannot be accessed.
Sourcepub fn is_initialized(&self) -> bool
pub fn is_initialized(&self) -> bool
Check if the side repo has been initialized.
Sourcepub fn ensure_initialized(&self) -> Result<()>
pub fn ensure_initialized(&self) -> Result<()>
Initialize the side repo if not already done.
§Errors
Returns an error if the directory cannot be created or git init fails.
Sourcepub fn git(&self, args: &[&str]) -> Result<String>
pub fn git(&self, args: &[&str]) -> Result<String>
Run a git command in the context of the side repo.
§Errors
Returns an error if the git command fails.
Sourcepub fn tracked_file(&self) -> PathBuf
pub fn tracked_file(&self) -> PathBuf
Get the path to the .side-tracked file.
Sourcepub fn stage(&self, path: &Path) -> Result<()>
pub fn stage(&self, path: &Path) -> Result<()>
Stage a path (forced, bypassing gitignore).
§Errors
Returns an error if initialization or staging fails.
Sourcepub fn stage_update(&self, paths: &[PathBuf])
pub fn stage_update(&self, paths: &[PathBuf])
Stage paths with update flag (handles modifications and deletions). Errors are ignored since paths may not be in the index yet.
Sourcepub fn commit(&self, message: &str) -> Result<()>
pub fn commit(&self, message: &str) -> Result<()>
Commit staged changes.
§Errors
Returns NothingToCommit if there are no staged changes, or an error if commit fails.
Sourcepub fn unstage(&self, path: &Path) -> Result<()>
pub fn unstage(&self, path: &Path) -> Result<()>
Remove a path from the index (unstage).
§Errors
Returns an error if the git rm command fails (though failures are typically ignored).
Sourcepub fn stage_tracked_file(&self) -> Result<()>
pub fn stage_tracked_file(&self) -> Result<()>
Stage the .side-tracked file using git plumbing.
Since .side-tracked lives in git_dir (not work_tree), we use hash-object + update-index.
§Errors
Returns an error if the file doesn’t exist or git commands fail.