Commit cf326948 by Edward Thomson

clone: test for cloning a repo with namespace scope

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.
parent 9d9a90ad
......@@ -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
......
......@@ -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);
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment