diff options
| author | Carlos Martín Nieto <cmn@dwim.me> | 2013-09-08 00:52:26 +0200 |
|---|---|---|
| committer | Carlos Martín Nieto <cmn@dwim.me> | 2013-09-09 20:31:14 +0200 |
| commit | 15f7b9b8d9bdfb68ca52d582be40cf6112464e77 (patch) | |
| tree | 5f2654223d4e34d04e3630c0ee95fc02a8d6db4e /tests-clar | |
| parent | ef6389ad504037e7a4311adbf14f1fa5a5aa4190 (diff) | |
| download | libgit2-15f7b9b8d9bdfb68ca52d582be40cf6112464e77.tar.gz | |
revwalk: allow simplifying by first-parent
When enabled, only the first parent of each commit will be queued,
enabling a simple way of using first-parent simplification.
Diffstat (limited to 'tests-clar')
| -rw-r--r-- | tests-clar/revwalk/simplify.c | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/tests-clar/revwalk/simplify.c b/tests-clar/revwalk/simplify.c new file mode 100644 index 000000000..c94952105 --- /dev/null +++ b/tests-clar/revwalk/simplify.c @@ -0,0 +1,51 @@ +#include "clar_libgit2.h" + +/* + * a4a7dce [0] Merge branch 'master' into br2 + |\ + | * 9fd738e [1] a fourth commit + | * 4a202b3 [2] a third commit + * | c47800c [3] branch commit one + |/ + * 5b5b025 [5] another commit + * 8496071 [4] testing +*/ +static const char *commit_head = "a4a7dce85cf63874e984719f4fdd239f5145052f"; + +static const char *expected_str[] = { + "a4a7dce85cf63874e984719f4fdd239f5145052f", /* 0 */ + "c47800c7266a2be04c571c04d5a6614691ea99bd", /* 3 */ + "8496071c1b46c854b31185ea97743be6a8774479", /* 4 */ + "5b5b025afb0b4c913b4c338a42934a3863bf3644", /* 5 */ +}; + +void test_revwalk_simplify__first_parent(void) +{ + git_repository *repo; + git_revwalk *walk; + git_oid id, expected[4]; + int i, error; + + for (i = 0; i < 4; i++) { + git_oid_fromstr(&expected[i], expected_str[i]); + } + + repo = cl_git_sandbox_init("testrepo.git"); + cl_git_pass(git_revwalk_new(&walk, repo)); + + git_oid_fromstr(&id, commit_head); + cl_git_pass(git_revwalk_push(walk, &id)); + git_revwalk_simplify_first_parent(walk); + + i = 0; + while ((error = git_revwalk_next(&id, walk)) == 0) { + git_oid_cmp(&id, &expected[i]); + i++; + } + + cl_assert_equal_i(i, 4); + cl_assert_equal_i(error, GIT_ITEROVER); + + git_revwalk_free(walk); + git_repository_free(repo); +} |
