replace inline code with call to open_commit() helper
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82
diff --git a/lib/commit_graph.c b/lib/commit_graph.c
index 5fb439c..67c8918 100644
--- a/lib/commit_graph.c
+++ b/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;