commit d91e053539d7b792ea587fe510d514642396db55 from: Stefan Sperling date: Mon Jun 13 09:37:38 2022 UTC make got log -s show committer date ok op@ commit - 4cac2b4e3f60c45b2a6550d4b15730d172eab925 commit + d91e053539d7b792ea587fe510d514642396db55 blob - f8f629aca02cc89d790c9c76f79a3a2704601f97 blob + b5cc0d766589d88610458ba52595511cd0f39987 --- got/got.c +++ got/got.c @@ -3895,6 +3895,9 @@ print_commit_oneline(struct got_commit_object *commit, char *ref_str = NULL, *id_str = NULL, *logmsg0 = NULL; char *comma, *s, *nl; struct got_reflist_head *refs; + char datebuf[12]; /* YYYY-MM-DD + SPACE + NUL */ + struct tm tm; + time_t committer_time; refs = got_reflist_object_id_map_lookup(refs_idmap, id); if (refs) { @@ -3913,6 +3916,12 @@ print_commit_oneline(struct got_commit_object *commit, return err; } + committer_time = got_object_commit_get_committer_time(commit); + if (gmtime_r(&committer_time, &tm) == NULL) + return got_error_from_errno("gmtime_r"); + if (strftime(datebuf, sizeof(datebuf), "%G-%m-%d ", &tm) == 0) + return got_error(GOT_ERR_NO_SPACE); + err = got_object_commit_get_logmsg(&logmsg0, commit); if (err) goto done; @@ -3927,9 +3936,9 @@ print_commit_oneline(struct got_commit_object *commit, } if (ref_str) - printf("%-7s %s\n", ref_str, s); + printf("%s%-7s %s\n", datebuf, ref_str, s); else - printf("%.7s %s\n", id_str, s); + printf("%s%.7s %s\n", datebuf, id_str, s); if (fflush(stdout) != 0 && err == NULL) err = got_error_from_errno("fflush");