]>
git.proxmox.com Git - libgit2.git/blob - tests/commit/parent.c
18ce0bba600ebc45431db3332ffe70fb5dce3134
1 #include "clar_libgit2.h"
3 static git_repository
*_repo
;
4 static git_commit
*commit
;
6 void test_commit_parent__initialize(void)
10 cl_git_pass(git_repository_open(&_repo
, cl_fixture("testrepo.git")));
12 git_oid_fromstr(&oid
, "be3563ae3f795b2b4353bcce3a527ad0a4f7f644");
13 cl_git_pass(git_commit_lookup(&commit
, _repo
, &oid
));
16 void test_commit_parent__cleanup(void)
18 git_commit_free(commit
);
21 git_repository_free(_repo
);
25 static void assert_nth_gen_parent(unsigned int gen
, const char *expected_oid
)
27 git_commit
*parent
= NULL
;
30 error
= git_commit_nth_gen_ancestor(&parent
, commit
, gen
);
32 if (expected_oid
!= NULL
) {
33 cl_assert_equal_i(0, error
);
34 cl_assert_equal_i(0, git_oid_streq(git_commit_id(parent
), expected_oid
));
36 cl_assert_equal_i(GIT_ENOTFOUND
, error
);
38 git_commit_free(parent
);
43 * commit be3563ae3f795b2b4353bcce3a527ad0a4f7f644
46 * commit 9fd738e8f7967c078dceed8190330fc8648ee56a
49 * commit 5b5b025afb0b4c913b4c338a42934a3863bf3644
52 * fatal: ambiguous argument 'be35~42': unknown revision or path not in the working tree.
54 void test_commit_parent__can_retrieve_nth_generation_parent(void)
56 assert_nth_gen_parent(0, "be3563ae3f795b2b4353bcce3a527ad0a4f7f644");
57 assert_nth_gen_parent(1, "9fd738e8f7967c078dceed8190330fc8648ee56a");
58 assert_nth_gen_parent(3, "5b5b025afb0b4c913b4c338a42934a3863bf3644");
59 assert_nth_gen_parent(42, NULL
);