diff options
| author | Edward Thomson <ethomson@edwardthomson.com> | 2022-09-19 10:31:25 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-09-19 10:31:25 +0100 |
| commit | 44b824854a0cf534202fa6cb8ba1c71225c32a63 (patch) | |
| tree | ce3d45add210738c6da64c430fc76a75fd3ad9b7 /tests/libgit2/online | |
| parent | d111cc9b62eafe036dd9ac3ba462f0165db5f52a (diff) | |
| parent | cf326948b13e066db18f86d3ea8a68916f972a2d (diff) | |
| download | libgit2-44b824854a0cf534202fa6cb8ba1c71225c32a63.tar.gz | |
Merge pull request #6369 from torvalds/main
Don't fail the whole clone if you can't find a default branch
Diffstat (limited to 'tests/libgit2/online')
| -rw-r--r-- | tests/libgit2/online/clone.c | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/tests/libgit2/online/clone.c b/tests/libgit2/online/clone.c index 585d30311..96ff66ae0 100644 --- a/tests/libgit2/online/clone.c +++ b/tests/libgit2/online/clone.c @@ -21,6 +21,7 @@ static git_clone_options g_options; static char *_remote_url = NULL; static char *_remote_user = NULL; static char *_remote_pass = NULL; +static char *_remote_branch = NULL; static char *_remote_sslnoverify = NULL; static char *_remote_ssh_pubkey = NULL; static char *_remote_ssh_privkey = NULL; @@ -69,6 +70,7 @@ void test_online_clone__initialize(void) _remote_url = cl_getenv("GITTEST_REMOTE_URL"); _remote_user = cl_getenv("GITTEST_REMOTE_USER"); _remote_pass = cl_getenv("GITTEST_REMOTE_PASS"); + _remote_branch = cl_getenv("GITTEST_REMOTE_BRANCH"); _remote_sslnoverify = cl_getenv("GITTEST_REMOTE_SSL_NOVERIFY"); _remote_ssh_pubkey = cl_getenv("GITTEST_REMOTE_SSH_PUBKEY"); _remote_ssh_privkey = cl_getenv("GITTEST_REMOTE_SSH_KEY"); @@ -102,6 +104,7 @@ void test_online_clone__cleanup(void) git__free(_remote_url); git__free(_remote_user); git__free(_remote_pass); + git__free(_remote_branch); git__free(_remote_sslnoverify); git__free(_remote_ssh_pubkey); git__free(_remote_ssh_privkey); @@ -1016,3 +1019,42 @@ void test_online_clone__redirect_initial_fails_for_subsequent(void) cl_git_fail(git_clone(&g_repo, _remote_redirect_subsequent, "./fail", &options)); } + +void test_online_clone__namespace_bare(void) +{ + git_clone_options options = GIT_CLONE_OPTIONS_INIT; + git_reference *head; + + if (!_remote_url) + cl_skip(); + + options.bare = true; + + cl_git_pass(git_clone(&g_repo, _remote_url, "./namespaced.git", &options)); + + cl_git_pass(git_reference_lookup(&head, g_repo, GIT_HEAD_FILE)); + cl_assert_equal_i(GIT_REFERENCE_SYMBOLIC, git_reference_type(head)); + cl_assert_equal_s("refs/heads/master", git_reference_symbolic_target(head)); + + git_reference_free(head); +} + +void test_online_clone__namespace_with_specified_branch(void) +{ + git_clone_options options = GIT_CLONE_OPTIONS_INIT; + git_reference *head; + + if (!_remote_url || !_remote_branch) + cl_skip(); + + options.checkout_branch = _remote_branch; + + cl_git_pass(git_clone(&g_repo, _remote_url, "./namespaced", &options)); + + cl_git_pass(git_reference_lookup(&head, g_repo, GIT_HEAD_FILE)); + cl_assert_equal_i(GIT_REFERENCE_SYMBOLIC, git_reference_type(head)); + cl_assert_equal_strn("refs/heads/", git_reference_symbolic_target(head), 11); + cl_assert_equal_s(_remote_branch, git_reference_symbolic_target(head) + 11); + + git_reference_free(head); +} |
