Commit 028d7a4e4c3fbee17ba819b80451fae7636c1ed0

Stefan Sperling 2018-09-19T14:52:32

fix commit graph iteration with just one iter-list entry

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
diff --git a/lib/commit_graph.c b/lib/commit_graph.c
index f71dade..58b872f 100644
--- a/lib/commit_graph.c
+++ b/lib/commit_graph.c
@@ -721,8 +721,12 @@ got_commit_graph_iter_next(struct got_object_id **id,
 	    TAILQ_LAST(&graph->iter_list, got_commit_graph_iter_list) &&
 	    got_object_idset_num_elements(graph->open_branches) == 0) {
 		/* We are done iterating. */
+		if (graph->iter_node == TAILQ_FIRST(&graph->iter_list))
+			*id = &graph->iter_node->id;
+		else
+			*id = NULL;
 		graph->iter_node = NULL;
-		return got_error(GOT_ERR_ITER_COMPLETED);
+		return *id ? NULL : got_error(GOT_ERR_ITER_COMPLETED);
 	}
 
 	if (TAILQ_NEXT(graph->iter_node, entry) == NULL)