Merge pull request #4580 from pks-t/pks/diff-like-git-coalesce blame_git: fix coalescing step never being executed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43
diff --git a/src/blame_git.c b/src/blame_git.c
index 3c221b3..302cd1e 100644
--- a/src/blame_git.c
+++ b/src/blame_git.c
@@ -623,6 +623,8 @@ static void coalesce(git_blame *blame)
int git_blame__like_git(git_blame *blame, uint32_t opt)
{
+ int error = 0;
+
while (true) {
git_blame__entry *ent;
git_blame__origin *suspect = NULL;
@@ -632,13 +634,13 @@ int git_blame__like_git(git_blame *blame, uint32_t opt)
if (!ent->guilty)
suspect = ent->suspect;
if (!suspect)
- return 0; /* all done */
+ break;
/* We'll use this suspect later in the loop, so hold on to it for now. */
origin_incref(suspect);
- if (pass_blame(blame, suspect, opt) < 0)
- return -1;
+ if ((error = pass_blame(blame, suspect, opt)) < 0)
+ break;
/* Take responsibility for the remaining entries */
for (ent = blame->ent; ent; ent = ent->next) {
@@ -652,9 +654,10 @@ int git_blame__like_git(git_blame *blame, uint32_t opt)
origin_decref(suspect);
}
- coalesce(blame);
+ if (!error)
+ coalesce(blame);
- return 0;
+ return error;
}
void git_blame__free_entry(git_blame__entry *ent)