Skip to main content

Remote

Struct Remote 

Source
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

Source

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).

Source

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.

Source

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.

Source

pub fn fetch_url(&self) -> &RemoteUrl

Fetch URL after config rewrite (for tests and display).

Source

pub fn push_url(&self) -> &RemoteUrl

Push URL when remote.*.pushurl is set, else the fetch URL.

Source

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.

Source

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.

Source

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.

Source

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.

Trait Implementations§

Source§

impl Clone for Remote

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Remote

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.