commit 4bb494d57939f42bed86833b18d100c54b234533 from: Stefan Sperling date: Sat Jun 16 17:24:46 2018 UTC display UTC commit timestamps in tog(1) commit - 788c352e1f3b00dfa5628e7ccfcfb056433c1948 commit + 4bb494d57939f42bed86833b18d100c54b234533 blob - a80083bfb47f68f00c32b5b01618c6fbc9aa66a7 blob + cdf523b6507a59b3fd3dda104d5d87083b7af51c --- got/got.c +++ got/got.c @@ -306,7 +306,7 @@ print_patch(struct got_commit_object *commit, struct g return err; } -char * +static char * get_datestr(time_t *time, char *datebuf) { char *p, *s = ctime_r(time, datebuf); blob - 2bfa94efc96d98d4217ff31fdc7f3eef4ff8b729 blob + 94feecd2d6cb9b1250f7594b6f9f27977135dfa6 --- lib/diff.c +++ lib/diff.c @@ -497,6 +497,16 @@ done: if (tree2) got_object_tree_close(tree2); return err; +} + +static char * +get_datestr(time_t *time, char *datebuf) +{ + char *p, *s = ctime_r(time, datebuf); + p = strchr(s, '\n'); + if (p) + *p = '\0'; + return s; } const struct got_error * @@ -507,6 +517,8 @@ got_diff_objects_as_commits(struct got_object *obj1, s struct got_commit_object *commit1 = NULL, *commit2 = NULL; struct got_object *tree_obj1 = NULL, *tree_obj2 = NULL; char *id_str; + char datebuf[26]; + time_t time; if (obj2 == NULL) return got_error(GOT_ERR_NO_OBJ); @@ -535,12 +547,16 @@ got_diff_objects_as_commits(struct got_object *obj1, s goto done; } free(id_str); - if (fprintf(outfile, "author: %s\n", commit2->author) < 0) { + time = mktime(&commit2->tm_author); + if (fprintf(outfile, "author: %s %s UTC\n", commit2->author, + get_datestr(&time, datebuf)) < 0) { err = got_error_from_errno(); goto done; } + time = mktime(&commit2->tm_committer); if (strcmp(commit2->author, commit2->committer) != 0 && - fprintf(outfile, "committer: %s\n", commit2->committer) < 0) { + fprintf(outfile, "committer: %s %s UTC\n", commit2->committer, + get_datestr(&time, datebuf)) < 0) { err = got_error_from_errno(); goto done; }