diff options
| author | Carlos Martín Nieto <cmn@dwim.me> | 2013-09-16 05:10:55 +0200 |
|---|---|---|
| committer | Carlos Martín Nieto <cmn@dwim.me> | 2013-10-02 06:41:42 +0200 |
| commit | d19870d947eef17008ae0b4b7ebc9e9d0038a770 (patch) | |
| tree | 48566589f6270d15d92507842e8f9eda32e19c03 /tests-clar/online/clone.c | |
| parent | e3c131c544bc79573ebefab4931b5ca89836ace1 (diff) | |
| download | libgit2-d19870d947eef17008ae0b4b7ebc9e9d0038a770.tar.gz | |
clone: implement git_clone_into
This allows you to set up the repository and remote as you which to
have them before performing the clone operation.
Diffstat (limited to 'tests-clar/online/clone.c')
| -rw-r--r-- | tests-clar/online/clone.c | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/tests-clar/online/clone.c b/tests-clar/online/clone.c index b82cbcd46..9a64ba166 100644 --- a/tests-clar/online/clone.c +++ b/tests-clar/online/clone.c @@ -126,6 +126,45 @@ void test_online_clone__can_checkout_a_cloned_repo(void) git_buf_free(&path); } +void test_online_clone__clone_into(void) +{ + git_buf path = GIT_BUF_INIT; + git_remote *remote; + git_reference *head; + git_checkout_opts checkout_opts = GIT_CHECKOUT_OPTS_INIT; + git_remote_callbacks callbacks = GIT_REMOTE_CALLBACKS_INIT; + + bool checkout_progress_cb_was_called = false, + fetch_progress_cb_was_called = false; + + checkout_opts.checkout_strategy = GIT_CHECKOUT_SAFE_CREATE; + checkout_opts.progress_cb = &checkout_progress; + checkout_opts.progress_payload = &checkout_progress_cb_was_called; + + cl_git_pass(git_repository_init(&g_repo, "./foo", false)); + cl_git_pass(git_remote_create(&remote, g_repo, "origin", LIVE_REPO_URL)); + + callbacks.transfer_progress = &fetch_progress; + callbacks.payload = &fetch_progress_cb_was_called; + git_remote_set_callbacks(remote, &callbacks); + + cl_git_pass(git_clone_into(g_repo, remote, &checkout_opts, NULL)); + + cl_git_pass(git_buf_joinpath(&path, git_repository_workdir(g_repo), "master.txt")); + cl_assert_equal_i(true, git_path_isfile(git_buf_cstr(&path))); + + cl_git_pass(git_reference_lookup(&head, g_repo, "HEAD")); + cl_assert_equal_i(GIT_REF_SYMBOLIC, git_reference_type(head)); + cl_assert_equal_s("refs/heads/master", git_reference_symbolic_target(head)); + + cl_assert_equal_i(true, checkout_progress_cb_was_called); + cl_assert_equal_i(true, fetch_progress_cb_was_called); + + git_remote_free(remote); + git_reference_free(head); + git_buf_free(&path); +} + static int update_tips(const char *refname, const git_oid *a, const git_oid *b, void *payload) { int *callcount = (int*)payload; |
