Network operations in grit-lib center on Remote: a typed URL (RemoteUrl), configured fetch refspecs, and one dispatcher for fetch, push, and list refs. Wire bytes still flow through the same fetch/push engines as before; Remote picks the transport from the URL scheme.
Remote URL and config
| Scheme / form | RemoteUrl variant |
Transport |
|---|---|---|
Path or file:// |
Local / File |
fetch_local / push_local |
git:// |
Git |
GitDaemonTransport |
ssh://, scp-style |
Ssh |
SshTransport (repo CommandRunner) |
http(s):// |
Http / Https |
http_fetch / push_http |
Parse a literal URL with RemoteUrl::try_from. Load remote.<name>.url, optional pushurl, and fetch refspecs (default +refs/heads/*:refs/remotes/<name>/*) via Remote::from_config. Config applies url_rewrite insteadOf / pushInsteadOf rules the same way Git does.
Local paths resolve through resolve_local_remote_git_dir from the repository root, not the process cwd.
list refs
Remote::list_refs takes ListRefsOptions (prefixes, heads, tags, symrefs, peel) and returns RemoteRef entries in git ls-remote order. On disk it uses list_refs_from_git_dir. Over the wire it uses protocol v2 ls-refs when available, otherwise the v0/v1 ref advertisement.
Fetch and push
Remote::fetch accepts FetchOptions and a Progress sink; fetch negotiates protocol v2 when the server supports it. Remote::push uses PushRefSpec and returns PushOutcome.
HTTP remotes need an HttpClient. Implement HttpClientFactory or, with the http-ureq feature, pass None to use the default ureq-backed factory (UreqHttpClient + HelperCredentialProvider).
Credentials and progress
HelperCredentialProvider satisfies HTTP 401 responses from configured credential.helper programs and never opens a TTY. Pass NoProgress to ignore sideband progress, or implement Progress::message for side-band channel 2.
Bundles
Git’s bundle format combines a text header (prerequisite commits, ref tips, optional v3 capabilities) with a thin packfile. grit_lib::bundle reads and writes that format for offline transfer and tests:
Bundle(open,verify,unbundle) andread_headerparse v2/v3 headers and leave the stream at thePACKmagic.verifychecks prerequisite OIDs against the ODB and ref connectivity (matchinggit bundle verifysemantics).unbundleingests the pack via the index-pack path (fix-thin) and returns ref tips without updating refs.write_bundlebuilds v2 (SHA-1, no filter) or v3 bundles with a thin pack stream viapack_objects::build_pack.bundle_remote::fetch_from_bundleingests a bundle and applies fetch refspecs (clone/fetch from a.bundlepath).
Integration test bundle_git_compat round-trips bundles with system git bundle (verify, list-heads, clone/fetch, fsck --strict).