#include "clar_libgit2.h"
#include "git2/clone.h"
+#include "../submodule/submodule_helpers.h"
#include "remote.h"
-#include "fileops.h"
+#include "futils.h"
#include "repository.h"
#define LIVE_REPO_URL "git://github.com/libgit2/TestGitRepository"
void test_clone_nonetwork__initialize(void)
{
git_checkout_options dummy_opts = GIT_CHECKOUT_OPTIONS_INIT;
- git_remote_callbacks dummy_callbacks = GIT_REMOTE_CALLBACKS_INIT;
+ git_fetch_options dummy_fetch = GIT_FETCH_OPTIONS_INIT;
g_repo = NULL;
g_options.version = GIT_CLONE_OPTIONS_VERSION;
g_options.checkout_opts = dummy_opts;
g_options.checkout_opts.checkout_strategy = GIT_CHECKOUT_SAFE;
- g_options.remote_callbacks = dummy_callbacks;
+ g_options.fetch_opts = dummy_fetch;
}
void test_clone_nonetwork__cleanup(void)
cl_git_pass(git_buf_joinpath(&path, git_repository_workdir(g_repo), "master.txt"));
cl_assert_equal_i(false, git_path_isfile(git_buf_cstr(&path)));
- git_buf_free(&path);
+ git_buf_dispose(&path);
}
void test_clone_nonetwork__can_checkout_given_branch(void)
{
+ git_reference *remote_head;
+
g_options.checkout_branch = "test";
cl_git_pass(git_clone(&g_repo, cl_git_fixture_url("testrepo.git"), "./foo", &g_options));
cl_assert_equal_s(git_reference_name(g_ref), "refs/heads/test");
cl_assert(git_path_exists("foo/readme.txt"));
+
+ cl_git_pass(git_reference_lookup(&remote_head, g_repo, "refs/remotes/origin/HEAD"));
+ cl_assert_equal_i(GIT_REFERENCE_SYMBOLIC, git_reference_type(remote_head));
+ cl_assert_equal_s("refs/remotes/origin/master", git_reference_symbolic_target(remote_head));
+
+ git_reference_free(remote_head);
}
static int clone_cancel_fetch_transfer_progress_cb(
- const git_transfer_progress *stats, void *data)
+ const git_indexer_progress *stats, void *data)
{
GIT_UNUSED(stats); GIT_UNUSED(data);
return -54321;
{
g_options.checkout_branch = "test";
- g_options.remote_callbacks.transfer_progress =
+ g_options.fetch_opts.callbacks.transfer_progress =
clone_cancel_fetch_transfer_progress_cb;
cl_git_fail_with(git_clone(
memset(&entry, 0, sizeof(git_index_entry));
entry.path = file_path;
entry.mode = GIT_FILEMODE_BLOB;
- cl_git_pass(git_odb_write(&entry.id, odb, file_content, strlen(file_content), GIT_OBJ_BLOB));
+ cl_git_pass(git_odb_write(&entry.id, odb, file_content, strlen(file_content), GIT_OBJECT_BLOB));
cl_git_pass(git_index_add(index, &entry));
cl_git_pass(git_index_write_tree_to(&tree_id, index, stage));
{
git_reflog *log;
const git_reflog_entry *entry;
- char expected_log_message[128] = {0};
+ git_buf expected_message = GIT_BUF_INIT;
- sprintf(expected_log_message, "clone: from %s", cl_git_fixture_url("testrepo.git"));
+ git_buf_printf(&expected_message,
+ "clone: from %s", cl_git_fixture_url("testrepo.git"));
cl_git_pass(git_reflog_read(&log, g_repo, name));
cl_assert_equal_i(1, git_reflog_entrycount(log));
entry = git_reflog_entry_byindex(log, 0);
- cl_assert_equal_s(expected_log_message, git_reflog_entry_message(entry));
+ cl_assert_equal_s(expected_message.ptr, git_reflog_entry_message(entry));
git_reflog_free(log);
+
+ git_buf_dispose(&expected_message);
}
void test_clone_nonetwork__clone_updates_reflog_properly(void)