Update git2 to 0.7.0
authorAlex Crichton <alex@alexcrichton.com>
Tue, 27 Feb 2018 13:14:38 +0000 (05:14 -0800)
committerAlex Crichton <alex@alexcrichton.com>
Tue, 27 Feb 2018 14:24:26 +0000 (06:24 -0800)
cc #5066

Cargo.toml
src/cargo/ops/cargo_package.rs
src/cargo/sources/git/utils.rs
src/cargo/sources/path.rs
tests/testsuite/build_auth.rs
tests/testsuite/cargotest/Cargo.toml
tests/testsuite/cargotest/support/git.rs

index eef7aae39fe1fc79cb7e7dbb49ca35bdd774c67c..ec9f99c2c9d048d4c27a9abe1da93b04c30eb3c9 100644 (file)
@@ -28,8 +28,8 @@ failure = "0.1.1"
 filetime = "0.1"
 flate2 = "1.0"
 fs2 = "0.4"
-git2 = "0.6.11"
-git2-curl = "0.7"
+git2 = "0.7.0"
+git2-curl = "0.8"
 glob = "0.2"
 hex = "0.3"
 home = "0.3"
@@ -37,7 +37,7 @@ ignore = "0.4"
 jobserver = "0.1.9"
 lazycell = "0.6"
 libc = "0.2"
-libgit2-sys = "0.6"
+libgit2-sys = "0.7"
 log = "0.4"
 num_cpus = "1.0"
 same-file = "1"
@@ -91,4 +91,4 @@ doc = false
 
 [[test]]
 name = "testsuite"
-path = "tests/testsuite/lib.rs"
\ No newline at end of file
+path = "tests/testsuite/lib.rs"
index 0dc3aedd5dc634d34f379e94a4fb4db22cc78ee1..c53bc477b9aeb69f3829df115ec85070df20ed2c 100644 (file)
@@ -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
             }
index 1958500dff9e648f0ba7447ee6d6fe64072e2f83..52101f0b62266d571d0af062292481d0e43d8b57 100644 (file)
@@ -431,7 +431,7 @@ fn with_authentication<T, F>(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<T, F>(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<T, F>(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<T, F>(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<T, F>(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 {
index f24909ef92910688c14740cbba7c162019347a0b..fa7fc13455ae8e5fd51979ddea32aed2171be75e 100644 (file)
@@ -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,
             }
         });
index 83ae62c2ba6acc9227f3f1a5dbc092f5dda78305..2fe1db7e72a96b5bc41e42dcbf01c62119f84ade 100644 (file)
@@ -30,11 +30,7 @@ fn http_auth_offered() {
     let t = thread::spawn(move|| {
         let mut conn = BufStream::new(server.accept().unwrap().0);
         let req = headers(&mut conn);
-        let user_agent = if cfg!(windows) {
-            "User-Agent: git/1.0 (libgit2 0.26.0)"
-        } else {
-            "User-Agent: git/2.0 (libgit2 0.26.0)"
-        };
+        let user_agent = "User-Agent: git/2.0 (libgit2 0.27.0)";
         conn.write_all(b"\
             HTTP/1.1 401 Unauthorized\r\n\
             WWW-Authenticate: Basic realm=\"wheee\"\r\n
index a4a7c7e7fa5937845875bddd9309007008f12f23..c02c441fd688e0540b41fa99e9bdec5ec9d1480f 100644 (file)
@@ -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"
index 0fe2db676dccd52a08cd36c49c450fa91dd08f05..43a188dddd4762e9d657c467a56e47168fe18636 100644 (file)
@@ -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}
     }))));