diff options
author | Carlos Martín Nieto <carlos@cmartin.tk> | 2012-03-03 06:31:51 +0400 |
---|---|---|
committer | Carlos Martín Nieto <carlos@cmartin.tk> | 2012-04-12 22:25:24 +0400 |
commit | de7ab85dc614ba702a89f3f0c761c68ee1e00fda (patch) | |
tree | 4b38067acaf4e7dd35ec00c6c10852786bf85af7 /tests-clar/revwalk | |
parent | 06b9d915901b3dd9dc85016bb000e631eb1da1d7 (diff) |
Implement git_merge_base()
It's implemented in revwalk.c so it has access to the revision
walker's commit cache and related functions. The algorithm is the one
used by git, modified so it fits better with the library's functions.
Diffstat (limited to 'tests-clar/revwalk')
-rw-r--r-- | tests-clar/revwalk/mergebase.c | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/tests-clar/revwalk/mergebase.c b/tests-clar/revwalk/mergebase.c new file mode 100644 index 000000000..91bc6ae8c --- /dev/null +++ b/tests-clar/revwalk/mergebase.c @@ -0,0 +1,37 @@ +#include "clar_libgit2.h" + +static git_repository *_repo; + +void test_revwalk_mergebase__initialize(void) +{ + cl_git_pass(git_repository_open(&_repo, cl_fixture("testrepo.git"))); +} + +void test_revwalk_mergebase__cleanup(void) +{ + git_repository_free(_repo); +} + +void test_revwalk_mergebase__single1(void) +{ + git_oid result, one, two, expected; + + git_oid_fromstr(&one, "c47800c7266a2be04c571c04d5a6614691ea99bd "); + git_oid_fromstr(&two, "9fd738e8f7967c078dceed8190330fc8648ee56a"); + git_oid_fromstr(&expected, "5b5b025afb0b4c913b4c338a42934a3863bf3644"); + + cl_git_pass(git_merge_base(&result, _repo, &one, &two)); + cl_assert(git_oid_cmp(&result, &expected) == 0); +} + +void test_revwalk_mergebase__single2(void) +{ + git_oid result, one, two, expected; + + git_oid_fromstr(&one, "763d71aadf09a7951596c9746c024e7eece7c7af"); + git_oid_fromstr(&two, "a65fedf39aefe402d3bb6e24df4d4f5fe4547750"); + git_oid_fromstr(&expected, "c47800c7266a2be04c571c04d5a6614691ea99bd"); + + cl_git_pass(git_merge_base(&result, _repo, &one, &two)); + cl_assert(git_oid_cmp(&result, &expected) == 0); +} |