-
Notifications
You must be signed in to change notification settings - Fork 398
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #160 from alexcrichton/update-libgit2
Update libgit2
- Loading branch information
Showing
10 changed files
with
138 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
use std::ffi::CString; | ||
use std::marker; | ||
|
||
use raw; | ||
use util::Binding; | ||
|
||
/// Options which can be specified to various fetch operations. | ||
pub struct ProxyOptions<'a> { | ||
url: Option<CString>, | ||
proxy_kind: raw::git_proxy_t, | ||
_marker: marker::PhantomData<&'a i32>, | ||
} | ||
|
||
impl<'a> ProxyOptions<'a> { | ||
/// Creates a new set of proxy options ready to be configured. | ||
pub fn new() -> ProxyOptions<'a> { | ||
ProxyOptions { | ||
url: None, | ||
proxy_kind: raw::GIT_PROXY_NONE, | ||
_marker: marker::PhantomData, | ||
} | ||
} | ||
|
||
/// Try to auto-detect the proxy from the git configuration. | ||
/// | ||
/// Note that this will override `url` specified before. | ||
pub fn auto(&mut self) -> &mut Self { | ||
self.proxy_kind = raw::GIT_PROXY_AUTO; | ||
self | ||
} | ||
|
||
/// Specify the exact URL of the proxy to use. | ||
/// | ||
/// Note that this will override `auto` specified before. | ||
pub fn url(&mut self, url: &str) -> &mut Self { | ||
self.proxy_kind = raw::GIT_PROXY_SPECIFIED; | ||
self.url = Some(CString::new(url).unwrap()); | ||
self | ||
} | ||
} | ||
|
||
impl<'a> Binding for ProxyOptions<'a> { | ||
type Raw = raw::git_proxy_options; | ||
unsafe fn from_raw(_raw: raw::git_proxy_options) -> ProxyOptions<'a> { | ||
panic!("can't create proxy from raw options") | ||
} | ||
|
||
fn raw(&self) -> raw::git_proxy_options { | ||
raw::git_proxy_options { | ||
version: raw::GIT_PROXY_OPTIONS_VERSION, | ||
kind: self.proxy_kind, | ||
url: self.url.as_ref().map(|s| s.as_ptr()).unwrap_or(0 as *const _), | ||
credentials: None, | ||
certificate_check: None, | ||
payload: 0 as *mut _, | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters