[go: up one dir, main page]

Struct git2::Transaction[][src]

pub struct Transaction<'repo> { /* fields omitted */ }
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 comitting is not atomic: if an operation fails, the transaction aborts, but previous successful operations are not rolled back.

Implementations

impl<'repo> Transaction<'repo>[src]

pub fn lock_ref(&mut self, refname: &str) -> Result<(), Error>[src]

Lock the specified reference by name.

pub fn set_target(
    &mut self,
    refname: &str,
    target: Oid,
    reflog_signature: Option<&Signature<'_>>,
    reflog_message: &str
) -> Result<(), Error>
[src]

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.

pub fn set_symbolic_target(
    &mut self,
    refname: &str,
    target: &str,
    reflog_signature: Option<&Signature<'_>>,
    reflog_message: &str
) -> Result<(), Error>
[src]

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.

pub fn set_reflog(&mut self, refname: &str, reflog: Reflog) -> Result<(), Error>[src]

Add a Reflog to the transaction.

This commit the in-memory Reflog to disk when the transaction commits. Note that atomicty is *not guaranteed: if the transaction fails to modify refname, the reflog may still have been comitted to disk.

If this is combined with setting the target, that update won’t be written to the log (ie. the reflog_signature and reflog_message parameters will be ignored).

pub fn remove(&mut self, refname: &str) -> Result<(), Error>[src]

Remove a reference.

The reference must have been locked via lock_ref.

pub fn commit(self) -> Result<(), Error>[src]

Commit the changes from the transaction.

The updates will be made one by one, and the first failure will stop the processing.

Trait Implementations

impl Drop for Transaction<'_>[src]

fn drop(&mut self)[src]

Executes the destructor for this type. Read more

Auto Trait Implementations

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

impl<T> Any for T where
    T: 'static + ?Sized
[src]

pub fn type_id(&self) -> TypeId[src]

Gets the TypeId of self. Read more

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

pub fn borrow(&self) -> &T[src]

Immutably borrows from an owned value. Read more

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

pub fn borrow_mut(&mut self) -> &mut T[src]

Mutably borrows from an owned value. Read more

impl<T> From<T> for T[src]

pub fn from(t: T) -> T[src]

Performs the conversion.

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

pub fn into(self) -> U[src]

Performs the conversion.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

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

Performs the conversion.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.

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

Performs the conversion.