summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPatrick Steinhardt <ps@pks.im>2019-10-17 13:32:22 +0200
committerPatrick Steinhardt <ps@pks.im>2019-10-17 13:35:30 +0200
commit09b1ac11b4ad53a9a0e7e3a2dc2cdfe4614186ea (patch)
tree7c01645d4a289205e5e223399d2420005b457fa2
parent3c5d78bd7ed1ece63409a6f1f7e6d5f216fcfc7b (diff)
downloadlibgit2-09b1ac11b4ad53a9a0e7e3a2dc2cdfe4614186ea.tar.gz
tests: submodule: fix tests for cloning submodules
The test submodule::add::homemade_clone unfortunately doesn't test what's expected, but does instead clone the submodule to a directory that is outside of the parent repository. Fixing this by cloning to the correct location isn't possible, though, as `git_submodule_add_setup` will have pre-created a ".git" file already, which will cause `git_clone` to error out. As it's not possible to perform the clone without fiddling around with the repo's layout, let's just remove this test as that is in fact what the new `git_submodule_clone` function is for.
-rw-r--r--tests/submodule/add.c52
1 files changed, 0 insertions, 52 deletions
diff --git a/tests/submodule/add.c b/tests/submodule/add.c
index d3100da86..e79d07961 100644
--- a/tests/submodule/add.c
+++ b/tests/submodule/add.c
@@ -185,58 +185,6 @@ void test_submodule_add__file_exists_in_index(void)
git_buf_dispose(&name);
}
-static int just_return_origin(git_remote **out, git_repository *repo, const char *name, const char *url, void *payload)
-{
- GIT_UNUSED(url); GIT_UNUSED(payload);
-
- return git_remote_lookup(out, repo, name);
-}
-
-static int just_return_repo(git_repository **out, const char *path, int bare, void *payload)
-{
- git_submodule *sm = payload;
-
- GIT_UNUSED(path); GIT_UNUSED(bare);
-
- return git_submodule_open(out, sm);
-}
-
-void test_submodule_add__homemade_clone(void)
-{
- git_clone_options clone_opts = GIT_CLONE_OPTIONS_INIT;
- git_index *index;
- git_oid tree_id, commit_id;
- git_submodule *sm;
- git_signature *sig;
- git_repository *sm_repo;
-
- cl_git_pass(git_repository_init(&g_repo, "willaddsubmodule", false));
-
- /* Create the submodule structure, clone into it and finalize */
- cl_git_pass(git_submodule_add_setup(&sm, g_repo, cl_fixture("testrepo.git"), "testrepo", true));
-
- clone_opts.repository_cb = just_return_repo;
- clone_opts.repository_cb_payload = sm;
- clone_opts.remote_cb = just_return_origin;
- clone_opts.remote_cb_payload = sm;
- cl_git_pass(git_clone(&sm_repo, cl_fixture("testrepo.git"), "testrepo", &clone_opts));
- cl_git_pass(git_submodule_add_finalize(sm));
- git_repository_free(sm_repo);
- git_submodule_free(sm);
-
- cl_git_pass(git_repository_index(&index, g_repo));
- cl_git_pass(git_index_write_tree(&tree_id, index));
- git_index_free(index);
-
- cl_git_pass(git_signature_now(&sig, "Submoduler", "submoduler@local"));
- cl_git_pass(git_commit_create_from_ids(&commit_id, g_repo, "HEAD", sig, sig, NULL, "A submodule\n",
- &tree_id, 0, NULL));
-
- git_signature_free(sig);
-
- assert_submodule_exists(g_repo, "testrepo");
-}
-
void test_submodule_add__submodule_clone(void)
{
git_index *index;