Hash :
de7ab85d
Author :
Date :
2012-03-03T03:31:51
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.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 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);
}