pub struct ServeOptions {
pub protocol: ProtocolVersion,
pub stateless_rpc: bool,
pub advertise_refs: bool,
pub agent: String,
pub hidden_refs: Vec<String>,
pub server_options: Vec<String>,
pub bundle_list: Option<BundleList>,
pub push_bundle: Option<String>,
pub accepted_promisor_remotes: Vec<String>,
pub lazy_fetch: Option<bool>,
}Expand description
How a serving session is framed on the wire.
Fields§
§protocol: ProtocolVersionProtocol version the client asked for.
stateless_rpc: boolHandle exactly one request from the input and stop, without printing the advertisement first. Smart HTTP uses this for its POST requests.
advertise_refs: boolPrint the ref (or capability) advertisement and stop. Smart HTTP uses
this to answer GET info/refs.
agent: StringValue for the agent= capability, such as grit/0.5.0.
Ref patterns hidden from the advertisement (transfer.hideRefs and the
service-specific uploadpack.hideRefs / receive.hideRefs).
server_options: Vec<String>Values the client sent as v2 server-option=<value> capability lines on
the current command request. Cleared at the start of each v2 command and
filled before ls-refs / fetch / object-info handlers run.
bundle_list: Option<BundleList>Bundles to offer through the protocol v2 bundle-uri command. None
leaves the command out of the advertisement.
push_bundle: Option<String>Where clients may upload a resumable push bundle, advertised by
receive-pack as pushBundle=<value>; relative values are relative to
the repository URL. None advertises nothing.
accepted_promisor_remotes: Vec<String>Filled while serving: the promisor remotes the client accepted, from the
promisor-remote=<names> capability of its v2 command requests. Only names
this server advertised (see
PromisorAdvertisement)
are kept. The list lasts for the whole session, so an acceptance sent with
ls-refs still holds for the fetch that follows; a stateless (smart
HTTP) request only sees what that one request carried. Callers leave it
empty.
lazy_fetch: Option<bool>Fetch objects this repository is missing from its own promisor remotes
before answering a client that accepted none of them, so the client still
gets a complete pack. None uses uploadpack.lazyFetch (a grit setting,
false by default).
Git’s upload-pack turns lazy fetch off unless GIT_NO_LAZY_FETCH=0 is in
its environment; the library reads no environment, so callers map that
variable here. Fetching needs a
PromisorFetcher on the
Repository, otherwise the request fails with
MissingObjectReason::NoFetcher.
Implementations§
Source§impl ServeOptions
impl ServeOptions
Sourcepub fn lazy_fetch_from_environment(env: &Environment) -> Option<bool>
pub fn lazy_fetch_from_environment(env: &Environment) -> Option<bool>
The Self::lazy_fetch an upload-pack process should use under env, from
GIT_NO_LAZY_FETCH (or grit’s GRIT_NO_LAZY_FETCH, which wins when both are
set): a false value turns lazy fetch on, a true value turns it off, and
unset (or not a boolean) leaves uploadpack.lazyFetch in charge.
Git’s upload-pack sets GIT_NO_LAZY_FETCH=1 unless the variable is already
in its environment, so GIT_NO_LAZY_FETCH=0 is how a Git server is told to
fetch promised objects for clients that did not accept its promisor remotes.
§Parameters
env: the server process environment.
Sourcepub fn lazy_fetch_enabled(&self, config: &ConfigSet) -> bool
pub fn lazy_fetch_enabled(&self, config: &ConfigSet) -> bool
Whether upload-pack may fetch missing promised objects for this session:
Self::lazy_fetch when set, otherwise uploadpack.lazyFetch from config.
A caller uses this to decide whether to open the served Repository with a
PromisorFetcher. Without one, a
served repository never fetches anything.
§Parameters
config: the served repository’s configuration.
Sourcepub fn attach_promisor_fetcher(
&self,
repo: &Repository,
config: &ConfigSet,
fetcher: Option<Arc<dyn PromisorFetcher>>,
) -> bool
pub fn attach_promisor_fetcher( &self, repo: &Repository, config: &ConfigSet, fetcher: Option<Arc<dyn PromisorFetcher>>, ) -> bool
Give the repository an upload-pack session serves the promisor fetcher it may
use: fetcher when Self::lazy_fetch_enabled, and none otherwise, so a
server without lazy fetch never fetches anything, whichever fetcher the
repository was opened with.
Every upload-pack entry point (the grit upload-pack command, smart HTTP,
the in-process local transport) calls this right after opening the
repository.
§Parameters
repo: the served repository.config: its configuration.fetcher: the fetcher to use when lazy fetch is on.
§Returns
Whether a fetcher is now installed.