pub struct GitBridge<'a> { /* private fields */ }Expand description
Git bridge for Heddle repository.
Implementations§
Source§impl<'a> GitBridge<'a>
impl<'a> GitBridge<'a>
Sourcepub fn new(heddle_repo: &'a HeddleRepository) -> Self
pub fn new(heddle_repo: &'a HeddleRepository) -> Self
Create a new Git bridge for a Heddle repository.
Sourcepub fn init_mirror(&mut self) -> GitResult<()>
pub fn init_mirror(&mut self) -> GitResult<()>
Initialize a Git mirror in the .heddle/git directory.
Sourcepub fn mirror_path(&self) -> PathBuf
pub fn mirror_path(&self) -> PathBuf
Get the path to the Git mirror directory.
Sourcepub fn is_initialized(&self) -> bool
pub fn is_initialized(&self) -> bool
Check if a Git mirror is initialized.
Sourcepub fn export(&mut self) -> GitResult<ExportStats>
pub fn export(&mut self) -> GitResult<ExportStats>
Export all Heddle states to Git commits.
Sourcepub fn push(&mut self, remote_name: &str) -> GitResult<Vec<String>>
pub fn push(&mut self, remote_name: &str) -> GitResult<Vec<String>>
Push to a Git remote. Returns the full names of the refs written
at the destination this invocation (see Self::push_with_scope_force).
Sourcepub fn push_with_scope(
&mut self,
remote_name: &str,
scope: GitPushScope,
) -> GitResult<Vec<String>>
pub fn push_with_scope( &mut self, remote_name: &str, scope: GitPushScope, ) -> GitResult<Vec<String>>
Push to a Git remote with an explicit ref scope. Returns the full names of the refs written at the destination this invocation.
Sourcepub fn push_with_scope_force(
&mut self,
remote_name: &str,
scope: GitPushScope,
force: bool,
) -> GitResult<Vec<String>>
pub fn push_with_scope_force( &mut self, remote_name: &str, scope: GitPushScope, force: bool, ) -> GitResult<Vec<String>>
Push to a Git remote with an explicit ref scope and optional non-fast-forward ref movement.
Returns the full names (e.g. refs/heads/<thread>,
refs/notes/heddle, refs/tags/<tag>) of the refs WRITTEN at the
destination this invocation — creations, fast-forwards, and forced
rewinds — sorted for deterministic output. A no-op push returns an
empty list. Retraction deletes are not included.
Sourcepub fn export_to_path(&mut self, target_path: &Path) -> GitResult<ExportStats>
pub fn export_to_path(&mut self, target_path: &Path) -> GitResult<ExportStats>
Export current Heddle state into the internal mirror, then write it out
as a bare git repository at target_path. Auto-initializes
target_path as a bare repo if it does not already exist.
Sourcepub fn fetch(&mut self, remote_name: &str) -> GitResult<()>
pub fn fetch(&mut self, remote_name: &str) -> GitResult<()>
Fetch Git refs and objects into the internal mirror without moving Heddle thread refs or the current worktree.
Sourcepub fn pull(&mut self, remote_name: &str) -> GitResult<GitPullOutcome>
pub fn pull(&mut self, remote_name: &str) -> GitResult<GitPullOutcome>
Pull from a Git remote.
Sourcepub fn write_through_current_checkout(
&mut self,
) -> GitResult<WriteThroughOutcome>
pub fn write_through_current_checkout( &mut self, ) -> GitResult<WriteThroughOutcome>
Make the checkout’s real .git view agree with the current Heddle
thread: copy exported objects from the internal mirror, advance the
matching Git branch, attach HEAD, and rebuild the Git index from the
exported commit tree.
pub fn write_through_current_checkout_with_message( &mut self, state_id: ChangeId, message: String, ) -> GitResult<WriteThroughOutcome>
Sourcepub fn update_intent_to_add(&self, state_id: &ChangeId) -> GitResult<()>
pub fn update_intent_to_add(&self, state_id: &ChangeId) -> GitResult<()>
Mark files that Heddle has captured but that Git still sees as
untracked as intent-to-add in the colocated checkout’s index,
so a colocated developer’s git status shows AM new_file
(“Heddle knows about it; no Git blob committed yet”) instead of
?? new_file (“untracked — Git knows nothing”). The placeholder
entry uses the empty-blob oid and a zeroed stat, so Git always
reports the working-tree content as modified-against-index.
Ported from jujutsu’s update_intent_to_add (lib/src/git.rs),
which diffs old_tree vs new_tree and flags paths present in
the new tree but absent from the old one. Here new_tree is the
just-captured Heddle state’s tree and old_tree is whatever the
checkout’s index already tracks — paths already in the index are
not ??, so they are left untouched (no spurious marking of
tracked or unchanged files).
Call frequency mirrors jj: this fires at a Heddle parent/state
change (capture), not on every command. A later checkpoint
rebuilds the index from the committed tree via
Self::write_through_current_checkout, replacing these
placeholder entries with real ones — so the index is never
churned by read-only invocations.
Sourcepub fn write_through_thread_checkout(
&mut self,
thread: &str,
) -> GitResult<WriteThroughOutcome>
pub fn write_through_thread_checkout( &mut self, thread: &str, ) -> GitResult<WriteThroughOutcome>
Make the checkout’s real .git view agree with a specific Heddle
thread. thread switch uses this after writing Heddle HEAD because
resolving “current” through Git-overlay discovery can still see the
branch that was active before the switch.
Source§impl GitBridge<'_>
impl GitBridge<'_>
Sourcepub fn reconstruction_repo(&mut self) -> GitResult<SleyRepository>
pub fn reconstruction_repo(&mut self) -> GitResult<SleyRepository>
Open (initializing if necessary) a writable sley repo suitable for reconstruction’s tree-OID resolution. Any writable odb works — git trees are content-addressed — so the bridge’s own mirror is reused.
Sourcepub fn reconstruct_commit_bytes(
&self,
repo: &SleyRepository,
state: &State,
) -> GitResult<Vec<u8>>
pub fn reconstruct_commit_bytes( &self, repo: &SleyRepository, state: &State, ) -> GitResult<Vec<u8>>
Reconstruct the byte-exact commit content for state against repo (see
reconstruct_commit_bytes), using the bridge’s import-built mapping for
parent OIDs.
Sourcepub fn reconstruct_and_write_commit(
&self,
repo: &SleyRepository,
state: &State,
) -> GitResult<ObjectId>
pub fn reconstruct_and_write_commit( &self, repo: &SleyRepository, state: &State, ) -> GitResult<ObjectId>
Reconstruct state’s commit object from Heddle state and WRITE it into
repo’s object database, returning its git OID (see write_commit_object).
The export’s commit-minting step (#567): the object is regenerated from
state, so it lands at the original SHA without the mirror needing to hold
the verbatim bytes.
Sourcepub fn reconstruct_commit_for_git_sha(
&self,
repo: &SleyRepository,
sha: &str,
) -> GitResult<Option<Vec<u8>>>
pub fn reconstruct_commit_for_git_sha( &self, repo: &SleyRepository, sha: &str, ) -> GitResult<Option<Vec<u8>>>
Reconstruct the commit currently mapped to the git object sha (40-hex),
or None if no Heddle state maps to it. Convenience for callers keyed by
the original git OID — e.g. the #566 conformance gate, which compares the
reconstruction of each original commit against its captured golden bytes.
Sourcepub fn reconstruct_and_write_commit_for_git_sha(
&self,
repo: &SleyRepository,
sha: &str,
) -> GitResult<Option<ObjectId>>
pub fn reconstruct_and_write_commit_for_git_sha( &self, repo: &SleyRepository, sha: &str, ) -> GitResult<Option<ObjectId>>
Reconstruct the commit mapped to git object sha and WRITE it into repo,
returning the written OID (or None if no Heddle state maps to sha).
Combines Self::reconstruct_commit_for_git_sha with the odb write so the
#567 export-from-state path is exercisable against an arbitrary repo —
notably a FRESH one that never received the verbatim imported bytes, which
is how the export gate proves the object is regenerated from state, not
copied from the mirror.
Auto Trait Implementations§
impl<'a> !RefUnwindSafe for GitBridge<'a>
impl<'a> !UnwindSafe for GitBridge<'a>
impl<'a> Freeze for GitBridge<'a>
impl<'a> Send for GitBridge<'a>
impl<'a> Sync for GitBridge<'a>
impl<'a> Unpin for GitBridge<'a>
impl<'a> UnsafeUnpin for GitBridge<'a>
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::Request