[][src]Struct git2::Remote

pub struct Remote<'repo> { /* fields omitted */ }

A structure representing a remote of a git repository.

The lifetime is the lifetime of the repository that it is attached to. The remote is used to manage fetches and pushes as well as refspecs.


impl<'repo> Remote<'repo>[src]

pub fn is_valid_name(remote_name: &str) -> bool[src]

Ensure the remote name is well-formed.

pub fn name(&self) -> Option<&str>[src]

Get the remote's name.

Returns None if this remote has not yet been named or if the name is not valid utf-8

pub fn name_bytes(&self) -> Option<&[u8]>[src]

Get the remote's name, in bytes.

Returns None if this remote has not yet been named

pub fn url(&self) -> Option<&str>[src]

Get the remote's url.

Returns None if the url is not valid utf-8

pub fn url_bytes(&self) -> &[u8][src]

Get the remote's url as a byte array.

pub fn pushurl(&self) -> Option<&str>[src]

Get the remote's pushurl.

Returns None if the pushurl is not valid utf-8

pub fn pushurl_bytes(&self) -> Option<&[u8]>[src]

Get the remote's pushurl as a byte array.

pub fn connect(&mut self, dir: Direction) -> Result<(), Error>[src]

Open a connection to a remote.

pub fn connect_auth<'connection, 'cb>(
    &'connection mut self,
    dir: Direction,
    cb: Option<RemoteCallbacks<'cb>>,
    proxy_options: Option<ProxyOptions<'cb>>
) -> Result<RemoteConnection<'repo, 'connection, 'cb>, Error>

Open a connection to a remote with callbacks and proxy settings

Returns a RemoteConnection that will disconnect once dropped

pub fn connected(&mut self) -> bool[src]

Check whether the remote is connected

pub fn disconnect(&mut self) -> Result<(), Error>[src]

Disconnect from the remote

pub fn download<Str: AsRef<str> + IntoCString + Clone>(
    &mut self,
    specs: &[Str],
    opts: Option<&mut FetchOptions>
) -> Result<(), Error>

Download and index the packfile

Connect to the remote if it hasn't been done yet, negotiate with the remote git which objects are missing, download and index the packfile.

The .idx file will be created and both it and the packfile with be renamed to their final name.

The specs argument is a list of refspecs to use for this negotiation and download. Use an empty array to use the base refspecs.

pub fn refspecs(&self) -> Refspecs[src]

Get the number of refspecs for a remote

pub fn get_refspec(&self, i: usize) -> Option<Refspec<'repo>>[src]

Get the nth refspec from this remote.

The refspecs iterator can be used to iterate over all refspecs.

pub fn fetch<Str: AsRef<str> + IntoCString + Clone>(
    &mut self,
    refspecs: &[Str],
    opts: Option<&mut FetchOptions>,
    reflog_msg: Option<&str>
) -> Result<(), Error>

Download new data and update tips

Convenience function to connect to a remote, download the data, disconnect and update the remote-tracking branches.


Example of functionality similar to git fetch origin/master:

fn fetch_origin_master(repo: git2::Repository) -> Result<(), git2::Error> {
    repo.find_remote("origin")?.fetch(&["master"], None, None)

let repo = git2::Repository::discover("rust").unwrap();

pub fn update_tips(
    &mut self,
    callbacks: Option<&mut RemoteCallbacks>,
    update_fetchhead: bool,
    download_tags: AutotagOption,
    msg: Option<&str>
) -> Result<(), Error>

Update the tips to the new state

pub fn push<Str: AsRef<str> + IntoCString + Clone>(
    &mut self,
    refspecs: &[Str],
    opts: Option<&mut PushOptions>
) -> Result<(), Error>

Perform a push

Perform all the steps for a push. If no refspecs are passed then the configured refspecs will be used.

Note that you'll likely want to use RemoteCallbacks and set push_update_reference to test whether all the references were pushed successfully.

pub fn stats(&self) -> Progress[src]

Get the statistics structure that is filled in by the fetch operation.

pub fn list(&self) -> Result<&[RemoteHead], Error>[src]

Get the remote repository's reference advertisement list.

Get the list of references with which the server responds to a new connection.

The remote (or more exactly its transport) must have connected to the remote repository. This list is available as soon as the connection to the remote is initiated and it remains available after disconnecting.

pub fn fetch_refspecs(&self) -> Result<StringArray, Error>[src]

Get the remote's list of fetch refspecs

pub fn push_refspecs(&self) -> Result<StringArray, Error>[src]

Get the remote's list of push refspecs

Trait Implementations

impl<'repo> Clone for Remote<'repo>[src]

impl<'repo> Drop for Remote<'repo>[src]

Auto Trait Implementations

impl<'repo> RefUnwindSafe for Remote<'repo>

impl<'repo> !Send for Remote<'repo>

impl<'repo> !Sync for Remote<'repo>

impl<'repo> Unpin for Remote<'repo>

impl<'repo> UnwindSafe for Remote<'repo>

Blanket Implementations

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

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

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

impl<T> From<T> for T[src]

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

impl<T> ToOwned for T where
    T: Clone

type Owned = T

The resulting type after obtaining ownership.

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

type Error = Infallible

The type returned in the event of a conversion error.

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

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

The type returned in the event of a conversion error.