Commit 0276f0f55bf24dc5e0f49612106c1091381033f9

Juan Rubén 2014-02-26T19:22:19

Reset num_parents to 1 only for merge commits Also, correct test case to account for the boundary flag

diff --git a/src/blame_git.c b/src/blame_git.c
index c275293..72afb85 100644
--- a/src/blame_git.c
+++ b/src/blame_git.c
@@ -489,7 +489,7 @@ static void pass_blame(git_blame *blame, git_blame__origin *origin, uint32_t opt
 	if (!git_oid_cmp(git_commit_id(commit), &blame->options.oldest_commit))
 		/* Stop at oldest specified commit */
 		num_parents = 0;
-	else if (opt & GIT_BLAME_FIRST_PARENT)
+	else if (opt & GIT_BLAME_FIRST_PARENT && num_parents > 1)
 		/* Limit search to the first parent */
 		num_parents = 1;
 
diff --git a/tests/blame/simple.c b/tests/blame/simple.c
index 18b3457..11ff4cd 100644
--- a/tests/blame/simple.c
+++ b/tests/blame/simple.c
@@ -314,7 +314,7 @@ void test_blame_simple__can_restrict_to_first_parent_commits(void)
 	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, 0, "b99f7ac0", "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");
 }