commit-heatmap-gen

commit heatmap generator
git clone git://brookjeynes.dev/bjeynes/commit-heatmap-gen.git
Log | Files | Refs | README

commit 838aeb555307787a52f971016be35b3d57027f69
parent 3a7501693588e2df0dd6c03a189007369e53d4d6
Author: brookjeynes <me@brookjeynes.dev>
Date:   Thu, 18 Jun 2026 07:07:09 +1000

feat: walk git tree and retrieve author information

Signed-off-by: brookjeynes <me@brookjeynes.dev>

Diffstat:
Mmain.c | 59++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-
1 file changed, 58 insertions(+), 1 deletion(-)

diff --git a/main.c b/main.c @@ -1,10 +1,67 @@ #include <git2.h> +#include <git2/signature.h> +#include <stdio.h> +#include <string.h> -int main() { +int main(int argc, char *argv[]) { int error; + if (argc == 1) { + fprintf(stderr, "err: author email required\n"); + exit(1); + } + + char *author_email = argv[1]; + git_libgit2_init(); + git_repository *repo = NULL; + if ((error = git_repository_open(&repo, "../jido")) < 0) { + const git_error *e = git_error_last(); + printf("err: %d/%d: %s\n", error, e->klass, e->message); + exit(error); + } + + git_object *obj = NULL; + if ((error = git_revparse_single(&obj, repo, "HEAD")) < 0) { + const git_error *e = git_error_last(); + printf("err: %d/%d: %s\n", error, e->klass, e->message); + exit(error); + } + + const git_oid *head = NULL; + head = git_object_id(obj); + git_object_free(obj); + + git_revwalk *walker = NULL; + if ((error = git_revwalk_new(&walker, repo)) < 0) { + const git_error *e = git_error_last(); + printf("err: %d/%d: %s\n", error, e->klass, e->message); + exit(error); + } + + if ((error = git_revwalk_push(walker, head)) < 0) { + const git_error *e = git_error_last(); + printf("err: %d/%d: %s\n", error, e->klass, e->message); + exit(error); + } + + git_oid id; + while (!git_revwalk_next(&id, walker)) { + git_commit *commit; + if ((error = git_commit_lookup(&commit, repo, &id)) < 0) { + const git_error *e = git_error_last(); + printf("err: %d/%d: %s\n", error, e->klass, e->message); + exit(error); + } + + const git_signature *author = git_commit_author(commit); + if (strcmp(author_email, author->email) == 0) { + printf("%s <%s> at %ld\n", author->name, author->email, + author->when.time); + } + } + git_libgit2_shutdown(); return 0;