Skip to main content

PackedRefs

Struct PackedRefs 

Source
pub struct PackedRefs { /* private fields */ }
Expand description

A one-time, in-memory snapshot of a ref store’s packed-refs file.

Bulk ref operations — notably fetch’s apply phase — resolve and write thousands of refs back-to-back. Going through resolve_ref / write_ref for each one re-reads and re-scans the entire packed-refs file on every call, making the apply O(refs × packed-refs size). On a repository with tens of thousands of packed refs that dominates the whole fetch even when no objects are transferred. Loading the file once into this snapshot and using resolve_ref_cached / write_ref_cached makes the apply linear.

The snapshot reflects packed-refs at load time. write_ref_cached may update the snapshot in place so later namespace checks in the same apply batch see loose refs without reloading the file. Otherwise treat it as read-only: stale packed data only omits refs that were loose on disk (resolved outside the snapshot) to begin with.

Implementations§

Source§

impl PackedRefs

Source

pub fn load(git_dir: &Path) -> Result<Self>

Load the packed-refs snapshot for the ref store backing git_dir (the shared common dir for linked worktrees). A missing file yields an empty snapshot; reftable repositories also yield an empty snapshot.

§Errors

Returns Error::Io if packed-refs exists but cannot be read, or Error::PackedRefsUnexpectedLine when the file contains lines Git would reject.

Source

pub fn get(&self, refname: &str) -> Option<ObjectId>

The packed value recorded for refname, if any.

Source

pub fn has_namespace_conflict(&self, refname: &str) -> bool

Whether any packed ref name conflicts with refname as a path prefix (e.g. an existing refs/heads/x blocks creating refs/heads/x/y). Mirrors the internal packed_ref_namespace_conflict helper against the snapshot.

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.