Skip to main content

http_fetch

Function http_fetch 

Source
pub fn http_fetch(
    client: &dyn HttpClient,
    local_git_dir: &Path,
    repo_url: &str,
    opts: &FetchOptions,
    progress: &mut dyn Progress,
) -> Result<FetchOutcome>
Expand description

Fetch from a smart-HTTP remote, driving the stateless-RPC negotiation and writing tracking-ref updates into local_git_dir.

This is the HTTP counterpart to crate::fetch::fetch_remote: instead of a duplex socket it issues info/refs discovery + git-upload-pack POSTs through client. The refspec matching, tag-mode, prune, and update classification reuse the shared crate::transfer helpers, so the FetchOutcome shape matches every other fetch path.

Both protocol v0/v1 and protocol v2 are handled: the version is taken from the info/refs advertisement (the v2 capability block is returned only when the discovery GET carries Git-Protocol: version=2, which the client’s default header supplies). For v2 the ref map is recovered with a command=ls-refs POST and the pack is negotiated with command=fetch POSTs (stateless: every round resends the wants + accumulated haves).

§Errors

Returns an error if discovery fails, a refspec is invalid, or negotiation / pack ingest / ref I/O fails.