commit - 47cbebdb272710e91aa4dc023336d37b0d9e127f
commit + 1c852fbe888bbdb270dc16ce5a8a32719d94a7b5
blob - fe5aa01903748b62a3fc815ef665067cdafca09f
blob + b2c6877232ce1d6600910ad3fac71fb7afed170a
--- regress/repository/repository_test.c
+++ regress/repository/repository_test.c
#define GOT_REPO_PATH "../../../"
+
+static const struct got_error *
+print_commit_object(struct got_object *obj, struct got_repository *repo)
+{
+ struct got_commit_object *commit;
+ struct got_parent_id *pid;
+ char buf[SHA1_DIGEST_STRING_LENGTH];
+ const struct got_error *err;
+
+ err = got_object_commit_open(&commit, repo, obj);
+ if (err != NULL)
+ return err;
+
+ printf("tree: %s\n",
+ got_object_id_str(&commit->tree_id, buf, sizeof(buf)));
+ printf("parent%s: ", (commit->nparents == 1) ? "" : "s");
+ SIMPLEQ_FOREACH(pid, &commit->parent_ids, entry) {
+ printf("%s\n",
+ got_object_id_str(&pid->id, buf, sizeof(buf)));
+ }
+ printf("author: %s\n", commit->author);
+ printf("committer: %s\n", commit->committer);
+ printf("log: %s\n", commit->logmsg);
+ got_object_commit_close(commit);
+
+ return NULL;
+}
+
static int
repo_read_object_header(const char *repo_path)
{
if (err != NULL || obj == NULL)
return 0;
printf("object type=%d size=%lu\n", obj->type, obj->size);
- if (obj->type == GOT_OBJ_TYPE_COMMIT) {
- struct got_commit_object *commit;
- struct got_parent_id *pid;
-
- err = got_object_commit_open(&commit, repo, obj);
- if (err != NULL || commit == NULL)
- return 0;
- printf("tree: %s\n",
- got_object_id_str(&commit->tree_id, buf, sizeof(buf)));
- printf("parent%s: ", (commit->nparents == 1) ? "" : "s");
- SIMPLEQ_FOREACH(pid, &commit->parent_ids, entry) {
- printf("%s\n",
- got_object_id_str(&pid->id, buf, sizeof(buf)));
- }
- printf("author: %s\n", commit->author);
- printf("committer: %s\n", commit->committer);
- printf("log: %s\n", commit->logmsg);
- got_object_commit_close(commit);
- }
+ if (obj->type == GOT_OBJ_TYPE_COMMIT)
+ print_commit_object(obj, repo);
got_object_close(obj);
free(id);
got_ref_close(head_ref);