Skip to main content

RefCas

Struct RefCas 

Source
pub struct RefCas<'a> {
    pub name: String,
    pub old: Option<Oid<'a>>,
    pub new: Option<Oid<'a>>,
    pub peeled: Option<Vec<u8>>,
}
Expand description

One ref edit with the value the caller expects to find.

This is the field RefUpdate lacks, and its absence is the whole reason git push --atomic could not be expressed: GitOps::put_refs is a batch without compare-and-swap and GitOps::update_ref is compare-and-swap without a batch, and --atomic is defined as both at once. Neither composes into the other — applying a batch one CAS at a time is exactly the partial application --atomic promises never to happen.

old and new are borrowed, like every other oid in this contract: a receive-pack command line is <old> <new> <ref> and both oids are already slices of the pkt-line the caller is holding. peeled is the one that is owned, because it is not on the wire — it is derived by the server, once, at ingest.

Fields§

§name: String§old: Option<Oid<'a>>

What the caller believes is there. None means must not exist — a create that must fail if anything is already at name.

There is deliberately no third “don’t care” state. receive-pack always names an old value (all-zeroes for a create), so a caller that genuinely does not care wants GitOps::put_refs, which is the batch that makes no claim about the previous value.

§new: Option<Oid<'a>>

The new value. None deletes.

§peeled: Option<Vec<u8>>

For an annotated tag, the commit new peels to — the terminal non-tag object, following a tag-of-a-tag all the way down, exactly as git’s packed-refs stores its ^peeled line.

Owned, and None for everything else. A branch head, a lightweight tag and a delete peel to nothing worth storing, so they carry None; only a new that is itself a tag object carries Some. The backend persists it in the ref row’s peeled column so the advertisement (GitServe) reads the peeled target straight out of the row and never re-peels — the object read per tag that every clone, fetch and ls-remote used to pay (gunnar stinky S-080) falls to zero.

It is owned rather than an Oid because, unlike old/new, it is not a slice of any pkt-line the caller holds: the peel is computed by the server from the objects the push just delivered. A backend that keeps no peel column, or a caller that does not compute one, leaves it None and the advertisement falls back to peeling — correct, only not free.

Trait Implementations§

Source§

impl<'a> Clone for RefCas<'a>

Source§

fn clone(&self) -> RefCas<'a>

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<'a> Debug for RefCas<'a>

Source§

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

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

impl<'a> Eq for RefCas<'a>

Source§

impl<'a> PartialEq for RefCas<'a>

Source§

fn eq(&self, other: &RefCas<'a>) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl<'a> StructuralPartialEq for RefCas<'a>

Auto Trait Implementations§

§

impl<'a> Freeze for RefCas<'a>

§

impl<'a> RefUnwindSafe for RefCas<'a>

§

impl<'a> Send for RefCas<'a>

§

impl<'a> Sync for RefCas<'a>

§

impl<'a> Unpin for RefCas<'a>

§

impl<'a> UnsafeUnpin for RefCas<'a>

§

impl<'a> UnwindSafe for RefCas<'a>

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 = !

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.