]>
Commit | Line | Data |
---|---|---|
15f7b9b8 CMN |
1 | #include "clar_libgit2.h" |
2 | ||
3 | /* | |
4 | * a4a7dce [0] Merge branch 'master' into br2 | |
5 | |\ | |
6 | | * 9fd738e [1] a fourth commit | |
7 | | * 4a202b3 [2] a third commit | |
8 | * | c47800c [3] branch commit one | |
9 | |/ | |
10 | * 5b5b025 [5] another commit | |
11 | * 8496071 [4] testing | |
12 | */ | |
13 | static const char *commit_head = "a4a7dce85cf63874e984719f4fdd239f5145052f"; | |
14 | ||
15 | static const char *expected_str[] = { | |
16 | "a4a7dce85cf63874e984719f4fdd239f5145052f", /* 0 */ | |
17 | "c47800c7266a2be04c571c04d5a6614691ea99bd", /* 3 */ | |
18 | "8496071c1b46c854b31185ea97743be6a8774479", /* 4 */ | |
19 | "5b5b025afb0b4c913b4c338a42934a3863bf3644", /* 5 */ | |
20 | }; | |
21 | ||
22 | void test_revwalk_simplify__first_parent(void) | |
23 | { | |
24 | git_repository *repo; | |
25 | git_revwalk *walk; | |
26 | git_oid id, expected[4]; | |
27 | int i, error; | |
28 | ||
29 | for (i = 0; i < 4; i++) { | |
30 | git_oid_fromstr(&expected[i], expected_str[i]); | |
31 | } | |
32 | ||
33 | repo = cl_git_sandbox_init("testrepo.git"); | |
34 | cl_git_pass(git_revwalk_new(&walk, repo)); | |
35 | ||
36 | git_oid_fromstr(&id, commit_head); | |
37 | cl_git_pass(git_revwalk_push(walk, &id)); | |
38 | git_revwalk_simplify_first_parent(walk); | |
39 | ||
40 | i = 0; | |
41 | while ((error = git_revwalk_next(&id, walk)) == 0) { | |
42 | git_oid_cmp(&id, &expected[i]); | |
43 | i++; | |
44 | } | |
45 | ||
46 | cl_assert_equal_i(i, 4); | |
47 | cl_assert_equal_i(error, GIT_ITEROVER); | |
48 | ||
49 | git_revwalk_free(walk); | |
50 | git_repository_free(repo); | |
51 | } |