commit - 3fe1abad43f057903efb7980e29ce93af766891e
commit + 6e790f45d64975dc0b774d672fa3577dfcfafdc9
blob - 54d808ec2c08ac0e57c12400068fb20edd2302b2
blob + 6a104bbde53b6ab5aa419027b762dc8b49c7426a
--- include/got_object.h
+++ include/got_object.h
/* Dispose of a commit object. */
void got_object_commit_close(struct got_commit_object *);
+/* Get the commit's committer timestamp (in UTC). */
+const struct got_error *got_object_commit_get_committer_time(time_t *,
+ struct got_commit_object *);
+
+/* Get the commit's author timestamp (in UTC). */
+const struct got_error *got_object_commit_get_committer_time(time_t *,
+ 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 - 7dd5b8be427df3a57ec980255b2022c804e2f12d
blob + 5d6edcfd4343961cb8e7b00e4596e9d0fff68613
--- lib/commit_graph.c
+++ lib/commit_graph.c
is_root_node(struct got_commit_graph_node *node)
{
return node->commit->nparents == 0;
-}
-
-static const struct got_error *
-parse_commit_time(int64_t *time, struct got_commit_object *commit)
-{
- const struct got_error *err = NULL;
- const char *errstr;
- char *committer, *space;
-
- *time = 0;
-
- committer = strdup(commit->committer);
- if (committer == NULL)
- return got_error_from_errno();
-
- /* Strip off trailing timezone indicator. */
- space = strrchr(committer, ' ');
- if (space == NULL) {
- err = got_error(GOT_ERR_BAD_OBJ_DATA);
- goto done;
- }
- *space = '\0';
-
- /* Timestamp is separated from committer name + email by space. */
- space = strrchr(committer, ' ');
- if (space == NULL) {
- err = got_error(GOT_ERR_BAD_OBJ_DATA);
- goto done;
- }
-
- *time = strtonum(space + 1, 0, INT64_MAX, &errstr);
- if (errstr)
- err = got_error(GOT_ERR_BAD_OBJ_DATA);
-
-done:
- free(committer);
- return err;
}
static const struct got_error *
const struct got_error *err;
int64_t t1, t2;
- err = parse_commit_time(&t1, c1);
+ err = got_object_commit_get_committer_time(&t1, c1);
if (err)
return err;
- err = parse_commit_time(&t2, c2);
+ err = got_object_commit_get_committer_time(&t2, c2);
+
if (err)
return err;
blob - fd3ef97d777386e079ab697ef1959196c6ac765e
blob + 679abeccb798c260183c7938c2b076e5824d5197
--- lib/object.c
+++ lib/object.c
}
return err;
}
+
+static const struct got_error *
+parse_commit_time(time_t *time, const char *author_str)
+{
+ const struct got_error *err = NULL;
+ const char *errstr;
+ char *committer, *space;
+ *time = 0;
+
+ committer = strdup(author_str);
+ if (committer == NULL)
+ return got_error_from_errno();
+
+ /* Strip off trailing timezone indicator. */
+ space = strrchr(committer, ' ');
+ if (space == NULL) {
+ err = got_error(GOT_ERR_BAD_OBJ_DATA);
+ goto done;
+ }
+ *space = '\0';
+
+ /* Timestamp is separated from committer name + email by space. */
+ space = strrchr(committer, ' ');
+ if (space == NULL) {
+ err = got_error(GOT_ERR_BAD_OBJ_DATA);
+ goto done;
+ }
+
+ *time = strtonum(space + 1, 0, INT64_MAX, &errstr);
+ if (errstr)
+ err = got_error(GOT_ERR_BAD_OBJ_DATA);
+
+done:
+ free(committer);
+ return err;
+}
+
+const struct got_error *
+got_object_commit_get_committer_time(time_t *time,
+ struct got_commit_object *commit)
+{
+ return parse_commit_time(time, commit->committer);
+}
+
+const struct got_error *
+got_object_commit_get_author_time(time_t *time,
+ struct got_commit_object *commit)
+{
+ return parse_commit_time(time, commit->committer);
+}
+
static void
tree_entry_close(struct got_tree_entry *te)
{