pub struct BranchCommitRefLock { /* private fields */ }Expand description
Loose branch ref lock held between CAS validation and the ref file commit.
Dropping without commit_branch_commit_ref_lock aborts the lock file.
Implementations§
Source§impl BranchCommitRefLock
impl BranchCommitRefLock
Sourcepub fn acquire(
git_dir: &Path,
branch_ref: &str,
expected_old: Option<ObjectId>,
) -> Result<Self>
pub fn acquire( git_dir: &Path, branch_ref: &str, expected_old: Option<ObjectId>, ) -> Result<Self>
Acquire the branch ref lock and verify expected_old before worktree mutations.
§Errors
Same as update_branch_for_commit_with_config, except no reflogs or ref write occur yet.
Sourcepub fn write_reflogs(
&mut self,
git_dir: &Path,
update: &BranchCommitRefUpdate<'_>,
reflog_old: &ObjectId,
config: &ConfigSet,
) -> Result<()>
pub fn write_reflogs( &mut self, git_dir: &Path, update: &BranchCommitRefUpdate<'_>, reflog_old: &ObjectId, config: &ConfigSet, ) -> Result<()>
Append branch and HEAD reflog entries while holding the lock from Self::acquire.
Intended to run before worktree checkout so reflog I/O failures do not leave the
index or working tree ahead of HEAD.
§Errors
Returns I/O or reflog failures; the ref lock is aborted and any branch reflog line written in this call is truncated.
Sourcepub fn finish_ref_commit(
self,
git_dir: &Path,
update: &BranchCommitRefUpdate<'_>,
) -> Result<()>
pub fn finish_ref_commit( self, git_dir: &Path, update: &BranchCommitRefUpdate<'_>, ) -> Result<()>
Write the new OID into the held lock file and rename it over the branch ref.
Call after the worktree matches update.new_oid when splitting reflog work from checkout.
§Errors
Returns I/O failures; the ref lock is aborted unless the rename succeeds.
Sourcepub fn commit(
self,
git_dir: &Path,
update: &BranchCommitRefUpdate<'_>,
reflog_old: &ObjectId,
config: &ConfigSet,
) -> Result<()>
pub fn commit( self, git_dir: &Path, update: &BranchCommitRefUpdate<'_>, reflog_old: &ObjectId, config: &ConfigSet, ) -> Result<()>
Write reflogs and commit the branch ref while holding the lock from Self::acquire.
§Errors
Returns I/O or reflog failures; the lock is aborted unless the ref commit succeeds.