Commit 2ebc3c66 by Ben Straub

Redeploy git_revparse_single.

parent 4291ad07
......@@ -96,8 +96,9 @@ static int check_rref(char *ref)
static int check_lref(git_push *push, char *ref)
{
/* lref must be resolvable to an existing object */
git_oid oid;
int error = git_revparse(&oid, NULL, NULL, push->repo, ref);
git_object *obj;
int error = git_revparse_single(&obj, push->repo, ref);
git_object_free(obj);
if (!error)
return 0;
......
......@@ -236,13 +236,14 @@ static int local_negotiate_fetch(
/* Fill in the loids */
git_vector_foreach(&t->refs, i, rhead) {
git_oid oid;
git_object *obj;
int error = git_revparse(&oid, NULL, NULL, repo, rhead->name);
int error = git_revparse_single(&obj, repo, rhead->name);
if (!error)
git_oid_cpy(&rhead->loid, &oid);
git_oid_cpy(&rhead->loid, git_object_id(obj));
else if (error != GIT_ENOTFOUND)
return error;
git_object_free(obj);
giterr_clear();
}
......
......@@ -28,25 +28,19 @@ void test_checkout_tree__cleanup(void)
void test_checkout_tree__cannot_checkout_a_non_treeish(void)
{
git_oid oid;
/* blob */
cl_git_pass(git_revparse(&oid, NULL, NULL, g_repo, "a71586c1dfe8a71c6cbf6c129f404c5642ff31bd"));
cl_git_pass(git_object_lookup(&g_object, g_repo, &oid, GIT_OBJ_ANY));
cl_git_pass(git_revparse_single(&g_object, g_repo, "a71586c1dfe8a71c6cbf6c129f404c5642ff31bd"));
cl_git_fail(git_checkout_tree(g_repo, g_object, NULL));
}
void test_checkout_tree__can_checkout_a_subdirectory_from_a_commit(void)
{
char *entries[] = { "ab/de/" };
git_oid oid;
g_opts.paths.strings = entries;
g_opts.paths.count = 1;
cl_git_pass(git_revparse(&oid, NULL, NULL, g_repo, "subtrees"));
cl_git_pass(git_object_lookup(&g_object, g_repo, &oid, GIT_OBJ_ANY));
cl_git_pass(git_revparse_single(&g_object, g_repo, "subtrees"));
cl_assert_equal_i(false, git_path_isdir("./testrepo/ab/"));
......@@ -58,15 +52,12 @@ void test_checkout_tree__can_checkout_a_subdirectory_from_a_commit(void)
void test_checkout_tree__can_checkout_and_remove_directory(void)
{
git_oid oid;
cl_assert_equal_i(false, git_path_isdir("./testrepo/ab/"));
/* Checkout brach "subtrees" and update HEAD, so that HEAD matches the
* current working tree
*/
cl_git_pass(git_revparse(&oid, NULL, NULL, g_repo, "subtrees"));
cl_git_pass(git_object_lookup(&g_object, g_repo, &oid, GIT_OBJ_ANY));
cl_git_pass(git_revparse_single(&g_object, g_repo, "subtrees"));
cl_git_pass(git_checkout_tree(g_repo, g_object, &g_opts));
cl_git_pass(git_repository_set_head(g_repo, "refs/heads/subtrees"));
......@@ -81,8 +72,7 @@ void test_checkout_tree__can_checkout_and_remove_directory(void)
/* Checkout brach "master" and update HEAD, so that HEAD matches the
* current working tree
*/
cl_git_pass(git_revparse(&oid, NULL, NULL, g_repo, "master"));
cl_git_pass(git_object_lookup(&g_object, g_repo, &oid, GIT_OBJ_ANY));
cl_git_pass(git_revparse_single(&g_object, g_repo, "master"));
cl_git_pass(git_checkout_tree(g_repo, g_object, &g_opts));
cl_git_pass(git_repository_set_head(g_repo, "refs/heads/master"));
......@@ -94,13 +84,11 @@ void test_checkout_tree__can_checkout_and_remove_directory(void)
void test_checkout_tree__can_checkout_a_subdirectory_from_a_subtree(void)
{
char *entries[] = { "de/" };
git_oid oid;
g_opts.paths.strings = entries;
g_opts.paths.count = 1;
cl_git_pass(git_revparse(&oid, NULL, NULL, g_repo, "subtrees:ab"));
cl_git_pass(git_object_lookup(&g_object, g_repo, &oid, GIT_OBJ_ANY));
cl_git_pass(git_revparse_single(&g_object, g_repo, "subtrees:ab"));
cl_assert_equal_i(false, git_path_isdir("./testrepo/de/"));
......@@ -120,13 +108,11 @@ static void progress(const char *path, size_t cur, size_t tot, void *payload)
void test_checkout_tree__calls_progress_callback(void)
{
bool was_called = 0;
git_oid oid;
g_opts.progress_cb = progress;
g_opts.progress_payload = &was_called;
cl_git_pass(git_revparse(&oid, NULL, NULL, g_repo, "master"));
cl_git_pass(git_object_lookup(&g_object, g_repo, &oid, GIT_OBJ_ANY));
cl_git_pass(git_revparse_single(&g_object, g_repo, "master"));
cl_git_pass(git_checkout_tree(g_repo, g_object, &g_opts));
......@@ -290,16 +276,13 @@ void test_checkout_tree__can_update_only(void)
void test_checkout_tree__can_checkout_with_pattern(void)
{
char *entries[] = { "[l-z]*.txt" };
git_oid oid;
/* reset to beginning of history (i.e. just a README file) */
g_opts.checkout_strategy =
GIT_CHECKOUT_FORCE | GIT_CHECKOUT_REMOVE_UNTRACKED;
cl_git_pass(git_revparse(&oid, NULL, NULL, g_repo,
"8496071c1b46c854b31185ea97743be6a8774479"));
cl_git_pass(git_object_lookup(&g_object, g_repo, &oid, GIT_OBJ_ANY));
cl_git_pass(git_revparse_single(&g_object, g_repo, "8496071c1b46c854b31185ea97743be6a8774479"));
cl_git_pass(git_checkout_tree(g_repo, g_object, &g_opts));
cl_git_pass(
......@@ -319,8 +302,7 @@ void test_checkout_tree__can_checkout_with_pattern(void)
g_opts.paths.strings = entries;
g_opts.paths.count = 1;
cl_git_pass(git_revparse(&oid, NULL, NULL, g_repo, "refs/heads/master"));
cl_git_pass(git_object_lookup(&g_object, g_repo, &oid, GIT_OBJ_ANY));
cl_git_pass(git_revparse_single(&g_object, g_repo, "refs/heads/master"));
cl_git_pass(git_checkout_tree(g_repo, g_object, &g_opts));
......@@ -333,16 +315,13 @@ void test_checkout_tree__can_checkout_with_pattern(void)
void test_checkout_tree__can_disable_pattern_match(void)
{
char *entries[] = { "b*.txt" };
git_oid oid;
/* reset to beginning of history (i.e. just a README file) */
g_opts.checkout_strategy =
GIT_CHECKOUT_FORCE | GIT_CHECKOUT_REMOVE_UNTRACKED;
cl_git_pass(git_revparse(&oid, NULL, NULL, g_repo,
"8496071c1b46c854b31185ea97743be6a8774479"));
cl_git_pass(git_object_lookup(&g_object, g_repo, &oid, GIT_OBJ_ANY));
cl_git_pass(git_revparse_single(&g_object, g_repo, "8496071c1b46c854b31185ea97743be6a8774479"));
cl_git_pass(git_checkout_tree(g_repo, g_object, &g_opts));
cl_git_pass(
......@@ -360,8 +339,7 @@ void test_checkout_tree__can_disable_pattern_match(void)
g_opts.paths.strings = entries;
g_opts.paths.count = 1;
cl_git_pass(git_revparse(&oid, NULL, NULL, g_repo, "refs/heads/master"));
cl_git_pass(git_object_lookup(&g_object, g_repo, &oid, GIT_OBJ_ANY));
cl_git_pass(git_revparse_single(&g_object, g_repo, "refs/heads/master"));
cl_git_pass(git_checkout_tree(g_repo, g_object, &g_opts));
......@@ -386,13 +364,11 @@ void assert_conflict(
git_object *hack_tree;
git_reference *branch, *head;
git_buf file_path = GIT_BUF_INIT;
git_oid oid;
cl_git_pass(git_repository_index(&index, g_repo));
/* Create a branch pointing at the parent */
cl_git_pass(git_revparse(&oid, NULL, NULL, g_repo, parent_sha));
cl_git_pass(git_object_lookup(&g_object, g_repo, &oid, GIT_OBJ_ANY));
cl_git_pass(git_revparse_single(&g_object, g_repo, parent_sha));
cl_git_pass(git_branch_create(&branch, g_repo,
"potential_conflict", (git_commit *)g_object, 0));
......@@ -421,8 +397,7 @@ void assert_conflict(
git_buf_free(&file_path);
/* Trying to checkout the original commit */
cl_git_pass(git_revparse(&oid, NULL, NULL, g_repo, commit_sha));
cl_git_pass(git_object_lookup(&g_object, g_repo, &oid, GIT_OBJ_ANY));
cl_git_pass(git_revparse_single(&g_object, g_repo, commit_sha));
g_opts.checkout_strategy = GIT_CHECKOUT_SAFE;
cl_assert_equal_i(
......@@ -509,7 +484,6 @@ void test_checkout_tree__issue_1397(void)
git_checkout_opts opts = GIT_CHECKOUT_OPTS_INIT;
const char *partial_oid = "8a7ef04";
git_object *tree = NULL;
git_oid oid;
test_checkout_tree__cleanup(); /* cleanup default checkout */
......@@ -517,8 +491,7 @@ void test_checkout_tree__issue_1397(void)
cl_repo_set_bool(g_repo, "core.autocrlf", true);
cl_git_pass(git_revparse(&oid, NULL, NULL, g_repo, partial_oid));
cl_git_pass(git_object_lookup(&tree, g_repo, &oid, GIT_OBJ_ANY));
cl_git_pass(git_revparse_single(&tree, g_repo, partial_oid));
opts.checkout_strategy = GIT_CHECKOUT_FORCE;
......
......@@ -107,12 +107,10 @@ void test_checkout_typechange__checkout_typechanges_safe(void)
{
int i;
git_object *obj;
git_oid oid;
git_checkout_opts opts = GIT_CHECKOUT_OPTS_INIT;
for (i = 0; g_typechange_oids[i] != NULL; ++i) {
cl_git_pass(git_revparse(&oid, NULL, NULL, g_repo, g_typechange_oids[i]));
cl_git_pass(git_object_lookup(&obj, g_repo, &oid, GIT_OBJ_ANY));
cl_git_pass(git_revparse_single(&obj, g_repo, g_typechange_oids[i]));
opts.checkout_strategy = GIT_CHECKOUT_FORCE;
......@@ -196,7 +194,6 @@ void test_checkout_typechange__checkout_with_conflicts(void)
{
int i;
git_object *obj;
git_oid oid;
git_checkout_opts opts = GIT_CHECKOUT_OPTS_INIT;
notify_counts cts = {0};
......@@ -206,8 +203,7 @@ void test_checkout_typechange__checkout_with_conflicts(void)
opts.notify_payload = &cts;
for (i = 0; g_typechange_oids[i] != NULL; ++i) {
cl_git_pass(git_revparse(&oid, NULL, NULL, g_repo, g_typechange_oids[i]));
cl_git_pass(git_object_lookup(&obj, g_repo, &oid, GIT_OBJ_ANY));
cl_git_pass(git_revparse_single(&obj, g_repo, g_typechange_oids[i]));
force_create_file("typechanges/a/blocker");
force_create_file("typechanges/b");
......
......@@ -214,22 +214,23 @@ void test_clone_nonetwork__can_checkout_given_branch(void)
void test_clone_nonetwork__can_detached_head(void)
{
git_oid oid;
git_object *obj;
git_repository *cloned;
git_reference *cloned_head;
cl_git_pass(git_clone(&g_repo, cl_git_fixture_url("testrepo.git"), "./foo", &g_options));
cl_git_pass(git_revparse(&oid, NULL, NULL, g_repo, "master~1"));
cl_git_pass(git_repository_set_head_detached(g_repo, &oid));
cl_git_pass(git_revparse_single(&obj, g_repo, "master~1"));
cl_git_pass(git_repository_set_head_detached(g_repo, git_object_id(obj)));
cl_git_pass(git_clone(&cloned, "./foo", "./foo1", &g_options));
cl_assert(git_repository_head_detached(cloned));
cl_git_pass(git_repository_head(&cloned_head, cloned));
cl_assert(!git_oid_cmp(&oid, git_reference_target(cloned_head)));
cl_assert(!git_oid_cmp(git_object_id(obj), git_reference_target(cloned_head)));
git_object_free(obj);
git_reference_free(cloned_head);
git_repository_free(cloned);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment