pub enum WantPolicy {
AdvertisedTips,
ReachableFromRefs,
Any,
}Expand description
Which object ids a client is allowed to ask for.
git spells this as three separate uploadpack.allow*SHA1InWant settings,
and the middle one is not optional for a server that advertises filter: a
partial clone’s lazy fetch asks for bare blob ids that were never
advertised, so WantPolicy::AdvertisedTips turns every git checkout in
a blob:none clone into “the remote end hung up unexpectedly”.
Variants§
AdvertisedTips
Only ids that appeared in the advertisement.
The strictest setting, and the one that breaks partial clone.
ReachableFromRefs
Anything reachable from a reference. This is git’s
uploadpack.allowReachableSHA1InWant, and the default here.
The cost is honest and real: proving reachability means walking the
repository’s whole object closure once per request that names a
non-tip id. The git package’s __gunnar_reach__ bitmaps are what make this
cheap; until they exist, this walk is the price of partial clone.
Any
Anything present in the store, reachable or not.
Makes every object that was ever pushed fetchable by whoever can name it, including on branches that have since been deleted.
Implementations§
Source§impl WantPolicy
impl WantPolicy
Sourcepub fn advertises(self, promise: WantPolicy) -> bool
pub fn advertises(self, promise: WantPolicy) -> bool
Does this policy make good on a capability row that
requires promise?
§Why the answer is a match and not a >=
The three variants happen to be orderable, and encoding that as an ordering would make adding a fourth silently inherit whichever neighbours it landed between. Written out, a new variant does not compile until someone decides what it promises — which is the property that was missing, not the ordering.
The mapping is git’s, bit for bit: ALLOW_TIP_SHA1 prints
allow-tip-sha1-in-want, ALLOW_REACHABLE_SHA1 prints
allow-reachable-sha1-in-want, and ALLOW_ANY_SHA1 is both bits set,
so it prints both (upload-pack.c, send_ref).
WantPolicy::AdvertisedTips promises nothing, on purpose: gunnar
hides no reference, so “only ids in the advertisement” is exactly what a
v0 client assumes when neither capability is present.