Skip to main content

ReftableRefStore

Struct ReftableRefStore 

Source
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

Source

pub fn open(git_dir: PathBuf) -> Result<Self>

Open the reftable store for an existing repository git directory.

§Errors

Returns Error::Io when the reftable stack cannot be read.

Source

pub fn open_ephemeral() -> Result<Self>

Create a new ephemeral reftable repository (tests).

§Errors

Returns an error when initialization fails.

Source

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

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl RefStore for ReftableRefStore

Source§

fn format(&self) -> RefStorageFormat

Which on-disk or logical format this store uses. Read more
Source§

fn read_raw(&self, name: &str) -> Result<Option<RawRef>>

Read the stored value for name without resolving symbolic targets. Read more
Source§

fn for_each_ref( &self, prefix: &str, f: &mut dyn FnMut(&RefEntry) -> ControlFlow<()>, ) -> Result<()>

Invoke f for each ref whose name starts with prefix, in sorted name order. Read more
Source§

fn for_each_physical_stack_ref( &self, prefix: &str, f: &mut dyn FnMut(&RefEntry) -> ControlFlow<()>, ) -> Result<()>

Walk refs stored in this handle’s physical reftable stack (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>

Validate txn, take locks, and return a committable batch. Read more
Source§

fn reflog_exists(&self, name: &str) -> Result<bool>

Whether a reflog is present for name.
Source§

fn for_each_reflog_entry( &self, name: &str, reverse: bool, f: &mut dyn FnMut(&ReflogEntry) -> ControlFlow<()>, ) -> Result<()>

Iterate reflog entries for name (oldest first unless reverse). Read more
Source§

fn create_reflog(&self, name: &str) -> Result<()>

Create an empty reflog file/record for name.
Source§

fn delete_reflog(&self, name: &str) -> Result<()>

Remove the reflog for name.
Source§

fn replace_reflog(&self, name: &str, entries: Vec<ReflogEntry>) -> Result<()>

Replace the entire reflog (used by expire/delete-entries).
Source§

fn rewrite_reflog( &self, name: &str, transform: &mut dyn FnMut(Vec<ReflogEntry>) -> Result<Vec<ReflogEntry>>, ) -> Result<()>

Read a reflog under the backend writer lock, transform it, and write it back atomically. Read more
Source§

fn for_each_reflog_ref( &self, f: &mut dyn FnMut(&str) -> ControlFlow<()>, ) -> Result<()>

Invoke f for each ref name that has a reflog, in sorted order. Read more
Source§

fn resolve(&self, name: &str) -> Result<ObjectId>

Resolve name to an object id, following symbolic refs. Read more
Source§

fn verify_update_targets( &self, updates: &[RefUpdate], ) -> Result<(), RefStoreError>

Check the objects updates would point refs at, without taking any lock or writing. Read more
Source§

fn as_files(&self) -> Option<&FilesRefStore>

The files backend behind this store, when it is one. Read more
Source§

fn ref_lock_wait(&self) -> LockWait

How long grit-lib retries RefStoreError::LockHeld from Self::prepare. Read more

Auto Trait Implementations§

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> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

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.