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/refs | |
parent | 8480eef7ee0c8e52a8bf3ea12e5626009a966164 (diff) |
Deprecate git_revparse_single and _rangelike
Diffstat (limited to 'tests-clar/refs')
-rw-r--r-- | tests-clar/refs/revparse.c | 70 |
1 files changed, 40 insertions, 30 deletions
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); } |