diff options
| author | Ben Straub <bs@github.com> | 2013-09-16 16:12:31 -0700 |
|---|---|---|
| committer | Ben Straub <bs@github.com> | 2013-09-16 16:12:31 -0700 |
| commit | 549931679a77b280eb1f36afeda8930eb31d70f7 (patch) | |
| tree | 2744e3e198ad146bae72f35369bbeb4f8028c8c3 /tests-clar/revwalk/simplify.c | |
| parent | 1a68c168a6cdbe0db6e44fb582a7026a7d536c9d (diff) | |
| parent | 8821c9aa5baf31e21c21825e8c91c765e6631e7f (diff) | |
| download | libgit2-549931679a77b280eb1f36afeda8930eb31d70f7.tar.gz | |
Merge branch 'development' into blame_rebased
Conflicts:
include/git2.h
Diffstat (limited to 'tests-clar/revwalk/simplify.c')
| -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); +} |
