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, and
Error::UnsupportedObjectStore (operation "fetch") before contacting the remote
when repo uses a custom OdbBuilder::primary
store: received objects are installed under the on-disk objects/ directory, which
that repository does not read.
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.
§Errors
Returns RemoteError or transport errors on failure, and
Error::UnsupportedObjectStore (operation "push") before contacting the remote
when repo uses a custom OdbBuilder::primary
store: the pack is built from the on-disk objects/ directory.
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.