From 0be75d2edc1ab7eee8e74f0c06cea2e39575cdd2 Mon Sep 17 00:00:00 2001 From: Eric Huss Date: Tue, 13 Oct 2020 18:13:25 -0700 Subject: [PATCH] Update git2. --- Cargo.toml | 4 ++-- tests/testsuite/new.rs | 23 +++++++++++++++++++++++ 2 files changed, 25 insertions(+), 2 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index e6b8e7de27f..04c9ed26a68 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 32dbafe9814..6ea777eeaa8 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"); +}