Update the git2 dependency

It turned out most of the methods in libgit2 don't actually require a Signature
structure, they're all mostly optional. This commit updates to this version of
libgit2 where the arguments are all optional.
This commit is contained in:
Alex Crichton 2014-08-28 11:10:10 -07:00
parent 870c0f932a
commit 20e37c6a81
3 changed files with 48 additions and 17 deletions

8
Cargo.lock generated
View File

@ -5,7 +5,7 @@ dependencies = [
"docopt 0.6.0 (git+https://github.com/burntsushi/docopt.rs#fc7ba2f1a5a351f7874257d880223d2ff5c75d36)",
"docopt_macros 0.6.0 (git+https://github.com/burntsushi/docopt.rs#fc7ba2f1a5a351f7874257d880223d2ff5c75d36)",
"flate2 0.0.1 (git+https://github.com/alexcrichton/flate2-rs#12593d1b9ccf09c2eabac176a6e233b171eed843)",
"git2 0.0.1 (git+https://github.com/alexcrichton/git2-rs#16142ef9d77b9cf5615085326a571a29cba7d683)",
"git2 0.0.1 (git+https://github.com/alexcrichton/git2-rs#d83ce44b5cd9526d98187ded639475e1b6e45c9f)",
"glob 0.0.1 (git+https://github.com/rust-lang/glob#c4495d9f2f2a1b22173b860f907760ba8c419843)",
"hamcrest 0.1.0 (git+https://github.com/carllerche/hamcrest-rust.git#f0fd1546b0a7a278a12658ab8602b5c827cc3a42)",
"semver 0.0.1 (git+https://github.com/rust-lang/semver#c78b40d7fdf8acd99b503e6ce394fbcf9eb8982f)",
@ -40,9 +40,9 @@ source = "git+https://github.com/alexcrichton/flate2-rs#12593d1b9ccf09c2eabac176
[[package]]
name = "git2"
version = "0.0.1"
source = "git+https://github.com/alexcrichton/git2-rs#16142ef9d77b9cf5615085326a571a29cba7d683"
source = "git+https://github.com/alexcrichton/git2-rs#d83ce44b5cd9526d98187ded639475e1b6e45c9f"
dependencies = [
"libgit2 0.0.1 (git+https://github.com/alexcrichton/git2-rs#16142ef9d77b9cf5615085326a571a29cba7d683)",
"libgit2 0.0.1 (git+https://github.com/alexcrichton/git2-rs#d83ce44b5cd9526d98187ded639475e1b6e45c9f)",
]
[[package]]
@ -58,7 +58,7 @@ source = "git+https://github.com/carllerche/hamcrest-rust.git#f0fd1546b0a7a278a1
[[package]]
name = "libgit2"
version = "0.0.1"
source = "git+https://github.com/alexcrichton/git2-rs#16142ef9d77b9cf5615085326a571a29cba7d683"
source = "git+https://github.com/alexcrichton/git2-rs#d83ce44b5cd9526d98187ded639475e1b6e45c9f"
dependencies = [
"link-config 0.0.1 (git+https://github.com/alexcrichton/link-config#f08103ea7d2e2d3369c2c5e66b0220c8d16b92c9)",
"openssl-static-sys 0.0.1 (git+git://github.com/alexcrichton/openssl-static-sys#b8f2500c39932e9d022dcc2590493ab0cc144e2a)",

View File

@ -175,8 +175,7 @@ impl GitRemote {
let mut remote = try!(dst.remote_create_anonymous(url.as_slice(),
refspec));
try!(remote.add_fetch("refs/tags/*:refs/tags/*"));
let sig = try!(git2::Signature::default(dst));
try!(remote.fetch(&sig, None));
try!(remote.fetch(None, None));
Ok(())
}
@ -284,19 +283,16 @@ impl<'a> GitCheckout<'a> {
fn reset(&self) -> CargoResult<()> {
info!("reset {} to {}", self.repo.path().display(),
self.revision.as_slice());
let sig = try!(git2::Signature::default(&self.repo));
let oid = try!(git2::Oid::from_str(self.revision.as_slice()));
let object = try!(git2::Object::lookup(&self.repo, oid, None));
try!(self.repo.reset(&object, git2::Hard, &sig, None));
try!(self.repo.reset(&object, git2::Hard, None, None));
Ok(())
}
fn update_submodules(&self) -> CargoResult<()> {
let sig = try!(git2::Signature::default(&self.repo));
return update_submodules(&self.repo, &sig);
return update_submodules(&self.repo);
fn update_submodules(repo: &git2::Repository,
sig: &git2::Signature) -> CargoResult<()> {
fn update_submodules(repo: &git2::Repository) -> CargoResult<()> {
info!("update submodules for: {}", repo.path().display());
for mut child in try!(repo.submodules()).move_iter() {
@ -332,14 +328,14 @@ impl<'a> GitCheckout<'a> {
// Fetch data from origin and reset to the head commit
let refspec = "refs/heads/*:refs/heads/*";
let mut remote = try!(repo.remote_create_anonymous(url, refspec));
try!(remote.fetch(sig, None).chain_error(|| {
try!(remote.fetch(None, None).chain_error(|| {
internal(format!("failed to fetch submodule `{}` from {}",
child.name().unwrap_or(""), url))
}));
let obj = try!(git2::Object::lookup(&repo, head, None));
try!(repo.reset(&obj, git2::Hard, sig, None));
try!(update_submodules(&repo, sig));
try!(repo.reset(&obj, git2::Hard, None, None));
try!(update_submodules(&repo));
}
Ok(())
}

View File

@ -1,5 +1,4 @@
use std::io::File;
use std::io::timer;
use std::io::{timer, fs, File};
use std::time::Duration;
use support::{ProjectBuilder, ResultTest, project, execs, main_file, paths};
@ -1061,3 +1060,39 @@ test!(git_build_cmd_freshness {
{fresh} foo v0.0.0 ({url})
", fresh = FRESH, url = foo.url())));
})
test!(git_name_not_always_needed {
let p2 = git_repo("bar", |project| {
project.file("Cargo.toml", r#"
[package]
name = "bar"
version = "0.5.0"
authors = ["wycats@example.com"]
"#)
.file("src/lib.rs", r#"
pub fn gimme() -> &'static str { "zoidberg" }
"#)
}).assert();
fs::unlink(&paths::home().join(".gitconfig")).assert();
let p = project("foo")
.file("Cargo.toml", format!(r#"
[project]
name = "foo"
version = "0.5.0"
authors = []
[dev-dependencies.bar]
git = '{}'
"#, p2.url()).as_slice())
.file("src/main.rs", "fn main() {}");
// Generate a lockfile which did not use `bar` to compile, but had to update
// `bar` to generate the lockfile
assert_that(p.cargo_process("build"),
execs().with_stdout(format!("\
{updating} git repository `{bar}`
{compiling} foo v0.5.0 ({url})
", updating = UPDATING, compiling = COMPILING, url = p.url(), bar = p2.url())));
})