Skip to content

Commit bb927ce

Browse files
committed
Auto merge of #5091 - alexcrichton:update-git2, r=matklad
Update git2 to 0.7.0 cc #5066
2 parents 3361918 + a85c917 commit bb927ce

File tree

7 files changed

+16
-20
lines changed

7 files changed

+16
-20
lines changed

Cargo.toml

+4-4
Original file line numberDiff line numberDiff line change
@@ -28,16 +28,16 @@ failure = "0.1.1"
2828
filetime = "0.1"
2929
flate2 = "1.0"
3030
fs2 = "0.4"
31-
git2 = "0.6.11"
32-
git2-curl = "0.7"
31+
git2 = "0.7.0"
32+
git2-curl = "0.8"
3333
glob = "0.2"
3434
hex = "0.3"
3535
home = "0.3"
3636
ignore = "0.4"
3737
jobserver = "0.1.9"
3838
lazycell = "0.6"
3939
libc = "0.2"
40-
libgit2-sys = "0.6"
40+
libgit2-sys = "0.7"
4141
log = "0.4"
4242
num_cpus = "1.0"
4343
same-file = "1"
@@ -91,4 +91,4 @@ doc = false
9191

9292
[[test]]
9393
name = "testsuite"
94-
path = "tests/testsuite/lib.rs"
94+
path = "tests/testsuite/lib.rs"

src/cargo/ops/cargo_package.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ fn check_not_dirty(p: &Package, src: &PathSource) -> CargoResult<()> {
146146
let path = p.manifest_path();
147147
let path = path.strip_prefix(workdir).unwrap_or(path);
148148
if let Ok(status) = repo.status_file(path) {
149-
if (status & git2::STATUS_IGNORED).is_empty() {
149+
if (status & git2::Status::IGNORED).is_empty() {
150150
debug!("Cargo.toml found in repo, checking if dirty");
151151
return git(p, src, &repo)
152152
}
@@ -165,7 +165,7 @@ fn check_not_dirty(p: &Package, src: &PathSource) -> CargoResult<()> {
165165
let dirty = src.list_files(p)?.iter().filter(|file| {
166166
let relative = file.strip_prefix(workdir).unwrap();
167167
if let Ok(status) = repo.status_file(relative) {
168-
status != git2::STATUS_CURRENT
168+
status != git2::Status::CURRENT
169169
} else {
170170
false
171171
}

src/cargo/sources/git/utils.rs

+6-6
Original file line numberDiff line numberDiff line change
@@ -431,7 +431,7 @@ fn with_authentication<T, F>(url: &str, cfg: &git2::Config, mut f: F)
431431
// usernames during one authentication session with libgit2, so to
432432
// handle this we bail out of this authentication session after setting
433433
// the flag `ssh_username_requested`, and then we handle this below.
434-
if allowed.contains(git2::USERNAME) {
434+
if allowed.contains(git2::CredentialType::USERNAME) {
435435
debug_assert!(username.is_none());
436436
ssh_username_requested = true;
437437
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)
445445
// If we get called with this then the only way that should be possible
446446
// is if a username is specified in the URL itself (e.g. `username` is
447447
// Some), hence the unwrap() here. We try custom usernames down below.
448-
if allowed.contains(git2::SSH_KEY) && !tried_sshkey {
448+
if allowed.contains(git2::CredentialType::SSH_KEY) && !tried_sshkey {
449449
// If ssh-agent authentication fails, libgit2 will keep
450450
// calling this callback asking for other authentication
451451
// methods to try. Make sure we only try ssh-agent once,
@@ -462,15 +462,15 @@ fn with_authentication<T, F>(url: &str, cfg: &git2::Config, mut f: F)
462462
// but we currently don't! Right now the only way we support fetching a
463463
// plaintext password is through the `credential.helper` support, so
464464
// fetch that here.
465-
if allowed.contains(git2::USER_PASS_PLAINTEXT) {
465+
if allowed.contains(git2::CredentialType::USER_PASS_PLAINTEXT) {
466466
let r = git2::Cred::credential_helper(cfg, url, username);
467467
cred_helper_bad = Some(r.is_err());
468468
return r
469469
}
470470

471471
// I'm... not sure what the DEFAULT kind of authentication is, but seems
472472
// easy to support?
473-
if allowed.contains(git2::DEFAULT) {
473+
if allowed.contains(git2::CredentialType::DEFAULT) {
474474
return git2::Cred::default()
475475
}
476476

@@ -507,10 +507,10 @@ fn with_authentication<T, F>(url: &str, cfg: &git2::Config, mut f: F)
507507
// we bail out.
508508
let mut attempts = 0;
509509
res = f(&mut |_url, username, allowed| {
510-
if allowed.contains(git2::USERNAME) {
510+
if allowed.contains(git2::CredentialType::USERNAME) {
511511
return git2::Cred::username(&s);
512512
}
513-
if allowed.contains(git2::SSH_KEY) {
513+
if allowed.contains(git2::CredentialType::SSH_KEY) {
514514
debug_assert_eq!(Some(&s[..]), username);
515515
attempts += 1;
516516
if attempts == 1 {

src/cargo/sources/path.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -327,7 +327,7 @@ impl<'cfg> PathSource<'cfg> {
327327
let statuses = repo.statuses(Some(&mut opts))?;
328328
let untracked = statuses.iter().filter_map(|entry| {
329329
match entry.status() {
330-
git2::STATUS_WT_NEW => Some((join(root, entry.path_bytes()), None)),
330+
git2::Status::WT_NEW => Some((join(root, entry.path_bytes()), None)),
331331
_ => None,
332332
}
333333
});

tests/testsuite/build_auth.rs

+1-5
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,7 @@ fn http_auth_offered() {
3030
let t = thread::spawn(move|| {
3131
let mut conn = BufStream::new(server.accept().unwrap().0);
3232
let req = headers(&mut conn);
33-
let user_agent = if cfg!(windows) {
34-
"User-Agent: git/1.0 (libgit2 0.26.0)"
35-
} else {
36-
"User-Agent: git/2.0 (libgit2 0.26.0)"
37-
};
33+
let user_agent = "User-Agent: git/2.0 (libgit2 0.27.0)";
3834
conn.write_all(b"\
3935
HTTP/1.1 401 Unauthorized\r\n\
4036
WWW-Authenticate: Basic realm=\"wheee\"\r\n

tests/testsuite/cargotest/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ path = "lib.rs"
1010
cargo = { path = "../../.." }
1111
filetime = "0.1"
1212
flate2 = "1.0"
13-
git2 = { version = "0.6", default-features = false }
13+
git2 = { version = "0.7", default-features = false }
1414
hamcrest = "=0.1.1"
1515
hex = "0.3"
1616
log = "0.4"

tests/testsuite/cargotest/support/git.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ pub fn add(repo: &git2::Repository) {
9797
t!(submodule.add_to_index(false));
9898
}
9999
let mut index = t!(repo.index());
100-
t!(index.add_all(["*"].iter(), git2::ADD_DEFAULT,
100+
t!(index.add_all(["*"].iter(), git2::IndexAddOption::DEFAULT,
101101
Some(&mut (|a, _b| {
102102
if s.iter().any(|s| a.starts_with(s.path())) {1} else {0}
103103
}))));

0 commit comments

Comments
 (0)