pub fn push_remote(
local_git_dir: &Path,
conn: &mut dyn Connection,
refs: &[PushRefSpec],
opts: &PushOptions,
progress: &mut dyn Progress,
) -> Result<PushOutcome>Expand description
Push refs to a remote over a live Connection speaking git-receive-pack.
The flow mirrors crate::transfer::push_local, but the remote ref list and
.have hints come from the connection’s advertisement, the objects are
streamed over the wire as a single pack, and per-ref acceptance/rejection is
learned from the server’s report-status reply (a server may reject an update
our local checks would have accepted, e.g. denyNonFastForwards or a
pre-receive hook).
Steps:
- Read the receive-pack advertisement from
conn: remote refs (name -> oid),.haveoids, and capabilities (report-status(-v2),side-band-64k,ofs-delta,object-format). - Decide each
PushRefSpecagainst the advertised remote refs (up-to-date, new, fast-forward, forced, non-fast-forward rejection, force-with-lease stale) — the client-side gate before anything is sent. - Write the ref-update commands for the accepted, value-changing updates
(
<old> <new> <ref>\0<caps>\nfirst,<old> <new> <ref>\nrest), then a flush. - Build the minimal pack with
build_pack(wants = new tips, haves = advertised remote tips +.haves) and stream it; for deletion-only pushes stream the empty pack. - Read + parse
report-status/report-status-v2(demultiplexing the side-band if negotiated) and fold the per-refok/nglines back into the decided results.
progress receives the remote’s side-band channel-2 bytes (hook output,
remote: … diagnostics) when side-band-64k is negotiated.
Protocol v0/v1 only; a v2 connection is rejected.
§Errors
Returns an error if the connection is protocol v2, if a source object is missing from the local odb, if the pack build fails, or on wire/parse I/O failure.