pub struct GitSource { /* private fields */ }Expand description
Shell-out driver for the source tracker. Everything goes through Git’s
public interface — never into .git directly — so it works identically
against a clone or, later, a projection.
Implementations§
Source§impl GitSource
impl GitSource
pub fn open(root: &Utf8Path, substrate: SourceSubstrate) -> Result<Self>
pub fn root(&self) -> &Utf8Path
Sourcepub fn is_ignored(&self, path: &str) -> Result<bool>
pub fn is_ignored(&self, path: &str) -> Result<bool>
Whether the store repo’s gitignore rules cover path (which need not
exist yet) — used to enforce the tracker-path invariant.
Sourcepub fn is_tracked(&self, path: &str) -> Result<bool>
pub fn is_tracked(&self, path: &str) -> Result<bool>
Whether path is tracked by the store repo — a tracker path that is
also in Git history is dual-tracked, deliberately or not.
pub fn branch_exists(&self, name: &str) -> Result<bool>
pub fn create_branch(&self, name: &str, base: &str) -> Result<()>
pub fn rev_parse(&self, revision: &str) -> Result<String>
Sourcepub fn clone_to(&self, branch: &str, destination: &Utf8Path) -> Result<()>
pub fn clone_to(&self, branch: &str, destination: &Utf8Path) -> Result<()>
Materialize branch as a full standalone clone at destination.
A local-path clone hardlinks objects; never --shared/--reference.
Sourcepub fn fetch_ref(
&self,
from: &Utf8Path,
remote_ref: &str,
local_ref: &str,
) -> Result<()>
pub fn fetch_ref( &self, from: &Utf8Path, remote_ref: &str, local_ref: &str, ) -> Result<()>
Fetch a ref from another repository (typically a workspace clone) into the store. Fetch, never push: the store pulls commits in when a checkpoint blesses them, and workspaces stay passive.
pub fn update_ref(&self, name: &str, rev: &str) -> Result<()>
pub fn is_ancestor(&self, ancestor: &str, descendant: &str) -> Result<bool>
Sourcepub fn workspace_short_head(workspace: &Utf8Path) -> Result<String>
pub fn workspace_short_head(workspace: &Utf8Path) -> Result<String>
Live HEAD of a workspace clone, short form.
Sourcepub fn workspace_head(workspace: &Utf8Path) -> Result<String>
pub fn workspace_head(workspace: &Utf8Path) -> Result<String>
Live HEAD of a workspace clone, full form.
Sourcepub fn workspace_dirty_commit(
workspace: &Utf8Path,
message: &str,
) -> Result<Option<String>>
pub fn workspace_dirty_commit( workspace: &Utf8Path, message: &str, ) -> Result<Option<String>>
Snapshot uncommitted and untracked (non-ignored) workspace state as a
dangling commit on top of HEAD, without touching HEAD, the real
index, or the worktree. Returns None when the worktree is clean.
Mechanics: a throwaway GIT_INDEX_FILE seeded from HEAD, git add -A
into it, git write-tree, and git commit-tree — all public
interface, nothing reaches into .git internals.
pub fn workspace_update_ref( workspace: &Utf8Path, name: &str, rev: &str, ) -> Result<()>
pub fn workspace_delete_ref(workspace: &Utf8Path, name: &str) -> Result<()>
Sourcepub fn workspace_fetch_ref(
workspace: &Utf8Path,
from: &Utf8Path,
remote_ref: &str,
) -> Result<()>
pub fn workspace_fetch_ref( workspace: &Utf8Path, from: &Utf8Path, remote_ref: &str, ) -> Result<()>
Fetch a store ref into a workspace clone (undo may need objects the workspace has since discarded).
Sourcepub fn workspace_restore_to(
workspace: &Utf8Path,
head_rev: &str,
dirty_rev: Option<&str>,
) -> Result<()>
pub fn workspace_restore_to( workspace: &Utf8Path, head_rev: &str, dirty_rev: Option<&str>, ) -> Result<()>
Put a workspace back to a checkpointed source state: HEAD hard-reset
to head_rev, untracked (non-ignored) files removed, then — when the
checkpoint carried uncommitted state — that state reapplied to the
worktree as uncommitted changes again. Ignored files (tracker paths,
node_modules) are deliberately left alone; trackers and resources own
their restoration.
Sourcepub fn workspace_tracked_files(workspace: &Utf8Path) -> Result<Vec<Utf8PathBuf>>
pub fn workspace_tracked_files(workspace: &Utf8Path) -> Result<Vec<Utf8PathBuf>>
Every path the workspace’s Git tracks, workspace-relative. This is what “the source content of this branch” means for export: tracked files as they stand on disk, so uncommitted edits are included and ignored junk never is.
Sourcepub fn init_export_repo(
destination: &Utf8Path,
branch: &str,
message: &str,
) -> Result<String>
pub fn init_export_repo( destination: &Utf8Path, branch: &str, message: &str, ) -> Result<String>
Turn a directory of already-placed files into an ordinary Git
repository with one commit on branch. Returns the commit.
One commit, never a history rewrite: exporting the workspace’s Git history would carry every file any past commit contained, which is exactly the content the audience filter just excluded.