commit 2e1164be74a2a69f59973a6572b22f36f2479b8e
parent 838aeb555307787a52f971016be35b3d57027f69
Author: brookjeynes <me@brookjeynes.dev>
Date: Thu, 18 Jun 2026 08:06:32 +1000
feat: retrieve commit daterange
Signed-off-by: brookjeynes <me@brookjeynes.dev>
Diffstat:
1 file changed, 12 insertions(+), 2 deletions(-)
diff --git a/main.c b/main.c
@@ -1,7 +1,9 @@
#include <git2.h>
+#include <git2/commit.h>
#include <git2/signature.h>
#include <stdio.h>
#include <string.h>
+#include <time.h>
int main(int argc, char *argv[]) {
int error;
@@ -46,6 +48,9 @@ int main(int argc, char *argv[]) {
exit(error);
}
+ const time_t now = time(NULL);
+ const time_t year_behind = now - (365 * 24 * 60 * 60);
+
git_oid id;
while (!git_revwalk_next(&id, walker)) {
git_commit *commit;
@@ -55,10 +60,15 @@ int main(int argc, char *argv[]) {
exit(error);
}
+ const char *message = git_commit_message(commit);
const git_signature *author = git_commit_author(commit);
+
+ if (author->when.time < year_behind) {
+ break;
+ }
+
if (strcmp(author_email, author->email) == 0) {
- printf("%s <%s> at %ld\n", author->name, author->email,
- author->when.time);
+ printf("%s <%s> -> %s\n", author->name, author->email, message);
}
}