Commit 4bd3f2bbb76e22f763d47c525de6f91eafb0c53d

Stefan Sperling 2018-06-11T00:27:10

some commits were missing from the commit graph

diff --git a/lib/commit_graph.c b/lib/commit_graph.c
index 7c351cc..7dd5b8b 100644
--- a/lib/commit_graph.c
+++ b/lib/commit_graph.c
@@ -199,7 +199,7 @@ static const struct got_error *
 add_iteration_candidate(struct got_commit_graph *graph,
     struct got_commit_graph_node *node)
 {
-	struct got_commit_graph_node *n;
+	struct got_commit_graph_node *n, *next;
 	
 	if (TAILQ_EMPTY(&graph->iter_candidates)) {
 		TAILQ_INSERT_TAIL(&graph->iter_candidates, node, entry);
@@ -212,10 +212,24 @@ add_iteration_candidate(struct got_commit_graph *graph,
 		err = compare_commits(&cmp, node->commit, n->commit);
 		if (err)
 			return err;
-		if (cmp < 0)
-			continue;
-		TAILQ_INSERT_BEFORE(n, node, entry);
-		break;
+		if (cmp < 0) {
+			next = TAILQ_NEXT(n, entry);
+			if (next == NULL) {
+				TAILQ_INSERT_AFTER(&graph->iter_candidates, n,
+				    node, entry);
+				break;
+			}
+			err = compare_commits(&cmp, node->commit, next->commit);
+			if (err)
+				return err;
+			if (cmp >= 0) {
+				TAILQ_INSERT_BEFORE(next, node, entry);
+				break;
+			}
+		} else {
+			TAILQ_INSERT_BEFORE(n, node, entry);
+			break;
+		}
 	}
 
 	return NULL;