Skip to main content

BranchCommitRefLock

Struct BranchCommitRefLock 

Source
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

Source

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.

Source

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.

Source

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.

Source

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.

Trait Implementations§

Source§

impl Drop for BranchCommitRefLock

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

fn pin_drop(self: Pin<&mut Self>)

🔬This is a nightly-only experimental API. (pin_ergonomics)
Execute the destructor for this type, but different to Drop::drop, it requires self to be pinned. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.