diff options
author | Ben Straub <bs@github.com> | 2013-04-09 05:03:51 +0400 |
---|---|---|
committer | Ben Straub <bs@github.com> | 2013-04-09 05:07:04 +0400 |
commit | 1aa21fe3b87a1e601023f49c41fab3ce76c189ac (patch) | |
tree | b25c258e7d360cb9dd7d278094ff12b490a0e61e /tests-clar | |
parent | 8480eef7ee0c8e52a8bf3ea12e5626009a966164 (diff) | |
download | libgit2-1aa21fe3b87a1e601023f49c41fab3ce76c189ac.tar.gz |
Deprecate git_revparse_single and _rangelike
Diffstat (limited to 'tests-clar')
-rw-r--r-- | tests-clar/checkout/tree.c | 50 | ||||
-rw-r--r-- | tests-clar/checkout/typechange.c | 8 | ||||
-rw-r--r-- | tests-clar/clone/nonetwork.c | 9 | ||||
-rw-r--r-- | tests-clar/refs/revparse.c | 70 | ||||
-rw-r--r-- | tests-clar/repo/head.c | 8 | ||||
-rw-r--r-- | tests-clar/reset/default.c | 12 | ||||
-rw-r--r-- | tests-clar/stash/drop.c | 19 | ||||
-rw-r--r-- | tests-clar/stash/save.c | 16 |
8 files changed, 119 insertions, 73 deletions
diff --git a/tests-clar/checkout/tree.c b/tests-clar/checkout/tree.c index 5a2eacea1..ae4087f41 100644 --- a/tests-clar/checkout/tree.c +++ b/tests-clar/checkout/tree.c @@ -28,8 +28,11 @@ 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_single(&g_object, g_repo, "a71586c1dfe8a71c6cbf6c129f404c5642ff31bd")); + 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_fail(git_checkout_tree(g_repo, g_object, NULL)); } @@ -37,11 +40,13 @@ void test_checkout_tree__cannot_checkout_a_non_treeish(void) 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_single(&g_object, g_repo, "subtrees")); + 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_assert_equal_i(false, git_path_isdir("./testrepo/ab/")); @@ -53,12 +58,15 @@ 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_single(&g_object, g_repo, "subtrees")); + 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_checkout_tree(g_repo, g_object, &g_opts)); cl_git_pass(git_repository_set_head(g_repo, "refs/heads/subtrees")); @@ -73,7 +81,8 @@ 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_single(&g_object, g_repo, "master")); + 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_checkout_tree(g_repo, g_object, &g_opts)); cl_git_pass(git_repository_set_head(g_repo, "refs/heads/master")); @@ -85,11 +94,13 @@ 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_single(&g_object, g_repo, "subtrees:ab")); + 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_assert_equal_i(false, git_path_isdir("./testrepo/de/")); @@ -109,11 +120,13 @@ 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_single(&g_object, g_repo, "master")); + 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_checkout_tree(g_repo, g_object, &g_opts)); @@ -277,14 +290,16 @@ 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_single(&g_object, g_repo, + 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_checkout_tree(g_repo, g_object, &g_opts)); cl_git_pass( @@ -304,7 +319,8 @@ void test_checkout_tree__can_checkout_with_pattern(void) g_opts.paths.strings = entries; g_opts.paths.count = 1; - cl_git_pass(git_revparse_single(&g_object, g_repo, "refs/heads/master")); + 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_checkout_tree(g_repo, g_object, &g_opts)); @@ -317,14 +333,16 @@ 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_single(&g_object, g_repo, + 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_checkout_tree(g_repo, g_object, &g_opts)); cl_git_pass( @@ -342,7 +360,8 @@ void test_checkout_tree__can_disable_pattern_match(void) g_opts.paths.strings = entries; g_opts.paths.count = 1; - cl_git_pass(git_revparse_single(&g_object, g_repo, "refs/heads/master")); + 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_checkout_tree(g_repo, g_object, &g_opts)); @@ -367,11 +386,13 @@ 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_single(&g_object, g_repo, parent_sha)); + 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_branch_create(&branch, g_repo, "potential_conflict", (git_commit *)g_object, 0)); @@ -400,7 +421,8 @@ void assert_conflict( git_buf_free(&file_path); /* Trying to checkout the original commit */ - cl_git_pass(git_revparse_single(&g_object, g_repo, commit_sha)); + 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)); g_opts.checkout_strategy = GIT_CHECKOUT_SAFE; cl_assert_equal_i( @@ -487,6 +509,7 @@ 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 */ @@ -494,7 +517,8 @@ void test_checkout_tree__issue_1397(void) cl_repo_set_bool(g_repo, "core.autocrlf", true); - cl_git_pass(git_revparse_single(&tree, g_repo, partial_oid)); + 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)); opts.checkout_strategy = GIT_CHECKOUT_FORCE; diff --git a/tests-clar/checkout/typechange.c b/tests-clar/checkout/typechange.c index b92cc23fa..74521312a 100644 --- a/tests-clar/checkout/typechange.c +++ b/tests-clar/checkout/typechange.c @@ -107,10 +107,12 @@ 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_single(&obj, g_repo, g_typechange_oids[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)); opts.checkout_strategy = GIT_CHECKOUT_FORCE; @@ -194,6 +196,7 @@ 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}; @@ -203,7 +206,8 @@ 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_single(&obj, g_repo, g_typechange_oids[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)); force_create_file("typechanges/a/blocker"); force_create_file("typechanges/b"); diff --git a/tests-clar/clone/nonetwork.c b/tests-clar/clone/nonetwork.c index 2c4cba4eb..d86c1f4c9 100644 --- a/tests-clar/clone/nonetwork.c +++ b/tests-clar/clone/nonetwork.c @@ -214,23 +214,22 @@ void test_clone_nonetwork__can_checkout_given_branch(void) void test_clone_nonetwork__can_detached_head(void) { - git_object *commit; + git_oid oid; 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_single(&commit, g_repo, "master~1")); - cl_git_pass(git_repository_set_head_detached(g_repo, git_object_id(commit))); + 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_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(git_object_id(commit), git_reference_target(cloned_head))); + cl_assert(!git_oid_cmp(&oid, git_reference_target(cloned_head))); - git_commit_free((git_commit*)commit); git_reference_free(cloned_head); git_repository_free(cloned); diff --git a/tests-clar/refs/revparse.c b/tests-clar/refs/revparse.c index ab8839fda..39e77c8eb 100644 --- a/tests-clar/refs/revparse.c +++ b/tests-clar/refs/revparse.c @@ -6,25 +6,22 @@ #include "path.h" static git_repository *g_repo; -static git_object *g_obj; /* Helpers */ static void test_object_inrepo(const char *spec, const char *expected_oid, git_repository *repo) { char objstr[64] = {0}; - git_object *obj = NULL; + git_oid oid; int error; - error = git_revparse_single(&obj, repo, spec); + error = git_revparse(&oid, NULL, NULL, repo, spec); if (expected_oid != NULL) { cl_assert_equal_i(0, error); - git_oid_fmt(objstr, git_object_id(obj)); + git_oid_fmt(objstr, &oid); cl_assert_equal_s(objstr, expected_oid); } else cl_assert_equal_i(GIT_ENOTFOUND, error); - - git_object_free(obj); } static void test_id_inrepo( @@ -66,27 +63,24 @@ static void test_object(const char *spec, const char *expected_oid) static void test_rangelike(const char *rangelike, const char *expected_left, const char *expected_right, - int expected_threedots) + git_revparse_flag_t expected_revparseflags) { char objstr[64] = {0}; - git_object *left = NULL, *right = NULL; - int threedots; + git_oid left = {{0}}, right = {{0}}; + git_revparse_flag_t revparseflags; int error; - error = git_revparse_rangelike(&left, &right, &threedots, g_repo, rangelike); + error = git_revparse(&left, &right, &revparseflags, g_repo, rangelike); if (expected_left != NULL) { cl_assert_equal_i(0, error); - cl_assert_equal_i(threedots, expected_threedots); - git_oid_fmt(objstr, git_object_id(left)); + cl_assert_equal_i(revparseflags, expected_revparseflags); + git_oid_fmt(objstr, &left); cl_assert_equal_s(objstr, expected_left); - git_oid_fmt(objstr, git_object_id(right)); + git_oid_fmt(objstr, &right); cl_assert_equal_s(objstr, expected_right); } else cl_assert(error != 0); - - git_object_free(left); - git_object_free(right); } @@ -118,8 +112,9 @@ void test_refs_revparse__nonexistant_object(void) static void assert_invalid_spec(const char *invalid_spec) { + git_oid oid; cl_assert_equal_i( - GIT_EINVALIDSPEC, git_revparse_single(&g_obj, g_repo, invalid_spec)); + GIT_EINVALIDSPEC, git_revparse(&oid, NULL, NULL, g_repo, invalid_spec)); } void test_refs_revparse__invalid_reference_name(void) @@ -196,10 +191,12 @@ void test_refs_revparse__not_tag(void) void test_refs_revparse__to_type(void) { + git_oid oid; + assert_invalid_spec("wrapped_tag^{trip}"); test_object("point_to_blob^{commit}", NULL); cl_assert_equal_i( - GIT_EAMBIGUOUS, git_revparse_single(&g_obj, g_repo, "wrapped_tag^{blob}")); + GIT_EAMBIGUOUS, git_revparse(&oid, NULL, NULL, g_repo, "wrapped_tag^{blob}")); test_object("wrapped_tag^{commit}", "a65fedf39aefe402d3bb6e24df4d4f5fe4547750"); test_object("wrapped_tag^{tree}", "944c0f6e4dfa41595e6eb3ceecdb14f50fe18162"); @@ -263,7 +260,8 @@ void test_refs_revparse__ordinal(void) assert_invalid_spec("master@{-2}"); /* TODO: make the test below actually fail - * cl_git_fail(git_revparse_single(&g_obj, g_repo, "master@{1a}")); + * git_oid oid; + * cl_git_fail(git_revparse(&oid, NULL, NULL, g_repo, "master@{1a}")); */ test_object("nope@{0}", NULL); @@ -425,9 +423,11 @@ void test_refs_revparse__date(void) void test_refs_revparse__colon(void) { + git_oid oid; + assert_invalid_spec(":/"); assert_invalid_spec("point_to_blob:readme.txt"); - cl_git_fail(git_revparse_single(&g_obj, g_repo, ":2:README")); /* Not implemented */ + cl_git_fail(git_revparse(&oid, NULL, NULL, g_repo, ":2:README")); /* Not implemented */ test_object(":/not found in any commit", NULL); test_object("subtrees:ab/42.txt", NULL); @@ -517,8 +517,9 @@ void test_refs_revparse__disambiguation(void) void test_refs_revparse__a_too_short_objectid_returns_EAMBIGUOUS(void) { + git_oid oid; cl_assert_equal_i( - GIT_EAMBIGUOUS, git_revparse_single(&g_obj, g_repo, "e90")); + GIT_EAMBIGUOUS, git_revparse(&oid, NULL, NULL, g_repo, "e90")); } void test_refs_revparse__issue_994(void) @@ -526,14 +527,15 @@ void test_refs_revparse__issue_994(void) git_repository *repo; git_reference *head, *with_at; git_object *target; + git_oid oid; repo = cl_git_sandbox_init("testrepo.git"); cl_assert_equal_i(GIT_ENOTFOUND, - git_revparse_single(&target, repo, "origin/bim_with_3d@11296")); + git_revparse(&oid, NULL, NULL, repo, "origin/bim_with_3d@11296")); cl_assert_equal_i(GIT_ENOTFOUND, - git_revparse_single(&target, repo, "refs/remotes/origin/bim_with_3d@11296")); + git_revparse(&oid, NULL, NULL, repo, "refs/remotes/origin/bim_with_3d@11296")); cl_git_pass(git_repository_head(&head, repo)); @@ -544,10 +546,12 @@ void test_refs_revparse__issue_994(void) git_reference_target(head), 0)); - cl_git_pass(git_revparse_single(&target, repo, "origin/bim_with_3d@11296")); + cl_git_pass(git_revparse(&oid, NULL, NULL, repo, "origin/bim_with_3d@11296")); + cl_git_pass(git_object_lookup(&target, repo, &oid, GIT_OBJ_COMMIT)); git_object_free(target); - cl_git_pass(git_revparse_single(&target, repo, "refs/remotes/origin/bim_with_3d@11296")); + cl_git_pass(git_revparse(&oid, NULL, NULL, repo, "refs/remotes/origin/bim_with_3d@11296")); + cl_git_pass(git_object_lookup(&target, repo, &oid, GIT_OBJ_COMMIT)); git_object_free(target); git_reference_free(with_at); @@ -573,12 +577,14 @@ void test_refs_revparse__try_to_retrieve_branch_before_described_tag(void) git_reference *branch; git_object *target; char sha[GIT_OID_HEXSZ + 1]; + git_oid oid; repo = cl_git_sandbox_init("testrepo.git"); test_object_inrepo("blah-7-gc47800c", "c47800c7266a2be04c571c04d5a6614691ea99bd", repo); - cl_git_pass(git_revparse_single(&target, repo, "HEAD~3")); + cl_git_pass(git_revparse(&oid, NULL, NULL, repo, "HEAD~3")); + cl_git_pass(git_object_lookup(&target, repo, &oid, GIT_OBJ_COMMIT)); cl_git_pass(git_branch_create(&branch, repo, "blah-7-gc47800c", (git_commit *)target, 0)); git_oid_tostr(sha, GIT_OID_HEXSZ + 1, git_object_id(target)); @@ -611,12 +617,14 @@ void test_refs_revparse__try_to_retrieve_sha_before_branch(void) git_reference *branch; git_object *target; char sha[GIT_OID_HEXSZ + 1]; + git_oid oid; repo = cl_git_sandbox_init("testrepo.git"); test_object_inrepo("a65fedf39aefe402d3bb6e24df4d4f5fe4547750", "a65fedf39aefe402d3bb6e24df4d4f5fe4547750", repo); - cl_git_pass(git_revparse_single(&target, repo, "HEAD~3")); + cl_git_pass(git_revparse(&oid, NULL, NULL, repo, "HEAD~3")); + cl_git_pass(git_object_lookup(&target, repo, &oid, GIT_OBJ_COMMIT)); cl_git_pass(git_branch_create(&branch, repo, "a65fedf39aefe402d3bb6e24df4d4f5fe4547750", (git_commit *)target, 0)); git_oid_tostr(sha, GIT_OID_HEXSZ + 1, git_object_id(target)); @@ -647,12 +655,14 @@ void test_refs_revparse__try_to_retrieve_branch_before_abbrev_sha(void) git_reference *branch; git_object *target; char sha[GIT_OID_HEXSZ + 1]; + git_oid oid; repo = cl_git_sandbox_init("testrepo.git"); test_object_inrepo("c47800", "c47800c7266a2be04c571c04d5a6614691ea99bd", repo); - cl_git_pass(git_revparse_single(&target, repo, "HEAD~3")); + cl_git_pass(git_revparse(&oid, NULL, NULL, repo, "HEAD~3")); + cl_git_pass(git_object_lookup(&target, repo, &oid, GIT_OBJ_COMMIT)); cl_git_pass(git_branch_create(&branch, repo, "c47800", (git_commit *)target, 0)); git_oid_tostr(sha, GIT_OID_HEXSZ + 1, git_object_id(target)); @@ -670,12 +680,12 @@ void test_refs_revparse__range(void) test_rangelike("be3563a^1..be3563a", "9fd738e8f7967c078dceed8190330fc8648ee56a", "be3563ae3f795b2b4353bcce3a527ad0a4f7f644", - 0); + GIT_REVPARSE_RANGE); test_rangelike("be3563a^1...be3563a", "9fd738e8f7967c078dceed8190330fc8648ee56a", "be3563ae3f795b2b4353bcce3a527ad0a4f7f644", - 1); + GIT_REVPARSE_RANGE | GIT_REVPARSE_MERGE_BASE); test_rangelike("be3563a^1.be3563a", NULL, NULL, 0); } diff --git a/tests-clar/repo/head.c b/tests-clar/repo/head.c index a9f5cfc58..bb81bb087 100644 --- a/tests-clar/repo/head.c +++ b/tests-clar/repo/head.c @@ -120,9 +120,11 @@ void test_repo_head__set_head_detached_Return_ENOTFOUND_when_the_object_doesnt_e void test_repo_head__set_head_detached_Fails_when_the_object_isnt_a_commitish(void) { + git_oid oid; git_object *blob; - cl_git_pass(git_revparse_single(&blob, repo, "point_to_blob")); + cl_git_pass(git_revparse(&oid, NULL, NULL, repo, "point_to_blob")); + cl_git_pass(git_object_lookup(&blob, repo, &oid, GIT_OBJ_ANY)); cl_git_fail(git_repository_set_head_detached(repo, git_object_id(blob))); @@ -131,9 +133,11 @@ void test_repo_head__set_head_detached_Fails_when_the_object_isnt_a_commitish(vo void test_repo_head__set_head_detached_Detaches_HEAD_and_make_it_point_to_the_peeled_commit(void) { + git_oid oid; git_object *tag; - cl_git_pass(git_revparse_single(&tag, repo, "tags/test")); + cl_git_pass(git_revparse(&oid, NULL, NULL, repo, "tags/test")); + cl_git_pass(git_object_lookup(&tag, repo, &oid, GIT_OBJ_ANY)); cl_assert_equal_i(GIT_OBJ_TAG, git_object_type(tag)); cl_git_pass(git_repository_set_head_detached(repo, git_object_id(tag))); diff --git a/tests-clar/reset/default.c b/tests-clar/reset/default.c index 506d971ff..bc8da7392 100644 --- a/tests-clar/reset/default.c +++ b/tests-clar/reset/default.c @@ -95,6 +95,7 @@ void test_reset_default__resetting_filepaths_against_a_null_target_removes_them_ void test_reset_default__resetting_filepaths_replaces_their_corresponding_index_entries(void) { git_strarray before, after; + git_oid oid; char *paths[] = { "staged_changes", "staged_changes_file_deleted" }; char *before_shas[] = { "55d316c9ba708999f1918e9677d01dfcae69c6b9", @@ -109,7 +110,8 @@ void test_reset_default__resetting_filepaths_replaces_their_corresponding_index_ after.strings = after_shas; after.count = 2; - cl_git_pass(git_revparse_single(&_target, _repo, "0017bd4")); + cl_git_pass(git_revparse(&oid, NULL, NULL, _repo, "0017bd4")); + cl_git_pass(git_object_lookup(&_target, _repo, &oid, GIT_OBJ_ANY)); assert_content_in_index(&_pathspecs, true, &before); cl_git_pass(git_reset_default(_repo, _target, &_pathspecs)); @@ -135,6 +137,7 @@ void test_reset_default__resetting_filepaths_clears_previous_conflicts(void) { git_index_entry *conflict_entry[3]; git_strarray after; + git_oid oid; char *paths[] = { "conflicts-one.txt" }; char *after_shas[] = { "1f85ca51b8e0aac893a621b61a9c2661d6aa6d81" }; @@ -150,7 +153,8 @@ void test_reset_default__resetting_filepaths_clears_previous_conflicts(void) cl_git_pass(git_index_conflict_get(&conflict_entry[0], &conflict_entry[1], &conflict_entry[2], _index, "conflicts-one.txt")); - cl_git_pass(git_revparse_single(&_target, _repo, "9a05ccb")); + cl_git_pass(git_revparse(&oid, NULL, NULL, _repo, "9a05ccb")); + cl_git_pass(git_object_lookup(&_target, _repo, &oid, GIT_OBJ_ANY)); cl_git_pass(git_reset_default(_repo, _target, &_pathspecs)); assert_content_in_index(&_pathspecs, true, &after); @@ -167,13 +171,15 @@ Unstaged changes after reset: void test_reset_default__resetting_unknown_filepaths_does_not_fail(void) { char *paths[] = { "I_am_not_there.txt", "me_neither.txt" }; + git_oid oid; _pathspecs.strings = paths; _pathspecs.count = 2; assert_content_in_index(&_pathspecs, false, NULL); - cl_git_pass(git_revparse_single(&_target, _repo, "HEAD")); + cl_git_pass(git_revparse(&oid, NULL, NULL, _repo, "HEAD")); + cl_git_pass(git_object_lookup(&_target, _repo, &oid, GIT_OBJ_ANY)); cl_git_pass(git_reset_default(_repo, _target, &_pathspecs)); assert_content_in_index(&_pathspecs, false, NULL); diff --git a/tests-clar/stash/drop.c b/tests-clar/stash/drop.c index d171390da..da9e676a9 100644 --- a/tests-clar/stash/drop.c +++ b/tests-clar/stash/drop.c @@ -140,35 +140,30 @@ void test_stash_drop__dropping_the_last_entry_removes_the_stash(void) void retrieve_top_stash_id(git_oid *out) { - git_object *top_stash; + git_oid top_stash_id; - cl_git_pass(git_revparse_single(&top_stash, repo, "stash@{0}")); + cl_git_pass(git_revparse(&top_stash_id, NULL, NULL, repo, "stash@{0}")); cl_git_pass(git_reference_name_to_id(out, repo, GIT_REFS_STASH_FILE)); - cl_assert_equal_i(true, git_oid_cmp(out, git_object_id(top_stash)) == 0); - - git_object_free(top_stash); + cl_assert_equal_i(true, git_oid_cmp(out, &top_stash_id) == 0); } void test_stash_drop__dropping_the_top_stash_updates_the_stash_reference(void) { - git_object *next_top_stash; + git_oid next_top_stash_id; git_oid oid; push_three_states(); retrieve_top_stash_id(&oid); - cl_git_pass(git_revparse_single(&next_top_stash, repo, "stash@{1}")); - cl_assert_equal_i( - false, git_oid_cmp(&oid, git_object_id(next_top_stash)) == 0); + cl_git_pass(git_revparse(&next_top_stash_id, NULL, NULL, repo, "stash@{1}")); + cl_assert_equal_i(false, git_oid_cmp(&oid, &next_top_stash_id) == 0); cl_git_pass(git_stash_drop(repo, 0)); retrieve_top_stash_id(&oid); cl_assert_equal_i( - true, git_oid_cmp(&oid, git_object_id(next_top_stash)) == 0); - - git_object_free(next_top_stash); + true, git_oid_cmp(&oid, &next_top_stash_id) == 0); } diff --git a/tests-clar/stash/save.c b/tests-clar/stash/save.c index 588dfc3ea..4185e549c 100644 --- a/tests-clar/stash/save.c +++ b/tests-clar/stash/save.c @@ -37,10 +37,11 @@ void test_stash_save__cleanup(void) static void assert_object_oid(const char* revision, const char* expected_oid, git_otype type) { - git_object *object; + git_oid oid; int result; + git_object *obj; - result = git_revparse_single(&object, repo, revision); + result = git_revparse(&oid, NULL, NULL, repo, revision); if (!expected_oid) { cl_assert_equal_i(GIT_ENOTFOUND, result); @@ -48,10 +49,11 @@ static void assert_object_oid(const char* revision, const char* expected_oid, gi } else cl_assert_equal_i(0, result); - cl_assert_equal_i(type, git_object_type(object)); - cl_git_pass(git_oid_streq(git_object_id(object), expected_oid)); + cl_git_pass(git_oid_streq(&oid, expected_oid)); - git_object_free(object); + cl_git_pass(git_object_lookup(&obj, repo, &oid, GIT_OBJ_ANY)); + cl_assert_equal_i(type, git_object_type(obj)); + git_object_free(obj); } static void assert_blob_oid(const char* revision, const char* expected_oid) @@ -145,9 +147,11 @@ void test_stash_save__can_keep_index(void) static void assert_commit_message_contains(const char *revision, const char *fragment) { + git_oid oid; git_commit *commit; - cl_git_pass(git_revparse_single(((git_object **)&commit), repo, revision)); + cl_git_pass(git_revparse(&oid, NULL, NULL, repo, revision)); + cl_git_pass(git_commit_lookup(&commit, repo, &oid)); cl_assert(strstr(git_commit_message(commit), fragment) != NULL); |