baseline

yet another open-source distributed versioning control system
Log | Files | Refs

commit a7b172257f8a12ec768cdad95013486ba761ab22
parent 979c284928e43915f93a863f770e977c2e1532f4
Author: Mohamed Aslan <maslan@sce.carleton.ca>
Date:   Mon,  9 Jun 2014 21:50:30 -0400

add support for commit time

Diffstat:
Mcmd-log.c | 2+-
Mhelper.c | 4++++
Mobjects.c | 12++++++------
Mobjects.h | 6++++--
4 files changed, 15 insertions(+), 9 deletions(-)

diff --git a/cmd-log.c b/cmd-log.c @@ -37,7 +37,7 @@ cmd_log(int argc, char **argv) .author.email = "maslan@maslan.info", .committer.name = "mohamed", .committer.email = "maslan@maslan.info", - .message = "XXXLARAXXX" + .message = "Hello World!" }; x = baseline_commit_serialize(&tmp); printf("%s", x); diff --git a/helper.c b/helper.c @@ -45,8 +45,12 @@ baseline_helper_commit_build(struct dircache_ctx *dc_ctx, const char *dir_id, co comm->dir = strdup(dir_id); comm->author.name = strdup(user_name); comm->author.email = strdup(user_email); + if ((comm->author.timestamp = time(NULL)) == (time_t)-1) + return NULL; comm->committer.name = strdup(user_name); comm->committer.email = strdup(user_email); + if ((comm->committer.timestamp = time(NULL)) == (time_t)-1) + return NULL; if (parent_head != NULL) { comm->parents[0] = strdup(parent_head); comm->n_parents = 1; diff --git a/objects.c b/objects.c @@ -73,13 +73,13 @@ baseline_commit_serialize(struct commit *comm) if (comm == NULL) goto ret; if (comm->n_parents == 0) - asprintf(&raw, "dir %s\nauthor %s <%s>\ncommitter %s <%s>\n%s\n", - comm->dir, comm->author.name, comm->author.email, - comm->committer.name, comm->committer.email, comm->message); + asprintf(&raw, "dir %s\nauthor %s <%s> %llu\ncommitter %s <%s> %llu\n%s\n", + comm->dir, comm->author.name, comm->author.email, comm->author.timestamp, + comm->committer.name, comm->committer.email, comm->committer.timestamp, comm->message); else if (comm->n_parents == 1) - asprintf(&raw, "dir %s\nparent %s\nauthor %s <%s>\ncommitter %s <%s>\n%s\n", - comm->dir, comm->parents[0], comm->author.name, comm->author.email, - comm->committer.name, comm->committer.email, comm->message); + asprintf(&raw, "dir %s\nparent %s\nauthor %s <%s> %llu\ncommitter %s <%s> %llu\n%s\n", + comm->dir, comm->parents[0], comm->author.name, comm->author.email, comm->author.timestamp, + comm->committer.name, comm->committer.email, comm->committer.timestamp, comm->message); /* TODO: support more than 1 parent */ ret: return raw; diff --git a/objects.h b/objects.h @@ -18,6 +18,7 @@ #define _OBJECTS_H_ #include <fcntl.h> +#include <time.h> #define MAX_PARENTS 1 @@ -31,10 +32,11 @@ enum objtype { struct user { char *name; char *email; + time_t timestamp; }; struct commit { - char *id; /* do we really need that? */ + char *id; char *dir; struct user author; struct user committer; @@ -56,7 +58,7 @@ struct dirent { struct dir { char *id; - struct dir *parent; /* currently unused */ + struct dir *parent; struct dirent *children; };