pub struct FileRefStore { /* private fields */ }Implementations§
Source§impl FileRefStore
impl FileRefStore
pub fn new(git_dir: impl Into<PathBuf>, format: ObjectFormat) -> Self
pub fn read_ref(&self, name: &str) -> Result<Option<RefTarget>>
Sourcepub fn raw_ref_exists(&self, name: &str) -> Result<bool>
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.
pub fn read_reflog(&self, name: &str) -> Result<Vec<ReflogEntry>>
pub fn write_reflog(&self, name: &str, entries: &[ReflogEntry]) -> Result<()>
pub fn expire_reflog_older_than( &self, name: &str, cutoff_seconds: i64, ) -> Result<usize>
Sourcepub 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>
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.
pub fn list_refs(&self) -> Result<Vec<Ref>>
pub fn has_refs_with_prefix(&self, prefix: &str) -> Result<bool>
pub fn write_packed_refs(&self, refs: &[PackedRef]) -> Result<()>
pub fn pack_refs(&self, prune_loose: bool) -> Result<Vec<PackedRef>>
pub fn pack_refs_with_peeler<F>( &self, prune_loose: bool, peel: F, ) -> Result<Vec<PackedRef>>
pub fn current_branch_ref(&self) -> Result<Option<String>>
pub fn current_branch(&self) -> Result<Option<String>>
pub fn transaction(&self) -> FileRefTransaction<'_>
pub fn create_branch( &self, branch: &str, start: ObjectId, committer: Vec<u8>, message: Vec<u8>, ) -> Result<BranchCreate>
pub fn delete_branch(&self, branch: &str) -> Result<BranchDelete>
pub fn move_branch( &self, old_branch: &str, new_branch: &str, force: bool, committer: Vec<u8>, ) -> Result<()>
pub fn copy_branch( &self, old_branch: &str, new_branch: &str, force: bool, committer: Vec<u8>, ) -> Result<()>
pub fn create_tag(&self, tag: &str, target: ObjectId) -> Result<TagCreate>
pub fn apply_bundle_ref_updates( &self, refs: &[BundleRefUpdate], reflog: Option<BundleRefUpdateReflog>, ) -> Result<Vec<AppliedBundleRefUpdate>>
pub fn delete_tag(&self, tag: &str) -> Result<TagDelete>
pub fn delete_ref(&self, name: &str) -> Result<RefDelete>
pub fn delete_ref_checked( &self, delete: DeleteRef, ) -> Result<RefDelete, RefDeleteError>
pub fn delete_symbolic_ref(&self, name: &str) -> Result<bool>
pub fn append_reflog(&self, name: &str, entry: &ReflogEntry) -> Result<()>
Trait Implementations§
Source§impl Clone for FileRefStore
impl Clone for FileRefStore
Source§fn clone(&self) -> FileRefStore
fn clone(&self) -> FileRefStore
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more