Commit 9b88e78ce7dfa88adba6acc7e68ae6fa557d48d1

Stefan Sperling 2018-11-18T23:08:01

don't add duplicates to commit graph's open branches set

diff --git a/lib/commit_graph.c b/lib/commit_graph.c
index be53a12..5e0f786 100644
--- a/lib/commit_graph.c
+++ b/lib/commit_graph.c
@@ -283,10 +283,11 @@ advance_branch(struct got_commit_graph *graph,
 
 	if (graph->flags & GOT_COMMIT_GRAPH_FIRST_PARENT_TRAVERSAL) {
 		qid = SIMPLEQ_FIRST(&commit->parent_ids);
-		if (qid == NULL)
+		if (qid == NULL ||
+		    got_object_idset_get(graph->open_branches, qid->id))
 			return NULL;
-		err = got_object_idset_add(graph->open_branches, qid->id, node);
-		return err;
+		return got_object_idset_add(graph->open_branches,
+		    qid->id, node);
 	}
 
 	/*
@@ -307,6 +308,8 @@ advance_branch(struct got_commit_graph *graph,
 
 			if (got_object_idset_get(graph->node_ids, qid->id))
 				continue; /* parent already traversed */
+			if (got_object_idset_get(graph->open_branches, qid->id))
+				continue;
 
 			err = got_object_id_by_path(&id, repo, qid->id,
 			    graph->path);