Commit Diff


commit - daac4478f74fe96633ad055e02d74c781b34270c
commit + 78e82c8a2a2cd0fed316492b18264f5d8727f961
blob - 60384f611195c8632002438feac20a8570779eae
blob + 591ee66b8e3d659624ea402adc5cac155bfd6e21
--- include/got_error.h
+++ include/got_error.h
@@ -59,7 +59,7 @@
 #define GOT_ERR_PACK_OFFSET	42
 #define GOT_ERR_OBJ_EXISTS	43
 #define GOT_ERR_BAD_OBJ_ID	44
-#define GOT_ERR_ITER_BUSY	45
+/* 45 is currently unused */
 #define GOT_ERR_ITER_COMPLETED	46
 #define GOT_ERR_RANGE		47
 #define GOT_ERR_EXPECTED	48 /* for use in regress tests only */
blob - 7838410468b039613a6a79dd0f886d3a3f4d77c9
blob + 514ea5bf403b3a7ac375edcf405ab96bcd94cb20
--- lib/commit_graph.c
+++ lib/commit_graph.c
@@ -559,15 +559,29 @@ got_commit_graph_close(struct got_commit_graph *graph)
 	free(graph);
 }
 
+static const struct got_error *
+remove_branch_tip(struct got_object_id *commit_id, void *data, void *arg)
+{
+	struct got_object_idset *open_branches = arg;
+
+	return got_object_idset_remove(NULL, open_branches, commit_id);
+}
+
 const struct got_error *
 got_commit_graph_iter_start(struct got_commit_graph *graph,
     struct got_object_id *id, struct got_repository *repo,
     got_cancel_cb cancel_cb, void *cancel_arg)
 {
 	const struct got_error *err = NULL;
+	struct got_commit_graph_node *node;
 
-	if (!TAILQ_EMPTY(&graph->iter_list))
-		return got_error(GOT_ERR_ITER_BUSY);
+	/* Clear left-over state from previous iteration attempts. */
+	while ((node = TAILQ_FIRST(&graph->iter_list)))
+		TAILQ_REMOVE(&graph->iter_list, node, entry);
+	err = got_object_idset_for_each(graph->open_branches,
+	    remove_branch_tip, graph->open_branches);
+	if (err)
+		return err;
 
 	err = got_object_idset_add(graph->open_branches, id, NULL);
 	if (err)
blob - bbf6b833ae72af971965e84ef52ef83124c4a492
blob + 711d2054736f85896487ec6f2e7ed54fa6a56048
--- lib/error.c
+++ lib/error.c
@@ -83,7 +83,6 @@ static const struct got_error got_errors[] = {
 	{ GOT_ERR_PACK_OFFSET,	"bad offset in pack file" },
 	{ GOT_ERR_OBJ_EXISTS,	"object already exists" },
 	{ GOT_ERR_BAD_OBJ_ID,	"bad object id" },
-	{ GOT_ERR_ITER_BUSY,	"iteration already in progress" },
 	{ GOT_ERR_ITER_COMPLETED,"iteration completed" },
 	{ GOT_ERR_RANGE,	"value out of range" },
 	{ GOT_ERR_EXPECTED,	"expected an error but have no error" },