Commit Diff


commit - 79f35eb3b4364a05179d249cab971e1cd4f061aa
commit + c4d7a9c4003019cb8f0ef52f8b6d1913eb567917
blob - 5fb439cf2ac937396e49f91d4a55d40e4735c38d
blob + 67c8918b2be0070e47a220e2cfd785093cfceff7
--- lib/commit_graph.c
+++ lib/commit_graph.c
@@ -263,27 +263,38 @@ add_node(struct got_commit_graph_node **new_node,
 	return err;
 }
 
-const struct got_error *
-got_commit_graph_open(struct got_commit_graph **graph,
-    struct got_object_id *commit_id, struct got_repository *repo)
+static const struct got_error *
+open_commit(struct got_commit_object **commit, struct got_object_id *id,
+    struct got_repository *repo)
 {
-	const struct got_error *err = NULL;
+	const struct got_error *err;
 	struct got_object *obj;
-	struct got_commit_object *commit;
 
-	*graph = NULL;
-
-	err = got_object_open(&obj, repo, commit_id);
+	err = got_object_open(&obj, repo, id);
 	if (err)
 		return err;
 	if (got_object_get_type(obj) != GOT_OBJ_TYPE_COMMIT) {
 		err = got_error(GOT_ERR_OBJ_TYPE);
-		got_object_close(obj);
-		return err;
+		goto done;
 	}
 
-	err = got_object_commit_open(&commit, repo, obj);
+	err = got_object_commit_open(commit, repo, obj);
+done:
 	got_object_close(obj);
+	return err;
+}
+
+
+const struct got_error *
+got_commit_graph_open(struct got_commit_graph **graph,
+    struct got_object_id *commit_id, struct got_repository *repo)
+{
+	const struct got_error *err = NULL;
+	struct got_commit_object *commit;
+
+	*graph = NULL;
+
+	err = open_commit(&commit, commit_id, repo);
 	if (err)
 		return err;
 
@@ -304,27 +315,6 @@ got_commit_graph_open(struct got_commit_graph **graph,
 	return NULL;
 }
 
-static const struct got_error *
-open_commit(struct got_commit_object **commit, struct got_object_id *id,
-    struct got_repository *repo)
-{
-	const struct got_error *err;
-	struct got_object *obj;
-
-	err = got_object_open(&obj, repo, id);
-	if (err)
-		return err;
-	if (got_object_get_type(obj) != GOT_OBJ_TYPE_COMMIT) {
-		err = got_error(GOT_ERR_OBJ_TYPE);
-		goto done;
-	}
-
-	err = got_object_commit_open(commit, repo, obj);
-done:
-	got_object_close(obj);
-	return err;
-}
-
 struct got_commit_graph_branch {
 	struct got_object_id parent_id;
 	struct got_commit_graph_node *node;