Skip to main content

FileRefTransaction

Struct FileRefTransaction 

Source
pub struct FileRefTransaction<'a> { /* private fields */ }

Implementations§

Source§

impl<'a> FileRefTransaction<'a>

Source

pub fn with_hook(self, hook: &'a dyn ReferenceTransactionHook) -> Self

Attach the reference-transaction hook handler this transaction fires at each phase. Without one the transaction behaves exactly as before (no hook is run). This is the single point through which every ref-write path — update-ref, symbolic-ref, update-ref --stdin, push — gets hook coverage, so a new write site cannot silently skip the hook.

Source

pub fn update(&mut self, update: RefUpdate)

Queue a ref update whose precondition comes from RefUpdate::expected (None = no check; Some(target) = the ref must currently match target). For create-only or match-or-create semantics use update_to.

Source

pub fn update_to( &mut self, name: impl Into<String>, new: RefTarget, precondition: RefPrecondition, reflog: Option<ReflogEntry>, )

Queue a ref update with an explicit compare-and-swap RefPrecondition (e.g. MustNotExist for create-only, or ExistingMustMatch for match-or-create). The precondition is re-verified while the ref is locked.

Source

pub fn delete(&mut self, delete: DeleteRef)

Queue a direct ref delete using the historical checked-delete shape.

expected_old = None means “delete any direct ref”; Some(oid) means the direct ref must currently point at that object id.

Source

pub fn delete_with_precondition( &mut self, name: impl Into<String>, precondition: RefDeletePrecondition, _reflog: Option<DeleteRefReflog>, )

Queue a ref delete with an explicit direct/symbolic precondition.

_reflog is accepted for API compatibility but ignored: git unlinks the reflog on delete rather than writing a deletion entry, so a caller-supplied deletion message has no on-disk effect.

Source

pub fn commit(self) -> Result<()>

Commit all queued updates and deletes atomically and durably.

All ref changes succeed together or none take effect. For the loose-ref backend the sequence is:

  1. Preserve the historical update-only coalescing behavior. Mixed transactions reject duplicate ref names so a delete and write cannot target the same ref ambiguously.
  2. Take an exclusive <ref>.lock file for every ref up front, and lock packed-refs before checked deletes can inspect or rewrite it.
  3. Re-verify every precondition while holding the locks, closing the check-then-write race that a pre-lock verification would leave open.
  4. Stage every write, delete marker, and packed-refs rewrite.
  5. Rename/remove staged paths, rolling back already-applied paths if a later step fails.

If any step fails, every path already changed in this commit is restored to the exact bytes it held beforehand (or removed if it did not exist), and all outstanding lock files are deleted. Reflog entries are appended only after every ref change has landed.

Auto Trait Implementations§

§

impl<'a> !RefUnwindSafe for FileRefTransaction<'a>

§

impl<'a> !Send for FileRefTransaction<'a>

§

impl<'a> !Sync for FileRefTransaction<'a>

§

impl<'a> !UnwindSafe for FileRefTransaction<'a>

§

impl<'a> Freeze for FileRefTransaction<'a>

§

impl<'a> Unpin for FileRefTransaction<'a>

§

impl<'a> UnsafeUnpin for FileRefTransaction<'a>

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, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.