pub struct ReftableRefStore { /* private fields */ }Expand description
On-disk ref storage using the reftable backend (extensions.refStorage = reftable).
§Atomicity
Refs live in one reftable stack per location: the common stack in the repository’s git
directory, and in a linked worktree a second stack under worktrees/<id>/ for HEAD and
other per-worktree refs. A transaction touching one stack commits as a single new table,
so readers see all of it or none of it.
A transaction touching both stacks (for example updating HEAD in a linked worktree,
which writes the branch in the common stack and logs HEAD in the worktree stack) takes
the tables.list lock of every stack in RefStore::prepare, so no other writer can
interleave, and all checks pass before anything is written. Commit then writes one table
per stack, common stack first. These writes are not atomic together: if a later write
fails (an I/O error), PreparedRefTransaction::commit returns the error, the earlier
stacks keep their new table, and every remaining lock is released. For a HEAD update
this means the branch already points at the new commit with its reflog line, HEAD still
resolves to it through the symbolic ref, and only HEAD’s own reflog line is missing.
Implementations§
Source§impl ReftableRefStore
impl ReftableRefStore
Sourcepub fn open_ephemeral() -> Result<Self>
pub fn open_ephemeral() -> Result<Self>
Create a new ephemeral reftable repository (tests).
§Errors
Returns an error when initialization fails.
Sourcepub fn write_reftable_updates(
&self,
updates: Vec<ReftableTransactionUpdate>,
) -> Result<(), RefStoreError>
pub fn write_reftable_updates( &self, updates: Vec<ReftableTransactionUpdate>, ) -> Result<(), RefStoreError>
Write low-level reftable transaction updates (used by legacy reftable_* helpers).
§Errors
Propagates lock, CAS, and I/O failures from the underlying stack.
Trait Implementations§
Source§impl Debug for ReftableRefStore
impl Debug for ReftableRefStore
Source§impl RefStore for ReftableRefStore
impl RefStore for ReftableRefStore
Source§fn format(&self) -> RefStorageFormat
fn format(&self) -> RefStorageFormat
Source§fn read_raw(&self, name: &str) -> Result<Option<RawRef>>
fn read_raw(&self, name: &str) -> Result<Option<RawRef>>
name without resolving symbolic targets. Read moreSource§fn for_each_ref(
&self,
prefix: &str,
f: &mut dyn FnMut(&RefEntry) -> ControlFlow<()>,
) -> Result<()>
fn for_each_ref( &self, prefix: &str, f: &mut dyn FnMut(&RefEntry) -> ControlFlow<()>, ) -> Result<()>
Source§fn for_each_physical_stack_ref(
&self,
prefix: &str,
f: &mut dyn FnMut(&RefEntry) -> ControlFlow<()>,
) -> Result<()>
fn for_each_physical_stack_ref( &self, prefix: &str, f: &mut dyn FnMut(&RefEntry) -> ControlFlow<()>, ) -> Result<()>
reftable/ under the
store git directory). On the files backend this matches Self::for_each_ref.Source§fn prepare(
&self,
txn: RefTransaction,
) -> Result<Box<dyn PreparedRefTransaction + Send + '_>, RefStoreError>
fn prepare( &self, txn: RefTransaction, ) -> Result<Box<dyn PreparedRefTransaction + Send + '_>, RefStoreError>
txn, take locks, and return a committable batch. Read moreSource§fn for_each_reflog_entry(
&self,
name: &str,
reverse: bool,
f: &mut dyn FnMut(&ReflogEntry) -> ControlFlow<()>,
) -> Result<()>
fn for_each_reflog_entry( &self, name: &str, reverse: bool, f: &mut dyn FnMut(&ReflogEntry) -> ControlFlow<()>, ) -> Result<()>
Source§fn create_reflog(&self, name: &str) -> Result<()>
fn create_reflog(&self, name: &str) -> Result<()>
name.Source§fn replace_reflog(&self, name: &str, entries: Vec<ReflogEntry>) -> Result<()>
fn replace_reflog(&self, name: &str, entries: Vec<ReflogEntry>) -> Result<()>
Source§fn rewrite_reflog(
&self,
name: &str,
transform: &mut dyn FnMut(Vec<ReflogEntry>) -> Result<Vec<ReflogEntry>>,
) -> Result<()>
fn rewrite_reflog( &self, name: &str, transform: &mut dyn FnMut(Vec<ReflogEntry>) -> Result<Vec<ReflogEntry>>, ) -> Result<()>
Source§fn for_each_reflog_ref(
&self,
f: &mut dyn FnMut(&str) -> ControlFlow<()>,
) -> Result<()>
fn for_each_reflog_ref( &self, f: &mut dyn FnMut(&str) -> ControlFlow<()>, ) -> Result<()>
f for each ref name that has a reflog, in sorted order. Read moreSource§fn resolve(&self, name: &str) -> Result<ObjectId>
fn resolve(&self, name: &str) -> Result<ObjectId>
name to an object id, following symbolic refs. Read moreSource§fn verify_update_targets(
&self,
updates: &[RefUpdate],
) -> Result<(), RefStoreError>
fn verify_update_targets( &self, updates: &[RefUpdate], ) -> Result<(), RefStoreError>
updates would point refs at, without taking any lock or writing. Read more