diff options
author | Patrick Steinhardt <ps@pks.im> | 2019-10-03 10:40:41 +0200 |
---|---|---|
committer | Patrick Steinhardt <ps@pks.im> | 2020-06-27 14:33:58 +0200 |
commit | 22f201b158f4a3b7bfcf3bac2324ab3fa77bac06 (patch) | |
tree | cf982cb758db39a7d3ef050970853b2f954ec1e1 /tests | |
parent | d54c00814bbba7eb39c43a8556e1720674cab3f3 (diff) | |
download | libgit2-22f201b158f4a3b7bfcf3bac2324ab3fa77bac06.tar.gz |
grafts: make the structure self-contained and opaque
In order to increase maintainability in the future, we should try to
make structures as self-contained and opaque to its users as possible.
Thus it is probably not a good idea to just typedef `git_graftmap` to
`git_oidmap`, as that will make it a lot harder in the future to extend
the API in the future, if this need ever arises.
Refactor the code to instead declare a real structure `git_grafts`,
which is completely opaque to its callers.
Diffstat (limited to 'tests')
-rw-r--r-- | tests/grafts/basic.c | 17 |
1 files changed, 8 insertions, 9 deletions
diff --git a/tests/grafts/basic.c b/tests/grafts/basic.c index 39755ee82..f91397002 100644 --- a/tests/grafts/basic.c +++ b/tests/grafts/basic.c @@ -1,7 +1,7 @@ #include "clar_libgit2.h" #include "futils.h" -#include "graft.h" +#include "grafts.h" static git_repository *g_repo; @@ -17,29 +17,28 @@ void test_grafts_basic__cleanup(void) void test_grafts_basic__graft_add(void) { + git_array_oid_t parents = GIT_ARRAY_INIT; git_oid oid_src, *oid1; git_commit_graft *graft; - git_graftmap *grafts; - git_array_oid_t parents = GIT_ARRAY_INIT; + git_grafts *grafts; - cl_git_pass(git_oidmap_new(&grafts)); + cl_git_pass(git_grafts_new(&grafts)); cl_assert(oid1 = git_array_alloc(parents)); cl_git_pass(git_oid_fromstr(&oid_src, "2f3053cbff8a4ca2f0666de364ddb734a28a31a9")); git_oid_cpy(oid1, &oid_src); git_oid_fromstr(&oid_src, "f503807ffa920e407a600cfaee96b7152259acc7"); - cl_git_pass(git__graft_register(grafts, &oid_src, parents)); + cl_git_pass(git_grafts_add(grafts, &oid_src, parents)); git_array_clear(parents); - cl_assert_equal_i(1, git_oidmap_size(grafts)); - cl_git_pass(git__graft_for_oid(&graft, grafts, &oid_src)); + cl_assert_equal_i(1, git_grafts_size(grafts)); + cl_git_pass(git_grafts_get(&graft, grafts, &oid_src)); cl_assert_equal_s("f503807ffa920e407a600cfaee96b7152259acc7", git_oid_tostr_s(&graft->oid)); cl_assert_equal_i(1, git_array_size(graft->parents)); cl_assert_equal_s("2f3053cbff8a4ca2f0666de364ddb734a28a31a9", git_oid_tostr_s(git_array_get(graft->parents, 0))); - git__graft_clear(grafts); - git_oidmap_free(grafts); + git_grafts_free(grafts); } void test_grafts_basic__grafted_revwalk(void) |