This patch has been backported from the master branch. --- a/Cargo.toml +++ b/Cargo.toml @@ -28,15 +28,15 @@ filetime = "0.1" flate2 = "1.0" fs2 = "0.4" -git2 = "0.6" -git2-curl = "0.7" +git2 = "0.7" +git2-curl = "0.8" glob = "0.2" hex = "0.2" home = "0.3" ignore = "^0.2.2" jobserver = "0.1.6" libc = "0.2" -libgit2-sys = "0.6" +libgit2-sys = "0.7" log = "0.3" num_cpus = "1.0" same-file = "0.1" --- a/src/cargo/ops/cargo_package.rs +++ b/src/cargo/ops/cargo_package.rs @@ -146,7 +146,7 @@ fn check_not_dirty(p: &Package, src: &PathSource) -> CargoResult<()> { let path = p.manifest_path(); let path = path.strip_prefix(workdir).unwrap_or(path); if let Ok(status) = repo.status_file(path) { - if (status & git2::STATUS_IGNORED).is_empty() { + if (status & git2::Status::IGNORED).is_empty() { debug!("Cargo.toml found in repo, checking if dirty"); return git(p, src, &repo) } @@ -165,7 +165,7 @@ fn check_not_dirty(p: &Package, src: &PathSource) -> CargoResult<()> { let dirty = src.list_files(p)?.iter().filter(|file| { let relative = file.strip_prefix(workdir).unwrap(); if let Ok(status) = repo.status_file(relative) { - status != git2::STATUS_CURRENT + status != git2::Status::CURRENT } else { false } --- a/src/cargo/sources/git/utils.rs +++ b/src/cargo/sources/git/utils.rs @@ -431,7 +431,7 @@ fn with_authentication(url: &str, cfg: &git2::Config, mut f: F) // usernames during one authentication session with libgit2, so to // handle this we bail out of this authentication session after setting // the flag `ssh_username_requested`, and then we handle this below. - if allowed.contains(git2::USERNAME) { + if allowed.contains(git2::CredentialType::USERNAME) { debug_assert!(username.is_none()); ssh_username_requested = true; return Err(git2::Error::from_str("gonna try usernames later")) @@ -445,7 +445,7 @@ fn with_authentication(url: &str, cfg: &git2::Config, mut f: F) // If we get called with this then the only way that should be possible // is if a username is specified in the URL itself (e.g. `username` is // Some), hence the unwrap() here. We try custom usernames down below. - if allowed.contains(git2::SSH_KEY) && !tried_sshkey { + if allowed.contains(git2::CredentialType::SSH_KEY) && !tried_sshkey { // If ssh-agent authentication fails, libgit2 will keep // calling this callback asking for other authentication // methods to try. Make sure we only try ssh-agent once, @@ -462,7 +462,7 @@ fn with_authentication(url: &str, cfg: &git2::Config, mut f: F) // but we currently don't! Right now the only way we support fetching a // plaintext password is through the `credential.helper` support, so // fetch that here. - if allowed.contains(git2::USER_PASS_PLAINTEXT) { + if allowed.contains(git2::CredentialType::USER_PASS_PLAINTEXT) { let r = git2::Cred::credential_helper(cfg, url, username); cred_helper_bad = Some(r.is_err()); return r @@ -470,7 +470,7 @@ fn with_authentication(url: &str, cfg: &git2::Config, mut f: F) // I'm... not sure what the DEFAULT kind of authentication is, but seems // easy to support? - if allowed.contains(git2::DEFAULT) { + if allowed.contains(git2::CredentialType::DEFAULT) { return git2::Cred::default() } @@ -507,10 +507,10 @@ fn with_authentication(url: &str, cfg: &git2::Config, mut f: F) // we bail out. let mut attempts = 0; res = f(&mut |_url, username, allowed| { - if allowed.contains(git2::USERNAME) { + if allowed.contains(git2::CredentialType::USERNAME) { return git2::Cred::username(&s); } - if allowed.contains(git2::SSH_KEY) { + if allowed.contains(git2::CredentialType::SSH_KEY) { debug_assert_eq!(Some(&s[..]), username); attempts += 1; if attempts == 1 { --- a/src/cargo/sources/path.rs +++ b/src/cargo/sources/path.rs @@ -327,7 +327,7 @@ impl<'cfg> PathSource<'cfg> { let statuses = repo.statuses(Some(&mut opts))?; let untracked = statuses.iter().filter_map(|entry| { match entry.status() { - git2::STATUS_WT_NEW => Some((join(root, entry.path_bytes()), None)), + git2::Status::WT_NEW => Some((join(root, entry.path_bytes()), None)), _ => None, } }); --- a/tests/cargotest/Cargo.toml +++ b/tests/cargotest/Cargo.toml @@ -10,7 +10,7 @@ path = "lib.rs" cargo = { path = "../../.." } filetime = "0.1" flate2 = "1.0" -git2 = { version = "0.6", default-features = false } +git2 = { version = "0.7", default-features = false } hamcrest = "=0.1.1" hex = "0.3" log = "0.4" --- a/tests/cargotest/support/git.rs +++ b/tests/cargotest/support/git.rs @@ -97,7 +97,7 @@ pub fn add(repo: &git2::Repository) { t!(submodule.add_to_index(false)); } let mut index = t!(repo.index()); - t!(index.add_all(["*"].iter(), git2::ADD_DEFAULT, + t!(index.add_all(["*"].iter(), git2::IndexAddOption::DEFAULT, Some(&mut (|a, _b| { if s.iter().any(|s| a.starts_with(s.path())) {1} else {0} }))));