Skip to main content

Module push

Module push 

Source
Expand description

Wire-protocol push orchestration over a crate::transport::Connection.

push_remote is the wire counterpart to crate::transfer::push_local: instead of copying objects between two on-disk repositories, it drives a git-receive-pack exchange over a live crate::transport::Connection — reading the receive-pack advertisement (remote refs + .have lines + capabilities), deciding each ref update against the advertised remote refs (reusing the same fast-forward / force / force-with-lease rules as push_local), building the minimal pack with crate::transfer::build_pack (using the advertised remote tips + .haves as the negotiation haves), streaming it, and parsing the report-status / report-status-v2 reply into per-ref crate::push_report::PushRefResults.

This is the send-pack flow lifted from the CLI’s commands/send_pack.rs (run, report_has_rejections, demux_report_and_remote_messages), generalized to run over the crate::transport::Connection reader/writer rather than a spawned receive-pack subprocess.

Protocol v0/v1 only in this phase (the classic receive-pack advertisement). A protocol-v2 push would require the command=push round and is deferred.

The wire OID width is the repository’s hash algorithm (threaded through crate::odb::Odb::hash_algo), so SHA-256 repositories push correctly: the zero/null OID, the empty-pack trailer, and the advertisement parsing are all hash-width aware.

Functions§

push_http
Push refs to a remote over smart HTTP (git-receive-pack), returning a PushOutcome.
push_remote
Push refs to a remote over a live Connection speaking git-receive-pack.