Subject: [PATCH 5/5] Avoid queuing commits multiple times for the same origin

From: David Kastrup <[email-masked]>
Date: Mon, 3 Feb 2014 20:14:09 +0100

---
 builtin/blame.c | 13 ++++++++++---
 1 file changed, 10 insertions(+), 3 deletions(-)

diff --git a/builtin/blame.c b/builtin/blame.c
index 0188115..80345db 100644
--- a/builtin/blame.c
+++ b/builtin/blame.c
@@ -928,9 +928,12 @@ static int pass_blame_to_parent(struct scoreboard *sb,
 	/* The rest are the same as the parent */
 	blame_chunk(&d.dstq, &d.srcq, INT_MAX, d.offset, INT_MAX, target, parent);
 	*d.dstq = NULL;
-	parent->suspects = blame_merge(parent->suspects, newdest);
 	if (parent->suspects)
+		parent->suspects = blame_merge(parent->suspects, newdest);
+	else if (newdest) {
+		parent->suspects = newdest;
 		prio_queue_put(&sb->commits, parent->commit);
+	}
 
 	return 0;
 }
@@ -1303,8 +1306,12 @@ static void pass_whole_blame(struct scoreboard *sb,
 		origin_decref(e->suspect);
 		e->suspect = porigin;
 	}
-	porigin->suspects = blame_merge(porigin->suspects, suspects);
-	prio_queue_put(&sb->commits, porigin->commit);
+	if (porigin->suspects)
+		porigin->suspects = blame_merge(porigin->suspects, suspects);
+	else if (suspects) {
+		porigin->suspects = suspects;
+		prio_queue_put(&sb->commits, porigin->commit);
+	}
 }
 
 /*
-- 
1.8.3.2