Skip to content

Commit 731f793

Browse files
committed
Update to rust master
1 parent 106cc43 commit 731f793

File tree

4 files changed

+10
-12
lines changed

4 files changed

+10
-12
lines changed

examples/clone.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ fn run(args: &Args) -> Result<(), git2::Error> {
8585
let mut co = CheckoutBuilder::new();
8686
co.progress(|path, cur, total| {
8787
let mut state = state.borrow_mut();
88-
state.path = Path::new(path.unwrap_or(&[]));
88+
state.path = Path::new(path);
8989
state.current = cur;
9090
state.total = total;
9191
print(&mut *state);

src/build.rs

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ pub struct CheckoutBuilder<'cb> {
3939
///
4040
/// The first argument is the path for the notification, the next is the numver
4141
/// of completed steps so far, and the final is the total number of steps.
42-
pub type Progress<'a> = FnMut(Option<&[u8]>, uint, uint) + 'a;
42+
pub type Progress<'a> = FnMut(&[u8], uint, uint) + 'a;
4343

4444
impl<'cb> RepoBuilder<'cb> {
4545
/// Creates a new repository builder with all of the default configuration.
@@ -375,7 +375,7 @@ impl<'cb> CheckoutBuilder<'cb> {
375375

376376
/// Set a callback to receive notifications of checkout progress.
377377
pub fn progress<F>(&mut self, cb: F) -> &mut CheckoutBuilder<'cb>
378-
where F: FnMut(Option<&[u8]>, uint, uint) + 'cb {
378+
where F: FnMut(&[u8], uint, uint) + 'cb {
379379
self.progress = Some(box cb as Box<Progress<'cb>>);
380380
self
381381
}
@@ -430,13 +430,9 @@ extern fn progress_cb(path: *const c_char,
430430
Some(ref mut c) => c,
431431
None => return,
432432
};
433-
let path = if path.is_null() {
434-
None
435-
} else {
436-
Some(CString::new(path, false))
437-
};
433+
let path = CString::new(path, false);
438434
panic::wrap(|| {
439-
callback.call_mut((path.as_ref().map(|p| p.as_bytes_no_nul()),
435+
callback.call_mut((path.as_bytes_no_nul(),
440436
completed as uint, total as uint));
441437
});
442438
}

src/remote_callbacks.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,8 @@ enum ProgressState {
3535
/// * `username_from_url` - the username that was embedded in the url, or `None`
3636
/// if it was not included.
3737
/// * `allowed_types` - a bitmask stating which cred types are ok to return.
38-
pub type Credentials<'a> = FnMut(&str, Option<&str>, CredentialType)
38+
// FIXME: the second &str should be Option<&str> but that currently ICEs
39+
pub type Credentials<'a> = FnMut(&str, &str, CredentialType)
3940
-> Result<Cred, Error> + 'a;
4041

4142
/// Callback to be invoked while a transfer is in progress.
@@ -68,7 +69,7 @@ impl<'a> RemoteCallbacks<'a> {
6869

6970
/// The callback through which to fetch credentials if required.
7071
pub fn credentials<F>(&mut self, cb: F) -> &mut RemoteCallbacks<'a>
71-
where F: FnMut(&str, Option<&str>, CredentialType)
72+
where F: FnMut(&str, &str, CredentialType)
7273
-> Result<Cred, Error> + 'a
7374
{
7475
self.credentials = Some(box cb as Box<Credentials<'a>>);
@@ -219,6 +220,7 @@ extern fn credentials_cb(ret: *mut *mut raw::git_cred,
219220
},
220221
None => None,
221222
};
223+
let username_from_url = username_from_url.unwrap_or("");
222224

223225
let cred_type = CredentialType::from_bits_truncate(allowed_types as uint);
224226
match panic::wrap(|| {

src/submodule.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -239,7 +239,7 @@ mod tests {
239239

240240
let mut submodules = repo.submodules().unwrap();
241241
assert_eq!(submodules.len(), 2);
242-
let mut s = submodules.remove(0).unwrap();
242+
let mut s = submodules.remove(0);
243243
assert_eq!(s.name(), Some("bar"));
244244
assert_eq!(s.url(), Some("/path/to/nowhere"));
245245
assert_eq!(s.branch(), None);

0 commit comments

Comments
 (0)