diff --git a/Cargo.toml b/Cargo.toml index e6b8e7de2..04c9ed26a 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -32,7 +32,7 @@ pretty_env_logger = { version = "0.4", optional = true } anyhow = "1.0" filetime = "0.2.9" flate2 = { version = "1.0.3", default-features = false, features = ["zlib"] } -git2 = "0.13.5" +git2 = "0.13.12" git2-curl = "0.14.0" glob = "0.3.0" hex = "0.4" @@ -44,7 +44,7 @@ jobserver = "0.1.21" lazycell = "1.2.0" libc = "0.2" log = "0.4.6" -libgit2-sys = "0.12.7" +libgit2-sys = "0.12.14" memchr = "2.1.3" num_cpus = "1.0" opener = "0.4" diff --git a/tests/testsuite/new.rs b/tests/testsuite/new.rs index 32dbafe98..6ea777eea 100644 --- a/tests/testsuite/new.rs +++ b/tests/testsuite/new.rs @@ -602,3 +602,26 @@ If you need a crate name to not match the directory name, consider using --name ) .run(); } + +#[cargo_test] +fn git_default_branch() { + // Check for init.defaultBranch support. + create_empty_gitconfig(); + cargo_process("new foo").env("USER", "foo").run(); + let repo = git2::Repository::open(paths::root().join("foo")).unwrap(); + let head = repo.find_reference("HEAD").unwrap(); + assert_eq!(head.symbolic_target().unwrap(), "refs/heads/master"); + + fs::write( + paths::home().join(".gitconfig"), + r#" + [init] + defaultBranch = hello + "#, + ) + .unwrap(); + cargo_process("new bar").env("USER", "foo").run(); + let repo = git2::Repository::open(paths::root().join("bar")).unwrap(); + let head = repo.find_reference("HEAD").unwrap(); + assert_eq!(head.symbolic_target().unwrap(), "refs/heads/hello"); +}