make got log -s show committer date ok op@
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39
diff --git a/got/got.c b/got/got.c
index f8f629a..b5cc0d7 100644
--- a/got/got.c
+++ b/got/got.c
@@ -3895,6 +3895,9 @@ print_commit_oneline(struct got_commit_object *commit, struct got_object_id *id,
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, struct got_object_id *id,
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, struct got_object_id *id,
}
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");