Skip to main content

FileRefStore

Struct FileRefStore 

Source
pub struct FileRefStore { /* private fields */ }

Implementations§

Source§

impl FileRefStore

Source

pub fn new(git_dir: impl Into<PathBuf>, format: ObjectFormat) -> Self

Source

pub fn read_ref(&self, name: &str) -> Result<Option<RefTarget>>

Source

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

Raw existence check matching git’s refs_read_raw_ref (builtin/refs.c cmd_refs_exists). A ref “exists” if its loose file is present (regardless of contents — dangling symrefs, bad object ids, and refs written with a bad name all count) or if it is recorded in packed-refs / the reftable. Unlike [read_ref], no name validation is performed and the object the ref points at is never read. Returns:

  • Ok(true) — the raw ref exists.
  • Ok(false) — ENOENT or EISDIR (a bare directory where the ref would live and no packed entry); git maps both to exit code 2.
Source

pub fn read_reflog(&self, name: &str) -> Result<Vec<ReflogEntry>>

Source

pub fn write_reflog(&self, name: &str, entries: &[ReflogEntry]) -> Result<()>

Source

pub fn expire_reflog_older_than( &self, name: &str, cutoff_seconds: i64, ) -> Result<usize>

Source

pub fn expire_reflog_file( &self, name: &str, cutoff_unix: i64, expire_unreachable_cutoff: Option<i64>, write: bool, is_reachable: impl Fn(&ObjectId) -> bool, ) -> Result<usize>

Read a ref’s reflog, expire entries with expire_reflog, and rewrite the file with the survivors.

Reachability of each entry’s new_oid is delegated to is_reachable so the caller can supply whatever object-graph knowledge it has. Rewriting is opt-in via write: when false nothing is written and the function only reports how many entries would be removed (a dry run). When true the reflog is rewritten atomically (lock file + rename) only if at least one entry was removed; an unchanged reflog is left untouched. Returns the number of entries removed.

Source

pub fn list_refs(&self) -> Result<Vec<Ref>>

Source

pub fn has_refs_with_prefix(&self, prefix: &str) -> Result<bool>

Source

pub fn write_packed_refs(&self, refs: &[PackedRef]) -> Result<()>

Source

pub fn pack_refs(&self, prune_loose: bool) -> Result<Vec<PackedRef>>

Source

pub fn pack_refs_with_peeler<F>( &self, prune_loose: bool, peel: F, ) -> Result<Vec<PackedRef>>
where F: FnMut(&str, &ObjectId) -> Result<Option<ObjectId>>,

Source

pub fn current_branch_ref(&self) -> Result<Option<String>>

Source

pub fn current_branch(&self) -> Result<Option<String>>

Source

pub fn transaction(&self) -> FileRefTransaction<'_>

Source

pub fn create_branch( &self, branch: &str, start: ObjectId, committer: Vec<u8>, message: Vec<u8>, ) -> Result<BranchCreate>

Source

pub fn delete_branch(&self, branch: &str) -> Result<BranchDelete>

Source

pub fn move_branch( &self, old_branch: &str, new_branch: &str, force: bool, committer: Vec<u8>, ) -> Result<()>

Source

pub fn copy_branch( &self, old_branch: &str, new_branch: &str, force: bool, committer: Vec<u8>, ) -> Result<()>

Source

pub fn create_tag(&self, tag: &str, target: ObjectId) -> Result<TagCreate>

Source

pub fn apply_bundle_ref_updates( &self, refs: &[BundleRefUpdate], reflog: Option<BundleRefUpdateReflog>, ) -> Result<Vec<AppliedBundleRefUpdate>>

Source

pub fn delete_tag(&self, tag: &str) -> Result<TagDelete>

Source

pub fn delete_ref(&self, name: &str) -> Result<RefDelete>

Source

pub fn delete_ref_checked( &self, delete: DeleteRef, ) -> Result<RefDelete, RefDeleteError>

Source

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

Source

pub fn append_reflog(&self, name: &str, entry: &ReflogEntry) -> Result<()>

Trait Implementations§

Source§

impl Clone for FileRefStore

Source§

fn clone(&self) -> FileRefStore

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for FileRefStore

Source§

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

Formats the value using the given formatter. 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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

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

Source§

type Error = Infallible

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

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

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.