commit - c4d7a9c4003019cb8f0ef52f8b6d1913eb567917
commit + be6a1b5ad07f0e2c832ce7de6f07c87fbe1935a5
blob - a3645205361df169a60345d7d35787b6b79dd37c
blob + 1f6e4e055123872ec7e6b34a908765fe2bb1abdf
--- include/got_object.h
+++ include/got_object.h
*/
const struct got_error *got_object_blob_read_block(size_t *,
struct got_blob_object *);
+
+const struct got_error *
+got_object_open_as_commit(struct got_commit_object **,
+ struct got_repository *, struct got_object_id *);
+
const struct got_error *got_object_commit_add_parent(struct got_commit_object *,
const char *);
blob - 67c8918b2be0070e47a220e2cfd785093cfceff7
blob + 89f1d2c9389a5e07131a9dc00c552169926ab022
--- lib/commit_graph.c
+++ lib/commit_graph.c
if (err)
return err;
node->nchildren++;
-
- }
-
- return err;
-}
-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;
}
-
const struct got_error *
got_commit_graph_open(struct got_commit_graph **graph,
struct got_object_id *commit_id, struct got_repository *repo)
*graph = NULL;
- err = open_commit(&commit, commit_id, repo);
+ err = got_object_open_as_commit(&commit, repo, commit_id);
if (err)
return err;
commit_id = &branches[i].parent_id;
child_node = branches[i].node;
- err = open_commit(&commit, commit_id, repo);
+ err = got_object_open_as_commit(&commit, repo, commit_id);
if (err)
break;
blob - cc3271a1acd9dc5061a4f6463843bd81ac04b7f5
blob + 498d4c5d14364cf60575dcef5d969848dbb895a8
--- lib/object.c
+++ lib/object.c
}
const struct got_error *
+got_object_open_as_commit(struct got_commit_object **commit,
+ struct got_repository *repo, struct got_object_id *id)
+{
+ 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;
+}
+
+const struct got_error *
got_object_commit_add_parent(struct got_commit_object *commit,
const char *id_str)
{