Commit Diff


commit - d415e120d8f07423e264782724cce6af29c6432f
commit + 028d7a4e4c3fbee17ba819b80451fae7636c1ed0
blob - f71dade8771c97c99210c811c7d73b1112486624
blob + 58b872fd9b4a151a1ff40b597af8a9412d9f5b3b
--- lib/commit_graph.c
+++ 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)