pub struct Transaction<'repo> { /* private fields */ }Expand description
A structure representing a transactional update of a repository’s references.
Transactions work by locking loose refs for as long as the Transaction
is held, and committing all changes to disk when Transaction::commit is
called. Note that committing is not atomic: if an operation fails, the
transaction aborts, but previous successful operations are not rolled back.
Implementations§
Source§impl<'repo> Transaction<'repo>
impl<'repo> Transaction<'repo>
Sourcepub fn lock_ref(&mut self, refname: &str) -> Result<(), Error>
pub fn lock_ref(&mut self, refname: &str) -> Result<(), Error>
Lock the specified reference by name.
Sourcepub fn set_target(
&mut self,
refname: &str,
target: Oid,
reflog_signature: Option<&Signature<'_>>,
reflog_message: &str,
) -> Result<(), Error>
pub fn set_target( &mut self, refname: &str, target: Oid, reflog_signature: Option<&Signature<'_>>, reflog_message: &str, ) -> Result<(), Error>
Set the target of the specified reference.
The reference must have been locked via lock_ref.
If reflog_signature is None, the Signature is read from the
repository config.
Sourcepub fn set_symbolic_target(
&mut self,
refname: &str,
target: &str,
reflog_signature: Option<&Signature<'_>>,
reflog_message: &str,
) -> Result<(), Error>
pub fn set_symbolic_target( &mut self, refname: &str, target: &str, reflog_signature: Option<&Signature<'_>>, reflog_message: &str, ) -> Result<(), Error>
Set the target of the specified symbolic reference.
The reference must have been locked via lock_ref.
If reflog_signature is None, the Signature is read from the
repository config.
Sourcepub fn set_reflog(&mut self, refname: &str, reflog: Reflog) -> Result<(), Error>
pub fn set_reflog(&mut self, refname: &str, reflog: Reflog) -> Result<(), Error>
Add a Reflog to the transaction.
This commit the in-memory Reflog to disk when the transaction commits.
Note that atomicity is *not guaranteed: if the transaction fails to
modify refname, the reflog may still have been committed to disk.
If this is combined with setting the target, that update won’t be
written to the log (i.e. the reflog_signature and reflog_message
parameters will be ignored).
Trait Implementations§
Auto Trait Implementations§
impl<'repo> Freeze for Transaction<'repo>
impl<'repo> RefUnwindSafe for Transaction<'repo>
impl<'repo> !Send for Transaction<'repo>
impl<'repo> !Sync for Transaction<'repo>
impl<'repo> Unpin for Transaction<'repo>
impl<'repo> UnwindSafe for Transaction<'repo>
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
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more