commit - 56765ebba6f171b02b9c44abb6013d5d62ced841
commit + 45d799e2247f32829160ec48664dbccfae98150f
blob - 7cd07bd20aca71218aee61ff7af64ff3311955a5
blob + 9ca1e6c6f71588c3806a731999ac91937c63c1f2
--- got/got.c
+++ got/got.c
struct got_object_qid *qid;
char *id_str1 = NULL, *id_str2;
- err = got_object_open_as_tree(&tree2, repo, commit->tree_id);
+ err = got_object_open_as_tree(&tree2, repo,
+ got_object_commit_get_tree_id(commit));
if (err)
return err;
- qid = SIMPLEQ_FIRST(&commit->parent_ids);
+ qid = SIMPLEQ_FIRST(got_object_commit_get_parent_ids(commit));
if (qid != NULL) {
struct got_commit_object *pcommit;
if (err)
return err;
- err = got_object_open_as_tree(&tree1, repo, pcommit->tree_id);
+ err = got_object_open_as_tree(&tree1, repo,
+ got_object_commit_get_tree_id(pcommit));
got_object_commit_close(pcommit);
if (err)
return err;
const struct got_error *err = NULL;
char *id_str, *datestr, *logmsg0, *logmsg, *line;
char datebuf[26];
+ time_t committer_time;
+ const char *author, *committer;
err = got_object_id_str(&id_str, id);
if (err)
printf("-----------------------------------------------\n");
printf("commit %s\n", id_str);
free(id_str);
- printf("from: %s\n", commit->author);
- datestr = get_datestr(&commit->committer_time, datebuf);
+ printf("from: %s\n", got_object_commit_get_author(commit));
+ committer_time = got_object_commit_get_committer_time(commit);
+ datestr = get_datestr(&committer_time, datebuf);
printf("date: %s UTC\n", datestr);
- if (strcmp(commit->author, commit->committer) != 0)
- printf("via: %s\n", commit->committer);
- if (commit->nparents > 1) {
+ author = got_object_commit_get_author(commit);
+ committer = got_object_commit_get_committer(commit);
+ if (strcmp(author, committer) != 0)
+ printf("via: %s\n", committer);
+ if (got_object_commit_get_nparents(commit) > 1) {
+ const struct got_object_id_queue *parent_ids;
struct got_object_qid *qid;
int n = 1;
- SIMPLEQ_FOREACH(qid, &commit->parent_ids, entry) {
+ parent_ids = got_object_commit_get_parent_ids(commit);
+ SIMPLEQ_FOREACH(qid, parent_ids, entry) {
err = got_object_id_str(&id_str, qid->id);
if (err)
return err;
}
}
- logmsg0 = strdup(commit->logmsg);
+ logmsg0 = strdup(got_object_commit_get_logmsg(commit));
if (logmsg0 == NULL)
return got_error_from_errno();
blob - 4381cdf163f126acf727fe4d81e16d5f4c0ae0d7
blob + af264e30e6836ade853bbfe34bd4abbb3a8e26b6
--- include/got_object.h
+++ include/got_object.h
struct got_blob_object;
struct got_tree_object;
struct got_tag_object;
+struct got_commit_object;
struct got_tree_entry {
SIMPLEQ_ENTRY(got_tree_entry) entry;
struct got_object_id *);
void got_object_qid_free(struct got_object_qid *);
-struct got_commit_object {
- struct got_object_id *tree_id;
- unsigned int nparents;
- struct got_object_id_queue parent_ids;
- char *author;
- time_t author_time; /* UTC */
- time_t author_gmtoff;
- char *committer;
- time_t committer_time; /* UTC */
- time_t committer_gmtoff;
- char *logmsg;
-
- int refcnt; /* for internal use only */
-};
-
/* A generic object. Used as a handle which holds an ID and an object type. */
struct got_object;
#define GOT_OBJ_TYPE_COMMIT 1
/* Dispose of a commit object. */
void got_object_commit_close(struct got_commit_object *);
+/* Obtain the ID of the tree created in a commit. */
+struct got_object_id *got_object_commit_get_tree_id(struct got_commit_object *);
+
+/* Obtain the number of parent commits of a commit. */
+int got_object_commit_get_nparents(struct got_commit_object *);
+
+/* Obtain the list of parent commits of a commit. */
+const struct got_object_id_queue *got_object_commit_get_parent_ids(
+ struct got_commit_object *);
+
+/* Get the author's name and email address. */
+const char *got_object_commit_get_author(struct got_commit_object *);
+
+/* Get an author's commit timestamp. */
+time_t got_object_commit_get_author_time(struct got_commit_object *);
+
+/* Get an author's timezone offset. */
+time_t got_object_commit_get_author_gmtoff(struct got_commit_object *);
+
+/* Get the committer's name and email address. */
+const char *got_object_commit_get_committer(struct got_commit_object *);
+
+/* Get an committer's commit timestamp. */
+time_t got_object_commit_get_committer_time(struct got_commit_object *);
+
+/* Get an committer's timezone offset. */
+time_t got_object_commit_get_committer_gmtoff(struct got_commit_object *);
+
+/* Get the commit log message. */
+const char *got_object_commit_get_logmsg(struct got_commit_object *);
+
/*
* Attempt to open a tree object in a repository.
* The provided object must be of type GOT_OBJ_TYPE_TREE.
blob - 314a74068288ba542806c56894a9a52fd608399d
blob + 9af8a526beb32027acfb0c3d1027c8e543a961be
--- lib/diff.c
+++ lib/diff.c
err = got_object_commit_open(&commit1, repo, obj1);
if (err)
goto done;
- err = got_object_open(&tree_obj1, repo, commit1->tree_id);
+ err = got_object_open(&tree_obj1, repo,
+ got_object_commit_get_tree_id(commit1));
if (err)
goto done;
}
err = got_object_commit_open(&commit2, repo, obj2);
if (err)
goto done;
- err = got_object_open(&tree_obj2, repo, commit2->tree_id);
+ err = got_object_open(&tree_obj2, repo,
+ got_object_commit_get_tree_id(commit2));
if (err)
goto done;
blob - c2619193e47de7f03830953b4c47623aafbbd7fb
blob + 7bcbdfd39b328a04433e376dbf7471f0e48c4482
--- lib/got_lib_object.h
+++ lib/got_lib_object.h
int refcnt; /* > 0 if open and/or cached */
};
+struct got_commit_object {
+ struct got_object_id *tree_id;
+ unsigned int nparents;
+ struct got_object_id_queue parent_ids;
+ char *author;
+ time_t author_time; /* UTC */
+ time_t author_gmtoff;
+ char *committer;
+ time_t committer_time; /* UTC */
+ time_t committer_gmtoff;
+ char *logmsg;
+ int refcnt; /* > 0 if open and/or cached */
+};
+
struct got_tree_object {
struct got_tree_entries entries;
int refcnt;
blob - 433a6598256a2714af7dc3ab5859a6231a30150d
blob + edf8f8d3f1e2d5afcc0926bb3d6edead7609e66b
--- lib/object_parse.c
+++ lib/object_parse.c
free(commit->committer);
free(commit->logmsg);
free(commit);
+}
+
+struct got_object_id *
+got_object_commit_get_tree_id(struct got_commit_object *commit)
+{
+ return commit->tree_id;
+}
+
+int
+got_object_commit_get_nparents(struct got_commit_object *commit)
+{
+ return commit->nparents;
}
+const struct got_object_id_queue *
+got_object_commit_get_parent_ids(struct got_commit_object *commit)
+{
+ return &commit->parent_ids;
+}
+
+const char *
+got_object_commit_get_author(struct got_commit_object *commit)
+{
+ return commit->author;
+}
+
+time_t
+got_object_commit_get_author_time(struct got_commit_object *commit)
+{
+ return commit->author_time;
+}
+
+time_t got_object_commit_get_author_gmtoff(struct got_commit_object *commit)
+{
+ return commit->author_gmtoff;
+}
+
+const char *
+got_object_commit_get_committer(struct got_commit_object *commit)
+{
+ return commit->committer;
+}
+
+time_t
+got_object_commit_get_committer_time(struct got_commit_object *commit)
+{
+ return commit->committer_time;
+}
+
+time_t
+got_object_commit_get_committer_gmtoff(struct got_commit_object *commit)
+{
+ return commit->committer_gmtoff;
+}
+
+const char *
+got_object_commit_get_logmsg(struct got_commit_object *commit)
+{
+ return commit->logmsg;
+}
+
const struct got_error *
got_object_parse_commit(struct got_commit_object **commit, char *buf, size_t len)
{
blob - faf7e0d4c42ae9b366451dd0c514260ed7b37585
blob + 18bc93be414b53dfc38357b8bfab53aa7227ee28
--- regress/repository/repository_test.c
+++ regress/repository/repository_test.c
print_parent_commits(struct got_commit_object *commit,
struct got_repository *repo)
{
+ const struct got_object_id_queue *parent_ids;
struct got_object_qid *qid;
const struct got_error *err = NULL;
struct got_object *obj;
- SIMPLEQ_FOREACH(qid, &commit->parent_ids, entry) {
+ parent_ids = got_object_commit_get_parent_ids(commit);
+ SIMPLEQ_FOREACH(qid, parent_ids, entry) {
err = got_object_open(&obj, repo, qid->id);
if (err != NULL)
return err;
print_commit_object(struct got_object *obj, struct got_repository *repo)
{
struct got_commit_object *commit;
+ const struct got_object_id_queue *parent_ids;
struct got_object_qid *qid;
char *buf;
const struct got_error *err;
if (err)
return err;
- err = got_object_id_str(&buf, commit->tree_id);
+ err = got_object_id_str(&buf, got_object_commit_get_tree_id(commit));
if (err)
return err;
test_printf("tree: %s\n", buf);
free(buf);
- test_printf("parent%s: ", (commit->nparents == 1) ? "" : "s");
- SIMPLEQ_FOREACH(qid, &commit->parent_ids, entry) {
+ test_printf("parent%s: ",
+ (got_object_commit_get_nparents(commit) == 1) ? "" : "s");
+ parent_ids = got_object_commit_get_parent_ids(commit);
+ SIMPLEQ_FOREACH(qid, parent_ids, entry) {
err = got_object_id_str(&buf, qid->id);
if (err)
return err;
test_printf("%s\n", buf);
free(buf);
}
- test_printf("author: %s\n", commit->author);
- test_printf("committer: %s\n", commit->committer);
- test_printf("log: %s\n", commit->logmsg);
+ test_printf("author: %s\n", got_object_commit_get_author(commit));
+ test_printf("committer: %s\n", got_object_commit_get_committer(commit));
+ test_printf("log: %s\n", got_object_commit_get_logmsg(commit));
- err = got_object_open(&treeobj, repo, commit->tree_id);
+ err = got_object_open(&treeobj, repo,
+ got_object_commit_get_tree_id(commit));
if (err != NULL)
return err;
if (got_object_get_type(treeobj) == GOT_OBJ_TYPE_TREE) {
blob - b0d09c8faf17ad7edf5ea5b89ac54e6fab5b77d6
blob + 90bfd8951f9142131facc3e9770db2c4479da161
--- tog/tog.c
+++ tog/tog.c
static const size_t author_display_cols = 16;
const int avail = view->ncols;
struct tm tm;
+ time_t committer_time;
- if (localtime_r(&commit->committer_time, &tm) == NULL)
+ committer_time = got_object_commit_get_committer_time(commit);
+ if (localtime_r(&committer_time, &tm) == NULL)
return got_error_from_errno();
if (strftime(datebuf, sizeof(datebuf), "%g/%m/%d ", &tm)
>= sizeof(datebuf))
if (col > avail)
goto done;
- author0 = strdup(commit->author);
+ author0 = strdup(got_object_commit_get_author(commit));
if (author0 == NULL) {
err = got_error_from_errno();
goto done;
if (col > avail)
goto done;
- logmsg0 = strdup(commit->logmsg);
+ logmsg0 = strdup(got_object_commit_get_logmsg(commit));
if (logmsg0 == NULL) {
err = got_error_from_errno();
goto done;
if (err)
return err;
- parent_id = SIMPLEQ_FIRST(&commit->parent_ids);
+ parent_id = SIMPLEQ_FIRST(got_object_commit_get_parent_ids(commit));
if (parent_id) {
err = got_object_open(&obj1, repo, parent_id->id);
if (err)
struct got_tree_object *tree;
struct tog_view *tree_view;
- err = got_object_open_as_tree(&tree, repo, entry->commit->tree_id);
+ err = got_object_open_as_tree(&tree, repo,
+ got_object_commit_get_tree_id(entry->commit));
if (err)
return err;
char *id_str;
char datebuf[26];
struct got_commit_object *commit = NULL;
+ time_t committer_time;
+ const char *author, *committer;
err = got_object_id_str(&id_str, got_object_get_id(obj));
if (err)
err = got_error_from_errno();
goto done;
}
- if (fprintf(outfile, "from: %s\n", commit->author) < 0) {
+ if (fprintf(outfile, "from: %s\n",
+ got_object_commit_get_author(commit)) < 0) {
err = got_error_from_errno();
goto done;
}
+ committer_time = got_object_commit_get_committer_time(commit);
if (fprintf(outfile, "date: %s UTC\n",
- get_datestr(&commit->committer_time, datebuf)) < 0) {
+ get_datestr(&committer_time, datebuf)) < 0) {
err = got_error_from_errno();
goto done;
}
- if (strcmp(commit->author, commit->committer) != 0 &&
- fprintf(outfile, "via: %s\n", commit->committer) < 0) {
+ author = got_object_commit_get_author(commit);
+ committer = got_object_commit_get_committer(commit);
+ if (strcmp(author, committer) != 0 &&
+ fprintf(outfile, "via: %s\n", committer) < 0) {
err = got_error_from_errno();
goto done;
}
- if (fprintf(outfile, "%s\n", commit->logmsg) < 0) {
+ if (fprintf(outfile, "%s\n",
+ got_object_commit_get_logmsg(commit)) < 0) {
err = got_error_from_errno();
goto done;
}
s->diff_context, s->repo, f);
break;
case GOT_OBJ_TYPE_COMMIT: {
+ const struct got_object_id_queue *parent_ids;
struct got_object_qid *pid;
struct got_commit_object *commit2;
if (err)
break;
/* Show commit info if we're diffing to a parent commit. */
- SIMPLEQ_FOREACH(pid, &commit2->parent_ids, entry) {
+ parent_ids = got_object_commit_get_parent_ids(commit2);
+ SIMPLEQ_FOREACH(pid, parent_ids, entry) {
struct got_object_id *id1 = got_object_get_id(obj1);
if (got_object_id_cmp(id1, pid->id) == 0) {
write_commit_info(obj2, s->repo, f);
if (err)
goto done;
- pid = SIMPLEQ_FIRST(&commit->parent_ids);
+ pid = SIMPLEQ_FIRST(got_object_commit_get_parent_ids(commit));
if (pid) {
err = got_object_open(pobj, repo, pid->id);
if (err)
if (error != NULL)
goto done;
- error = got_object_open_as_tree(&tree, repo, commit->tree_id);
+ error = got_object_open_as_tree(&tree, repo,
+ got_object_commit_get_tree_id(commit));
if (error != NULL)
goto done;