Commit 7e33c8c53ef5e4d67f3fe59f5f2331ef875e6d53

Stefan Sperling 2020-01-04T21:31:55

no need to open a commit in got_commit_graph_iter_start()

diff --git a/lib/commit_graph.c b/lib/commit_graph.c
index d255fe9..ce6e873 100644
--- a/lib/commit_graph.c
+++ b/lib/commit_graph.c
@@ -480,18 +480,13 @@ got_commit_graph_iter_start(struct got_commit_graph *graph,
     got_cancel_cb cancel_cb, void *cancel_arg)
 {
 	const struct got_error *err = NULL;
-	struct got_commit_object *commit;
 
 	if (!TAILQ_EMPTY(&graph->iter_list))
 		return got_error(GOT_ERR_ITER_BUSY);
 
-	err = got_object_open_as_commit(&commit, repo, id);
-	if (err)
-		return err;
-
 	err = got_object_idset_add(graph->open_branches, id, NULL);
 	if (err)
-		goto done;
+		return err;
 
 	/* Locate first commit which changed graph->path. */
 	while (graph->iter_node == NULL &&
@@ -499,11 +494,10 @@ got_commit_graph_iter_start(struct got_commit_graph *graph,
 		err = fetch_commits_from_open_branches(graph, repo,
 		    cancel_cb, cancel_arg);
 		if (err)
-			break;
+			return err;
 	}
-done:
-	got_object_commit_close(commit);
-	return err;
+
+	return NULL;
 }
 
 const struct got_error *