diff options
| author | Edward Thomson <ethomson@edwardthomson.com> | 2020-07-13 10:05:04 +0100 |
|---|---|---|
| committer | Edward Thomson <ethomson@edwardthomson.com> | 2020-08-03 11:53:20 +0100 |
| commit | 471ed794d8bc8ce783964eda180c21234b2fe591 (patch) | |
| tree | 225a1f117c1e4714c94208a50fa8993e20f1e26f /tests | |
| parent | 84d2a0353d3934e88b08095e0100a408c4b0a42e (diff) | |
| download | libgit2-471ed794d8bc8ce783964eda180c21234b2fe591.tar.gz | |
clone: respect init.defaultBranch when empty
When cloning an empty repository, we need to guess what the branch
structure should be; instead of hardcoding `master`, use the
`init.defaultBranch` setting it if it provided.
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/clone/empty.c | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/tests/clone/empty.c b/tests/clone/empty.c index 8e59d2b8c..94847bc73 100644 --- a/tests/clone/empty.c +++ b/tests/clone/empty.c @@ -2,6 +2,7 @@ #include "git2/clone.h" #include "repository.h" +#include "repo/repo_helpers.h" static git_clone_options g_options; static git_repository *g_repo; @@ -22,6 +23,7 @@ void test_clone_empty__initialize(void) void test_clone_empty__cleanup(void) { + cl_fixture_cleanup("tmp_global_path"); cl_git_sandbox_cleanup(); } @@ -66,6 +68,21 @@ void test_clone_empty__can_clone_an_empty_local_repo_barely(void) expected_tracked_branch_name)); } +void test_clone_empty__respects_initialbranch_config(void) +{ + git_buf buf = GIT_BUF_INIT; + + create_tmp_global_config("tmp_global_path", "init.defaultbranch", "my_default_branch"); + + cl_set_cleanup(&cleanup_repository, "./empty"); + + g_options.bare = true; + cl_git_pass(git_clone(&g_repo_cloned, "./empty_bare.git", "./empty", &g_options)); + cl_git_pass(git_branch_upstream_name(&buf, g_repo_cloned, "refs/heads/my_default_branch")); + cl_assert_equal_s("refs/remotes/origin/my_default_branch", buf.ptr); + git_buf_dispose(&buf); +} + void test_clone_empty__can_clone_an_empty_local_repo(void) { cl_set_cleanup(&cleanup_repository, "./empty"); |
