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