commit 9a2e7ad4870891a7244450ed93be14d82bbd104b from: Sven M. Hallberg <pesco@khjk.org> date: Sat Aug 03 19:45:11 2024 UTC cvg: show author (orig:) timestamp in log Closely mirrors commit 34712e90 that did it for got. commit - e98ec79bc0b070b5256849711710a07b5041f456 commit + 9a2e7ad4870891a7244450ed93be14d82bbd104b blob - 1905092a295380908b5d5a8350e9e6543dd7d183 blob + 88997c4dc6287b86ef27dd022bbeadf189573cb0 --- cvg/cvg.c +++ cvg/cvg.c @@ -3345,7 +3345,7 @@ done: } static char * -get_datestr(time_t *time, char *datebuf) +get_datestr(const time_t *time, char *datebuf) { struct tm mytm, *tm; char *p, *s; @@ -3633,6 +3633,18 @@ printfile(FILE *f) return NULL; } +/* print a date line unless an error occurs (or fail silently) */ +static void +print_date(const char *prefix, const time_t *t) +{ + char datebuf[26]; + char *datestr; + + datestr = get_datestr(t, datebuf); + if (datestr) + printf("%s %s UTC\n", prefix, datestr); +} + static const struct got_error * print_commit(struct got_commit_object *commit, struct got_object_id *id, struct got_repository *repo, const char *path, @@ -3643,9 +3655,8 @@ print_commit(struct got_commit_object *commit, struct { const struct got_error *err = NULL; FILE *f = NULL; - char *id_str, *datestr, *logmsg0, *logmsg, *line; - char datebuf[26]; - time_t committer_time; + char *id_str, *logmsg0, *logmsg, *line; + time_t author_time, committer_time; const char *author, *committer; char *refs_str = NULL; @@ -3675,15 +3686,20 @@ print_commit(struct got_commit_object *commit, struct id_str = NULL; free(refs_str); refs_str = NULL; - printf("from: %s\n", got_object_commit_get_author(commit)); + + /* author and committer data */ author = got_object_commit_get_author(commit); + author_time = got_object_commit_get_author_time(commit); committer = got_object_commit_get_committer(commit); + committer_time = got_object_commit_get_committer_time(commit); + printf("from: %s\n", got_object_commit_get_author(commit)); if (strcmp(author, committer) != 0) printf("via: %s\n", committer); - committer_time = got_object_commit_get_committer_time(commit); - datestr = get_datestr(&committer_time, datebuf); - if (datestr) - printf("date: %s UTC\n", datestr); + print_date("date:", &committer_time); + if (author_time != committer_time) + print_date("orig:", &author_time); + + /* parent commits */ if (got_object_commit_get_nparents(commit) > 1) { const struct got_object_id_queue *parent_ids; struct got_object_qid *qid;