pub struct Remote {
pub name: Option<String>,
pub fetch_refspecs: Vec<String>,
/* private fields */
}Expand description
A resolved remote: name (if from config), URL(s), and fetch refspecs.
Fields§
§name: Option<String>Configured remote name, if any.
fetch_refspecs: Vec<String>Fetch refspecs (+refs/heads/*:refs/remotes/<name>/* when unset in config).
Implementations§
Source§impl Remote
impl Remote
Sourcepub const ANONYMOUS_FETCH_REFSPEC: &'static str = "refs/heads/*:"
pub const ANONYMOUS_FETCH_REFSPEC: &'static str = "refs/heads/*:"
Default refspec for Self::from_url — match Git’s anonymous fetch: download
advertised heads but do not write remote-tracking refs (only FETCH_HEAD).
Sourcepub fn from_config(config: &ConfigSet, name: &str) -> RemoteResult<Self>
pub fn from_config(config: &ConfigSet, name: &str) -> RemoteResult<Self>
Load remote.<name>.url, optional pushurl, and fetch refspecs from config.
Applies url.*.insteadOf / pushInsteadOf rewrites.
§Errors
Returns RemoteError::NoUrl when the remote has no URL.
Sourcepub fn from_url(url: &str) -> RemoteResult<Self>
pub fn from_url(url: &str) -> RemoteResult<Self>
Build a remote from a literal URL or path (not a configured remote name).
Uses Self::ANONYMOUS_FETCH_REFSPEC; callers that need tracking refs must
pass explicit FetchOptions::refspecs.
§Errors
Returns an error when url is empty or unsupported.
Sourcepub fn push_url(&self) -> &RemoteUrl
pub fn push_url(&self) -> &RemoteUrl
Push URL when remote.*.pushurl is set, else the fetch URL.
Sourcepub fn fetch(
&self,
repo: &Repository,
opts: FetchOptions,
progress: &mut dyn Progress,
cancel: &dyn Cancel,
http_factory: Option<&dyn HttpClientFactory>,
) -> RemoteResult<FetchOutcome>
pub fn fetch( &self, repo: &Repository, opts: FetchOptions, progress: &mut dyn Progress, cancel: &dyn Cancel, http_factory: Option<&dyn HttpClientFactory>, ) -> RemoteResult<FetchOutcome>
Fetch from this remote into repo.
http_factory is required for HTTP(S) remotes unless the http-ureq feature is
enabled and None is passed (then the default ureq-backed factory is used).
§Errors
Returns RemoteError or transport errors on failure. Received pack bytes are written
into the repository’s OdbBuilder::primary store
(including custom backends) via ingest_received_pack.
Sourcepub fn push(
&self,
repo: &Repository,
refs: &[PushRefSpec],
opts: PushOptions,
progress: &mut dyn Progress,
cancel: &dyn Cancel,
http_factory: Option<&dyn HttpClientFactory>,
) -> RemoteResult<PushOutcome>
pub fn push( &self, repo: &Repository, refs: &[PushRefSpec], opts: PushOptions, progress: &mut dyn Progress, cancel: &dyn Cancel, http_factory: Option<&dyn HttpClientFactory>, ) -> RemoteResult<PushOutcome>
Push refs to this remote from repo.
cancel is polled throughout: while the objects to send are walked, while the
pack is built and streamed, while a local (file:// or path) remote indexes
it, and while a smart-HTTP push waits for the server’s report. A cancel
before the objects are stored updates no remote ref and leaves no temporary
files; a cancel after a wire push sent its whole request stops waiting, but
the server may still apply the update. Remote-tracking refs are not updated
either way.
§Errors
Returns Error::Cancelled (see RemoteError::is_cancelled) once cancel
fires, or RemoteError / transport errors on failure. The pack is built from
Odb::read_store, including custom primaries.
Sourcepub fn seed_from_bundle_uri(
&self,
repo: &Repository,
cache_dir: &Path,
progress: &mut dyn Progress,
cancel: &dyn Cancel,
http_factory: Option<&dyn HttpClientFactory>,
) -> BundleSeed
pub fn seed_from_bundle_uri( &self, repo: &Repository, cache_dir: &Path, progress: &mut dyn Progress, cancel: &dyn Cancel, http_factory: Option<&dyn HttpClientFactory>, ) -> BundleSeed
Seed the empty repository repo from the bundle this remote advertises
with bundle-uri (see crate::bundle_uri::seed_from_bundle_uri).
Only smart-HTTP remotes advertise bundles; other transports, and
transfer.bundleURI=false in repo’s config, give
BundleSeed::NotOffered.
§Parameters
repo: the new repository the clone is filling.cache_dir: where bundle downloads are kept between attempts.progress: receives the download and unpack progress.cancel: checked while the bundle is downloaded and unpacked; a cancelled seed comes back asFailed, so callers checkcancelagain.http_factory: builds the HTTP client, as forSelf::fetch. Seeding is best-effort, so it uses a probe client: credentials the server refuses stay stored for the fetch that follows to report.
Sourcepub fn list_refs(
&self,
repo: Option<&Repository>,
opts: &ListRefsOptions,
http_factory: Option<&dyn HttpClientFactory>,
) -> RemoteResult<Vec<RemoteRef>>
pub fn list_refs( &self, repo: Option<&Repository>, opts: &ListRefsOptions, http_factory: Option<&dyn HttpClientFactory>, ) -> RemoteResult<Vec<RemoteRef>>
List references on this remote (all transports), matching git ls-remote ordering.
repo supplies git-dir/worktree for relative local URLs and optional ODB for peeling.
§Errors
Returns RemoteError on resolution or wire failures.
Sourcepub fn list_push_refs(
&self,
repo: &Repository,
http_factory: Option<&dyn HttpClientFactory>,
) -> RemoteResult<Vec<RemoteRef>>
pub fn list_push_refs( &self, repo: &Repository, http_factory: Option<&dyn HttpClientFactory>, ) -> RemoteResult<Vec<RemoteRef>>
List the refs a push to this remote’s push_url starts from.
Local and file:// destinations are read with one scan of every ref under refs/, the
set git receive-pack advertises (no HEAD line). Other transports return the
list_refs listing of the push URL.
§Errors
Returns RemoteError on resolution or wire failures, and
RemoteError::UnsupportedScheme for bundles.