Struct git_repository::Remote

source ·
pub struct Remote<'repo> { /* private fields */ }
Expand description

A remote which represents a way to interact with hosts for remote clones of the parent repository.

Implementations

Builder methods

Set the url to be used when pushing data to a remote.

Set the url to be used when pushing data to a remote, without applying rewrite rules in case these could be faulty, eliminating one failure mode.

Add spec as refspec for direction to our list if it’s unique.

Establishing connections to remote hosts (without performing a git-handshake).

Available on crate features async-network-client or blocking-network-client only.

Create a new connection using transport to communicate, with progress to indicate changes.

Note that this method expects the transport to be created by the user, which would involve the url(). It’s meant to be used when async operation is needed with runtimes of the user’s choice.

Available on (crate features async-network-client or blocking-network-client) and (crate features blocking-network-client or async-network-client-async-std) only.

Connect to the url suitable for direction and return a handle through which operations can be performed.

Note that the protocol.version configuration key affects the transport protocol used to connect, with 2 being the default.

The transport used for connection can be configured via transport_mut().configure() assuming the actually used transport is well known. If that’s not the case, the transport can be created by hand and passed to to_connection_with_transport().

Available on crate features async-network-client or blocking-network-client only.

Produce the sanitized URL and protocol version to use as obtained by querying the repository configuration.

This can be useful when using custom transports to allow additional configuration.

Serialize into git-config.

Save ourselves to the given config if we are a named remote or fail otherwise.

Note that all sections named remote "<name>" will be cleared of all values we are about to write, and the last remote "<name>" section will be containing all relevant values so that reloading the remote from config would yield the same in-memory state.

Forcefully set our name to name and write our state to config similar to save_to().

Note that this sets a name for anonymous remotes, but overwrites the name for those who were named before. If this name is different from the current one, the git configuration will still contain the previous name, and the caller should account for that.

Access

Return the name of this remote or None if it wasn’t persisted to disk yet.

Return our repository reference.

Return the set of ref-specs used for direction, which may be empty, in order of occurrence in the configuration.

Return the url used for the given direction with rewrites from url.<base>.insteadOf|pushInsteadOf, unless the instance was created with one of the _without_url_rewrite() methods. For pushing, this is the remote.<name>.pushUrl or the remote.<name>.url used for fetching, and for fetching it’s the remote.<name>.url. Note that it’s possible to only have the push url set, in which case there will be no way to fetch from the remote as the push-url isn’t used for that.

Modification

Read url.<base>.insteadOf|pushInsteadOf configuration variables and apply them to our urls, changing them in place.

This happens only once, and one if them may be changed even when reporting an error. If both urls fail, only the first error (for fetch urls) is reported.

Replace all currently set refspecs, typically from configuration, with the given specs for direction, or None if one of the input specs could not be parsed.

Trait Implementations

Returns a copy of the value. Read more
Performs copy-assignment from source. Read more
Formats the value using the given formatter. Read more
This method tests for self and other values to be equal, and is used by ==. Read more
This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

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

The alignment of pointer.
The type for initializers.
Initializes a with the given initializer. Read more
Dereferences the given pointer. Read more
Mutably dereferences the given pointer. Read more
Drops the object pointed to by the given pointer. Read more
Should always be Self
The resulting type after obtaining ownership.
Creates owned data from borrowed data, usually by cloning. Read more
Uses borrowed data to replace owned data, usually by cloning. Read more
The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.