Skip to main content

fetch_remote

Function fetch_remote 

Source
pub fn fetch_remote(
    local_git_dir: &Path,
    conn: &mut dyn Connection,
    opts: &FetchOptions,
    progress: &mut dyn Progress,
) -> Result<FetchOutcome>
Expand description

Fetch from a remote over a live Connection, driving the upload-pack negotiation and writing the resulting tracking-ref updates into local_git_dir.

The flow mirrors crate::transfer::fetch_local, but the remote ref list comes from the connection’s advertisement, the objects arrive over the wire (negotiated pack -> crate::unpack_objects), and the local repo is opened to classify ancestry. Reuses the refspec matching, tag-mode, prune, and classification helpers from crate::transfer.

Handles protocol v0, v1, and v2. For a v2 connection the ref map is recovered via a command=ls-refs round (no refs are advertised on connect) and the pack is negotiated with command=fetch; v0/v1 use the connect-time advertisement and the classic want/have/done exchange.

§Errors

Returns an error if a refspec is invalid, if the negotiation or pack ingest fails, or on ref/odb I/O failure.