void test_clone_nonetwork__local_bare(void) { g_options.bare = true; cl_git_pass(git_clone(&g_repo, cl_git_fixture_url("testrepo.git"), "./foo", &g_options)); }
void test_clone_nonetwork__cope_with_already_existing_directory(void) { p_mkdir("./foo", GIT_DIR_MODE); cl_git_pass(git_clone(&g_repo, cl_git_fixture_url("testrepo.git"), "./foo", &g_options)); }
void test_clone_nonetwork__local_absolute_path(void) { const char *local_src; local_src = cl_fixture("testrepo.git"); cl_git_pass(git_clone(&g_repo, local_src, "./foo", &g_options)); }
void test_clone_nonetwork__fail_with_already_existing_but_non_empty_directory(void) { p_mkdir("./foo", GIT_DIR_MODE); cl_git_mkfile("./foo/bar", "Baz!"); cl_git_fail(git_clone(&g_repo, cl_git_fixture_url("testrepo.git"), "./foo", &g_options)); }
void test_clone_nonetwork__defaults(void) { cl_git_pass(git_clone(&g_repo, cl_git_fixture_url("testrepo.git"), "./foo", NULL)); cl_assert(g_repo); cl_git_pass(git_remote_load(&g_remote, g_repo, "origin")); }
void test_clone_local__hardlinks(void) { git_repository *repo; git_clone_options opts = GIT_CLONE_OPTIONS_INIT; git_buf buf = GIT_BUF_INIT; struct stat st; /* * In this first clone, we just copy over, since the temp dir * will often be in a different filesystem, so we cannot * link. It also allows us to control the number of links */ opts.bare = true; opts.local = GIT_CLONE_LOCAL_NO_LINKS; cl_git_pass(git_clone(&repo, cl_fixture("testrepo.git"), "./clone.git", &opts)); git_repository_free(repo); /* This second clone is in the same filesystem, so we can hardlink */ opts.local = GIT_CLONE_LOCAL; cl_git_pass(git_clone(&repo, cl_git_path_url("clone.git"), "./clone2.git", &opts)); #ifndef GIT_WIN32 git_buf_clear(&buf); cl_git_pass(git_buf_join_n(&buf, '/', 4, git_repository_path(repo), "objects", "08", "b041783f40edfe12bb406c9c9a8a040177c125")); cl_git_pass(p_stat(buf.ptr, &st)); cl_assert_equal_i(2, st.st_nlink); #endif git_repository_free(repo); git_buf_clear(&buf); opts.local = GIT_CLONE_LOCAL_NO_LINKS; cl_git_pass(git_clone(&repo, cl_git_path_url("clone.git"), "./clone3.git", &opts)); git_buf_clear(&buf); cl_git_pass(git_buf_join_n(&buf, '/', 4, git_repository_path(repo), "objects", "08", "b041783f40edfe12bb406c9c9a8a040177c125")); cl_git_pass(p_stat(buf.ptr, &st)); cl_assert_equal_i(1, st.st_nlink); git_repository_free(repo); /* this one should automatically use links */ cl_git_pass(git_clone(&repo, "./clone.git", "./clone4.git", NULL)); #ifndef GIT_WIN32 git_buf_clear(&buf); cl_git_pass(git_buf_join_n(&buf, '/', 4, git_repository_path(repo), "objects", "08", "b041783f40edfe12bb406c9c9a8a040177c125")); cl_git_pass(p_stat(buf.ptr, &st)); cl_assert_equal_i(3, st.st_nlink); #endif git_buf_free(&buf); git_repository_free(repo); cl_git_pass(git_futils_rmdir_r("./clone.git", NULL, GIT_RMDIR_REMOVE_FILES)); cl_git_pass(git_futils_rmdir_r("./clone2.git", NULL, GIT_RMDIR_REMOVE_FILES)); cl_git_pass(git_futils_rmdir_r("./clone3.git", NULL, GIT_RMDIR_REMOVE_FILES)); cl_git_pass(git_futils_rmdir_r("./clone4.git", NULL, GIT_RMDIR_REMOVE_FILES)); }
void test_online_clone__certificate_valid(void) { g_options.remote_callbacks.certificate_check = succeed_certificate_check; cl_git_pass(git_clone(&g_repo, "https://github.com/libgit2/TestGitRepository", "./foo", &g_options)); }
void test_online_clone__url_with_no_path_returns_EINVALIDSPEC(void) { cl_git_fail_with(git_clone(&g_repo, "http://github.com", "./foo", &g_options), GIT_EINVALIDSPEC); }
void test_online_clone__can_cancel(void) { g_options.remote_callbacks.transfer_progress = cancel_at_half; cl_git_fail_with(git_clone(&g_repo, LIVE_REPO_URL, "./foo", &g_options), GIT_EUSER); }
static void fetchhead_test_clone(void) { cl_git_pass(git_clone(&g_repo, LIVE_REPO_URL, "./foo", &g_options)); }