summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEdward Thomson <ethomson@edwardthomson.com>2022-09-16 18:02:22 -0400
committerEdward Thomson <ethomson@edwardthomson.com>2022-09-18 16:49:37 -0400
commit2abe3e77f05527d2cbd2ef4e85dcbdae175414ce (patch)
tree86c9a5e6464ffaf77c1838544cd54b9a40546814
parentea61c67ae6e890b2d3605c164aad49e81122f551 (diff)
downloadlibgit2-ethomson/clone_namespaced.tar.gz
clone: test for cloning a repo with namespace scopeethomson/clone_namespaced
Test that we can successfully clone a repository that is namespace scoped on the remote and does not advertise a HEAD. To do this, we must specify the branch to checkout.
-rwxr-xr-xci/test.sh2
-rw-r--r--tests/libgit2/online/clone.c23
2 files changed, 25 insertions, 0 deletions
diff --git a/ci/test.sh b/ci/test.sh
index c1e514911..0e1d39e8d 100755
--- a/ci/test.sh
+++ b/ci/test.sh
@@ -252,8 +252,10 @@ if [ -z "$SKIP_GITDAEMON_TESTS" ]; then
echo ""
export GITTEST_REMOTE_URL="git://localhost:9419/namespace.git"
+ export GITTEST_REMOTE_BRANCH="four"
run_test gitdaemon_namespace
unset GITTEST_REMOTE_URL
+ unset GITTEST_REMOTE_BRANCH
fi
if [ -z "$SKIP_PROXY_TESTS" ]; then
diff --git a/tests/libgit2/online/clone.c b/tests/libgit2/online/clone.c
index fd8fb17ea..51a76c78a 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);
@@ -1025,3 +1028,23 @@ void test_online_clone__namespace_bare(void)
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);
+}