#include "clar_libgit2.h"
#include "git2/clone.h"
-#include "git2/sys/commit.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"
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;
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_free(log);
- git_buf_free(&expected_message);
+ git_buf_dispose(&expected_message);
}
void test_clone_nonetwork__clone_updates_reflog_properly(void)
git_repository_free(repo);
cl_fixture_cleanup("./repowithunborn");
}
-
-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_clone_nonetwork__clone_submodule(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");
-}