diff options
Diffstat (limited to 'tests/blame/simple.c')
-rw-r--r-- | tests/blame/simple.c | 27 |
1 files changed, 23 insertions, 4 deletions
diff --git a/tests/blame/simple.c b/tests/blame/simple.c index 79bd56b83..83e5e056b 100644 --- a/tests/blame/simple.c +++ b/tests/blame/simple.c @@ -135,13 +135,17 @@ void test_blame_simple__trivial_libgit2(void) git_blame_options opts = GIT_BLAME_OPTIONS_INIT; git_object *obj; - cl_git_pass(git_repository_open(&g_repo, cl_fixture("../.."))); + /* If we can't open the libgit2 repo or if it isn't a full repo + * with proper history, just skip this test */ + if (git_repository_open(&g_repo, cl_fixture("../..")) < 0) + cl_skip(); - /* This test can't work on a shallow clone */ if (git_repository_is_shallow(g_repo)) - return; + cl_skip(); + + if (git_revparse_single(&obj, g_repo, "359fc2d") < 0) + cl_skip(); - cl_git_pass(git_revparse_single(&obj, g_repo, "359fc2d")); git_oid_cpy(&opts.newest_commit, git_object_id(obj)); git_object_free(obj); @@ -303,3 +307,18 @@ void test_blame_simple__can_restrict_to_newish_commits(void) check_blame_hunk_index(g_repo, g_blame, 0, 1, 1, 1, "be3563a", "branch_file.txt"); check_blame_hunk_index(g_repo, g_blame, 1, 2, 1, 0, "a65fedf", "branch_file.txt"); } + +void test_blame_simple__can_restrict_to_first_parent_commits(void) +{ + git_blame_options opts = GIT_BLAME_OPTIONS_INIT; + opts.flags |= GIT_BLAME_FIRST_PARENT; + + cl_git_pass(git_repository_open(&g_repo, cl_fixture("blametest.git"))); + + cl_git_pass(git_blame_file(&g_blame, g_repo, "b.txt", &opts)); + cl_assert_equal_i(4, git_blame_get_hunk_count(g_blame)); + check_blame_hunk_index(g_repo, g_blame, 0, 1, 4, 0, "da237394", "b.txt"); + check_blame_hunk_index(g_repo, g_blame, 1, 5, 1, 1, "b99f7ac0", "b.txt"); + check_blame_hunk_index(g_repo, g_blame, 2, 6, 5, 0, "63d671eb", "b.txt"); + check_blame_hunk_index(g_repo, g_blame, 3, 11, 5, 0, "bc7c5ac2", "b.txt"); +} |