Struct git_ref::file::Transaction
source · pub struct Transaction<'s, 'p> { /* private fields */ }
Expand description
A transaction on a file store
Implementations
sourceimpl<'s, 'p> Transaction<'s, 'p>
impl<'s, 'p> Transaction<'s, 'p>
sourcepub fn prepare(
self,
edits: impl IntoIterator<Item = RefEdit>,
ref_files_lock_fail_mode: Fail,
packed_refs_lock_fail_mode: Fail
) -> Result<Self, Error>
pub fn prepare(
self,
edits: impl IntoIterator<Item = RefEdit>,
ref_files_lock_fail_mode: Fail,
packed_refs_lock_fail_mode: Fail
) -> Result<Self, Error>
Prepare for calling commit(…)
in a way that can be rolled back perfectly.
If the operation succeeds, the transaction can be committed or dropped to cause a rollback automatically. Rollbacks happen automatically on failure and they tend to be perfect. This method is idempotent.
sourcepub fn rollback(self) -> Vec<RefEdit> ⓘ
pub fn rollback(self) -> Vec<RefEdit> ⓘ
Rollback all intermediate state and return the RefEdits
as we know them thus far.
Note that they have been altered compared to what was initially provided as they have been split and know about their current state on disk.
Note
A rollback happens automatically as this instance is dropped as well.
sourceimpl<'s, 'p> Transaction<'s, 'p>
impl<'s, 'p> Transaction<'s, 'p>
sourcepub fn commit(self, committer: SignatureRef<'_>) -> Result<Vec<RefEdit>, Error>
pub fn commit(self, committer: SignatureRef<'_>) -> Result<Vec<RefEdit>, Error>
Make all prepared permanent and return the performed edits which represent the current
state of the affected refs in the ref store in that instant. Please note that the obtained edits may have been
adjusted to contain more dependent edits or additional information.
committer
is used in the reflog.
On error the transaction may have been performed partially, depending on the nature of the error, and no attempt to roll back partial changes is made.
In this stage, we perform the following operations:
- update the ref log
- move updated refs into place
- delete reflogs and empty parent directories
- delete packed refs
- delete their corresponding reference (if applicable) along with empty parent directories
Note that transactions will be prepared automatically as needed.
sourceimpl<'s, 'p> Transaction<'s, 'p>
impl<'s, 'p> Transaction<'s, 'p>
sourcepub fn packed_refs(self, packed_refs: PackedRefs<'p>) -> Self
pub fn packed_refs(self, packed_refs: PackedRefs<'p>) -> Self
Configure the way packed refs are handled during the transaction