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)
}
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
}
// 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"))
// 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,
// 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
// 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()
}
// 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 {
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