Struct git2::Remote [−][src]
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.
Methods
impl<'repo> Remote<'repo>
[src]
impl<'repo> Remote<'repo>
pub fn is_valid_name(remote_name: &str) -> bool
[src]
pub fn is_valid_name(remote_name: &str) -> bool
Ensure the remote name is well-formed.
pub fn name(&self) -> Option<&str>
[src]
pub fn name(&self) -> Option<&str>
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]
pub fn name_bytes(&self) -> Option<&[u8]>
Get the remote's name, in bytes.
Returns None
if this remote has not yet been named
pub fn url(&self) -> Option<&str>
[src]
pub fn url(&self) -> Option<&str>
Get the remote's url.
Returns None
if the url is not valid utf-8
pub fn url_bytes(&self) -> &[u8]
[src]
pub fn url_bytes(&self) -> &[u8]
Get the remote's url as a byte array.
pub fn pushurl(&self) -> Option<&str>
[src]
pub fn pushurl(&self) -> Option<&str>
Get the remote's pushurl.
Returns None
if the pushurl is not valid utf-8
pub fn pushurl_bytes(&self) -> Option<&[u8]>
[src]
pub fn pushurl_bytes(&self) -> Option<&[u8]>
Get the remote's pushurl as a byte array.
pub fn connect(&mut self, dir: Direction) -> Result<(), Error>
[src]
pub fn connect(&mut self, dir: Direction) -> Result<(), Error>
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>
[src]
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]
pub fn connected(&mut self) -> bool
Check whether the remote is connected
pub fn disconnect(&mut self)
[src]
pub fn disconnect(&mut self)
Disconnect from the remote
pub fn download(
&mut self,
specs: &[&str],
opts: Option<&mut FetchOptions>
) -> Result<(), Error>
[src]
pub fn download(
&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.
ⓘImportant traits for Refspecs<'repo>pub fn refspecs<'a>(&'a self) -> Refspecs<'a>
[src]
pub fn refspecs<'a>(&'a self) -> Refspecs<'a>
Get the number of refspecs for a remote
pub fn get_refspec(&self, i: usize) -> Option<Refspec<'repo>>
[src]
pub fn get_refspec(&self, i: usize) -> Option<Refspec<'repo>>
Get the nth
refspec from this remote.
The refspecs
iterator can be used to iterate over all refspecs.
pub fn fetch(
&mut self,
refspecs: &[&str],
opts: Option<&mut FetchOptions>,
reflog_msg: Option<&str>
) -> Result<(), Error>
[src]
pub fn fetch(
&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.
Examples
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(); fetch_origin_master(repo).unwrap();
pub fn update_tips(
&mut self,
callbacks: Option<&mut RemoteCallbacks>,
update_fetchhead: bool,
download_tags: AutotagOption,
msg: Option<&str>
) -> Result<(), Error>
[src]
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(
&mut self,
refspecs: &[&str],
opts: Option<&mut PushOptions>
) -> Result<(), Error>
[src]
pub fn push(
&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]
pub fn stats(&self) -> Progress
Get the statistics structure that is filled in by the fetch operation.
pub fn list(&self) -> Result<&[RemoteHead], Error>
[src]
pub fn list(&self) -> Result<&[RemoteHead], Error>
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]
pub fn fetch_refspecs(&self) -> Result<StringArray, Error>
Get the remote's list of fetch refspecs
pub fn push_refspecs(&self) -> Result<StringArray, Error>
[src]
pub fn push_refspecs(&self) -> Result<StringArray, Error>
Get the remote's list of push refspecs
Trait Implementations
impl<'repo> Clone for Remote<'repo>
[src]
impl<'repo> Clone for Remote<'repo>
fn clone(&self) -> Remote<'repo>
[src]
fn clone(&self) -> Remote<'repo>
Returns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)
1.0.0[src]
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source
. Read more
impl<'repo> Drop for Remote<'repo>
[src]
impl<'repo> Drop for Remote<'repo>