Expand description
git-remote — callable fetch / push / clone / ls-remote orchestration.
This crate lifts the network-transport orchestration out of the git-cli
monolith so it can be driven as a library (the way a downstream consumer such
as heddle needs). The wire codecs (sley_protocol), the pack encoder
(sley_pack), pack building (sley_odb) and ref/commit plumbing already
live in their own crates; git-remote is the glue that sequences them into
fetch/push/clone/ls-remote, with the CLI-specific concerns (argument
parsing, stdout/stderr formatting, exit codes, repository discovery from
process-global state) kept out via the seams below:
CredentialProvider— how authenticated remotes obtain credentials. The caller injects one (e.g. a credential-helper-backed impl, an interactive prompt, orNoCredentialsfor unauthenticated/public access).ProgressSink— where human-facing progress/summary lines go. The orchestration returns structured outcomes and emits progress through this sink instead of printing, so the caller controls presentation.
The lift proceeds in stages (see docs/git-remote-extraction.md); this is
the scaffold (stage A).
Structs§
- Clone
Options - The clone inputs the library needs for the branch-tracking flow, all resolved
by the caller. The remaining
git cloneknobs (bare/mirror,--revision, templates, config overrides, sparse, separate-git-dir, etc.) stay in the CLI: the unsupported ones are gated beforecloneis called, and the config-writing ones run inside theconfigure/configure_branchcallbacks. - Clone
Outcome - The structured result of a
clone. - Clone
Request - Fully resolved inputs for a
clonerun. - Clone
Services - Mutable seams used while cloning.
- Credential
Helper Provider - The default
CredentialProvider: fills and stores credentials via the repository’s configuredcredential.helperprograms. - Fetch
Bundle Request - Fully resolved inputs for a
fetch_bundlerun. - Fetch
Options - Controls for a
fetchrun, mirroring thegit fetchflags the CLI parses. - Fetch
Outcome - The structured result of a
fetch. - Fetch
Request - Fully resolved inputs for a
fetchrun. - Fetch
Services - Mutable seams used while fetching.
- GitFetch
Pack Request - Http
Fetch Pack Request - Fetch
wantsfrom an HTTP upload-pack remote into the repository atgit_dir, installing the resulting pack. Objects already present locally are skipped (for non-shallow fetches);promisorselects promisor-pack installation. - Http
Service Advertisements - Result of smart-HTTP service discovery: parsed ref advertisements plus the protocol v2 handshake when the server negotiated v2 on the info/refs exchange.
- Local
Deepen Plan - The in-process upload-pack’s plan for a
deepen(shallow) local fetch: whichshallow/unshallowupdates to report, which commits the pack walk must stop at, and which extra tips become packable because the client’s boundary moved. - LsRemote
Filter - The ref-class filters that select which advertised refs to keep, mirroring the
git ls-remoteflags the CLI parses. - LsRemote
Record - One advertised ref returned by
ls_remote— what the CLI prints as a<oid>\t<name>line (with an optional precedingref: <symref>\t<name>line when--symrefis set andsymrefis present). - NoCredentials
- A
CredentialProviderthat never supplies credentials, so every request is attempted unauthenticated. This is what an embedder targeting public remotes (e.g. heddle) uses to suppress prompts. - Pruned
Ref - A remote-tracking ref removed by a prune pass.
- Push
Action Plan - A caller-authored push plan. This is distinct from
PushPlan, which is a negotiated, executable transport token returned byplan_push. - Push
Action Request - Fully resolved inputs for a caller-authored exact push plan.
- Push
Command - One caller-authored receive-pack command.
- Push
Options - Controls for a
pushrun, mirroring thegit pushflags the CLI parses that affect the wire/planning behavior the library owns. - Push
Outcome - The structured result of a
push. - Push
Pack Request - Inputs for building a push packfile or full receive-pack request body.
- Push
Plan - A push after ref negotiation and command planning, but before any ref update is sent or applied.
- Push
Request - Fully resolved inputs for a
pushrun. - Push
Services - Mutable seams used while pushing.
- Silent
Progress - A
ProgressSinkthat discards every event. - SshFetch
Pack Request - Fetch
wantsfrom an SSH upload-pack remote into the repository atgit_dir, installing the resulting pack. Objects already present locally are skipped (for non-shallow fetches);promisorselects promisor-pack installation. - Transport
Capabilities - Transport and remote-operation capabilities exposed by
sley-remote.
Enums§
- Clone
Source - How
clonereaches the remote it is cloning from. - Fetch
Source - How a fetch obtains refs and objects from the remote.
- LsRemote
Source - How
ls_remoteobtains the ref advertisements. - Push
Action - A typed push action that preserves the caller’s exact old/new/delete intent.
- Push
Destination - How a push delivers refs and objects to the remote.
- Remote
Transport Kind - Coarse transport classification for capability lookups.
Constants§
- BUNDLE_
FETCH_ SUPPORTED - Flip to
trueonce bundle fetch is lifted from the CLI. - HTTP_
PROTOCOL_ V2_ FETCH - Flip to
trueonce HTTP v2fetchRPC is wired (seehttp.rs). - INFINITE_
DEPTH - Upstream
INFINITE_DEPTH:--unshallow, and the implicit deepen a shallow server runs for a plain fetch so its graft points reach the client. - SSH_
CLONE_ SUPPORTED - Flip to
trueonceCloneSource::Sshlands. - THIN_
PACK_ PUSH_ SUPPORTED - Thin-pack push via
crate::pack::build_push_packfile(PushPackRequest::thin).
Traits§
- Credential
Provider - Supplies credentials for an authenticated remote, mirroring git’s credential
protocol:
fillis handed a partialGitCredentialdescribing the request (protocol/host/path) and returns a completed credential, orNoneto proceed unauthenticated. - Progress
Sink - Receives human-facing progress and summary events from an operation (the
“To
” push summary, prune notices, “Cloning into…”, etc.). The orchestration returns structured outcomes regardless; this is purely for presentation, so the default implementations discard everything.
Functions§
- append_
reachable_ auto_ follow_ tags - Append tags reachable from the fetched (non-tag) commits, using the remote object database to test reachability.
- apply_
configured_ fetch_ prune_ option - Apply the configured
remote.<name>.prune(thenfetch.prune) unless the prune option was set explicitly on the command line. - apply_
configured_ remote_ tag_ option - Apply the configured
remote.<name>.tagoptunless the tag option was set explicitly on the command line. - apply_
shallow_ info - Fold the server’s shallow-info
entriesinto$GIT_DIR/shallow: the new boundary is the existing set plus everyshallow <oid>minus everyunshallow <oid>. A no-op whenentriesis empty (so a deepen request that reported no boundary change leaves the file untouched). Mirrors git’s update of the shallow file after a deepen fetch. - attach_
receive_ pack_ capabilities - Encode
featuresinto the leading ref advertisement’s capability list, inserting a syntheticcapabilities^{}entry when there are no refs. - attach_
upload_ pack_ capabilities - Encode
featuresinto the leading ref advertisement’s capability list, inserting a syntheticcapabilities^{}entry when there are no refs. - build_
push_ packfile - Build the packfile bytes for a push, excluding objects reachable from remote tips the local repository also holds.
- build_
receive_ pack_ body - Build a complete receive-pack push request body: planned commands, negotiated
capabilities, optional push-options, and the packfile from
build_push_packfile. - clone
- Clone the resolved
sourceinto a fresh repository atdestination. - compute_
local_ deepen - Compute the deepen plan for a shallow local fetch, mirroring upstream
shallow.c::get_shallow_commits: a breadth-first minimum-depth walk from the (tag-dereferenced)heads— the primary planned tips, upload-pack’swant_obj, NOT auto-followed tags — where tips enter at depth 0 and a commit processed at depthdis a boundary commit whend + 1 >= depth(it is packed, but its parents are not walked). - compute_
local_ deepen_ by_ rev_ list - Deepen plan for the rev-list modes (
--shallow-since,--shallow-exclude), mirroring upstreamget_shallow_commits_by_rev_list: the kept set is every commit reachable fromheadsthat is newer thansince(when given) and not reachable from adeepen_nottip; the boundary is every kept commit with at least one parent outside the kept set. - credential_
fill - Fill
request(username/password) using the configured credential helpers, returning a complete credential orNoneif it could not be completed. - credential_
request_ for_ url - The lookup key a credential helper is asked to fill for this remote.
- credential_
store - Tell the configured helpers to store (
approve = true) or erase a credential. - execute_
push_ action_ plan - Execute a previously negotiated exact push plan.
- execute_
push_ plan - Execute a previously planned push.
- fetch
- Fetch from a resolved
sourceinto the repository atgit_dir. - fetch_
bundle - Fetch from a parsed
bundleinto the repository atgit_dir. - fetch_
head_ source_ description - The
FETCH_HEADsource description forsource: its configured URL (rewritten perurl.<base>.insteadOf) if any, otherwise the rewrittensource. - fetch_
refspec_ excludes - Whether any negative refspec excludes
name. - fetch_
refspecs_ for_ source - The effective refspec list for a fetch: explicit
refspecs, else theconfiguredremote refspecs, elseHEAD; withrefs/tags/*appended when fetching all tags. - fetch_
source_ for_ url - Build a
FetchSourcefrom a resolved URL. - fetch_
url - Resolve the fetch URL for
remoteusingconfig(name lookup +insteadOf). - git_
upload_ pack_ advertisements - http_
advertised_ refs - Parse a smart-HTTP info/refs body into a ref advertisement set for protocol
v0/v1. Protocol v2 discovery responses require a follow-up
ls-refsRPC; usehttp_service_advertisementsinstead. - http_
authorization_ headers - Build the
Authorizationheader list for an optional credential header value. - http_
check_ status - Map an HTTP response status to success or a descriptive error for
url. - http_
credential_ host - The
host[:port]field of a credential request derived fromremote. - http_
protocol_ name - The
protocolfield of a credential request derived fromremote. - http_
protocol_ v2_ fetch_ response - Post a protocol v2
fetchRPC withwants/haves/shallow/deepenand read back the sectioned response. Authenticates and validates status + content type. When the server advertisessideband-all, the request and response use the sideband-all wire form. - http_
send_ with_ auth - Perform an HTTP request, retrying once with credential-provider-supplied
authentication if the first attempt returns 401.
performis invoked with an optionalAuthorizationheader value and must be idempotent (it may run twice). A successful retry approves the credential withcredentials; a still-401 retry rejects it. - http_
service_ advertisements - Fetch and parse the ref advertisements for
servicefrom the smart-HTTP info/refs endpoint, authenticating and validating status + content type. - http_
upload_ pack_ advertisements - The upload-pack ref advertisements and parsed features for
remote. - http_
upload_ pack_ fetch_ response - Post an upload-pack RPC
request+havesand read back the raw packfile response, authenticating and validating status + content type. For a plain (non-deepen) request; seehttp_upload_pack_shallow_fetch_responsefor the deepen case where the response carries a leading shallow-info section. - http_
upload_ pack_ shallow_ fetch_ response - Post a deepen upload-pack RPC
request+havesand read back the shallow-info section plus the raw packfile response. Use this whenrequestcarries ashallow/deepen/deepen-since/deepen-notargument: git always prefixes the response with a shallow-info section (possibly empty) in that case. The returnedProtocolV2FetchShallowInfoentries are the server’sshallow/unshallowupdates for$GIT_DIR/shallow. - http_
url_ credential - Credential implied by
user[:password]@userinfo in the remote URL. - http_
validate_ content_ type - Verify the response
Content-Typematchesexpected(ignoring parameters). - install_
fetch_ pack_ via_ git_ upload_ pack - install_
fetch_ pack_ via_ http_ protocol_ v2_ fetch - install_
fetch_ pack_ via_ http_ upload_ pack - install_
fetch_ pack_ via_ local_ upload_ pack - Fetch
wantsfrom a local repository atremote_git_dirinto the repository atgit_dir, round-tripping the request and response through the protocol codecs into the in-process upload-pack so the local path exercises the same wire format as the networked transports. Objects already present locally are skipped;promisorselects promisor-pack installation. - install_
fetch_ pack_ via_ ssh_ upload_ pack - local_
fetch_ advertisements - The ref advertisements a local repository would send to a fetching client:
HEAD(if resolvable) followed by every ref, each resolved to its object id. - local_
have_ oids - The object ids the local repository can offer as
haves during negotiation: the deduplicated tips of its own advertisements. - local_
push_ source_ refs - The push-source refs a local repository can match refspecs against: every ref
resolved to its object id, plus the short
refs/heads/andrefs/tags/aliases, plusHEAD. Errors if any ref’s object id does not matchformat. - ls_
remote - List the advertised refs for a resolved
source. - mark_
tag_ refspec_ updates_ not_ for_ merge - Mark tag refspec updates (
refs/tags/X:refs/tags/X) as not-for-merge. - new_
http_ client - Construct the default HTTP client used for smart-HTTP transport.
- normalize_
push_ refname - Expand a short push ref name to
refs/heads/<name>, leaving empty names,HEAD, and already-qualifiedrefs/* names untouched. - normalize_
push_ refspec - Normalize a push refspec, expanding short names to
refs/heads/<name>on both sides and supplying the source as the destination when none is given, while preserving a leading+force marker. - object_
format_ for_ git_ dir - The object format of the repository whose common
$GIT_DIRiscommon_git_dir. - order_
bundle_ fetch_ all_ tags_ updates - Reorder updates so a bundle
--tagsfetch lists non-tags, then tags pointing at fetched commits, then the remaining tags (matching git’s ordering). - plan_
push - Negotiate with the remote and compute the receive-pack command list without sending a pack or applying a ref update.
- plan_
push_ actions - Negotiate with the remote and bind a caller-authored exact push plan to a transport execution token.
- prune_
remote_ tracking_ refs_ from_ advertisements - Prune remote-tracking refs for
remotethat are absent fromadvertisements, deleting them and emitting git’s notice lines throughprogress(unlessquiet). Returns the refs that were pruned. - push
- Push
refspecsto a resolveddestinationfrom the repository atgit_dir. - push_
actions - Push a caller-authored exact plan, preserving its old/new/delete command ids.
- push_
destination_ for_ url - Build a
PushDestinationfrom a resolved URL. - push_
url - Resolve the push URL for
remoteusingconfig(pushurl+pushInsteadOf). - read_
shallow - The boundary commit ids recorded in
$GIT_DIR/shallow, or an empty vec when the file is absent (a complete repository). Lines are parsed as full hex oids offormat; blank lines are ignored. - receive_
pack_ features - The receive-pack capabilities advertised for a local repository: report status, ref deletion, ofs-delta, push-options, quiet, and the object format.
- receive_
pack_ into_ local_ repository - Apply a receive-pack push to the repository at
remote_git_dir: install the incoming packfile and execute the ref creations/updates/deletions, returning the report-status describing what happened. - receive_
pack_ request_ uses_ push_ options - Whether the client negotiated
push-options(so the caller must read the push-option section that follows the command list). - reject_
non_ fast_ forward_ pushes - Reject any non-forced branch update whose old tip is not an ancestor of the new tip (a non-fast-forward). Forced updates, non-branch refs, and creations/deletions are skipped.
- remote_
advertisement_ tips_ known_ to_ local - The advertised tips the local repository already has, deduplicated and excluding the all-zero sentinel — the safe negotiation base for the push pack.
- remote_
url_ is_ http - Whether an already-resolved remote
urluses HTTP(S) transport. - resolve_
fetch_ source - Resolve fetch URL rewriting and transport source in one step.
- resolve_
push_ destination - Resolve push URL rewriting and transport destination in one step.
- retain_
missing_ auto_ follow_ tags - Drop auto-followed tags that already exist locally, keeping only missing ones.
- ssh_
program - The
sshprogram to spawn for SSH transport: theGIT_SSHenvironment variable when set, otherwisessh. This mirrors git’s basicGIT_SSHselection (the richerGIT_SSH_COMMAND/core.sshCommandforms are not handled, matching the CLI behavior being lifted). - ssh_
upload_ pack_ advertisements - The upload-pack ref advertisements and parsed features for SSH
remote. - ssh_
upload_ pack_ fetch_ response - Post an upload-pack
request+havesover SSH and read back the raw packfile response. The leading re-advertised ref set in the RPC stream is read and discarded before the request is written. For a plain (non-deepen) request; seessh_upload_pack_shallow_fetch_responsefor the deepen case. - ssh_
upload_ pack_ shallow_ fetch_ response - Post a deepen upload-pack
request+havesover SSH and read back the shallow-info section plus the raw packfile response. Use this whenrequestcarries ashallow/deepen/deepen-since/deepen-notargument: the response is then prefixed with a shallow-info section (possibly empty). The returnedProtocolV2FetchShallowInfoentries are the server’s shallow-info updates. - transport_
kind_ for_ url - Classify a rewritten URL for capability checks.
- upload_
pack_ features - The upload-pack capabilities advertised for the repository at
git_dir: the object format, side-band-64k, and aHEADsymref hint if present. - upload_
pack_ from_ local_ repository - Serve an upload-pack request from the repository at
git_dir: build the packfile that carries every reachable object the clientwantsbut does not alreadyhaves, framed as a raw (non-side-band) response. - upload_
pack_ request_ uses_ sideband - Whether the client negotiated a side-band channel for the packfile response.
- upload_
pack_ sideband_ response - Re-frame a raw packfile response as side-band data packets, chunked to the pkt-line payload limit (less the one-byte channel prefix).
- validate_
receive_ pack_ report - Validate a receive-pack report-status, surfacing a failed unpack or any rejected ref as an error (matching git’s exit-failure message form).
- write_
default_ fetch_ head - Write a single default
FETCH_HEADrecord (a bareHEADfetch). - write_
fetch_ head - Write
FETCH_HEADfrom fetched ref updates, describing each bydescription. - write_
fetch_ head_ records - Write
FETCH_HEADrecords, truncating or appending perappend. - write_
shallow - Write
$GIT_DIR/shallowfromoids, sorting and de-duplicating them the way git does (by hex, one per line, trailing newline). An empty set removes the file so the repository reads as complete.