diff options
author | Runxi Yu <me@runxiyu.org> | 2025-04-03 15:35:05 +0800 |
---|---|---|
committer | Runxi Yu <me@runxiyu.org> | 2025-04-03 15:35:05 +0800 |
commit | 7350d609085a23a011a613fdec1a2ae2757a1f02 (patch) | |
tree | 3ae898d1c7af04b524340eca4c48a0c8fecf5ef6 /git2d | |
parent | git2d: Report recent commits too (diff) | |
download | forge-7350d609085a23a011a613fdec1a2ae2757a1f02.tar.gz forge-7350d609085a23a011a613fdec1a2ae2757a1f02.tar.zst forge-7350d609085a23a011a613fdec1a2ae2757a1f02.zip |
git2d: Clean up commit author date/etc handling, and add email
Diffstat (limited to 'git2d')
-rw-r--r-- | git2d/main.c | 26 |
1 files changed, 14 insertions, 12 deletions
diff --git a/git2d/main.c b/git2d/main.c index a795695..5301a67 100644 --- a/git2d/main.c +++ b/git2d/main.c @@ -152,13 +152,6 @@ session(void *_conn) const char *msg = git_commit_summary(commit); const git_signature *author = git_commit_author(commit); - time_t time = git_commit_time(commit); - char timebuf[64]; - struct tm *tm = localtime(&time); - if (tm) - strftime(timebuf, sizeof(timebuf), "%Y-%m-%d %H:%M:%S", tm); - else - strcpy(timebuf, "unknown"); /* ID */ bare_put_data(&writer, oid.id, GIT_OID_RAWSZ); @@ -167,14 +160,23 @@ session(void *_conn) size_t msg_len = msg ? strlen(msg) : 0; bare_put_data(&writer, (const uint8_t *)(msg ? msg : ""), msg_len); - /* Author */ + /* Author's name */ const char *author_name = author ? author->name : ""; - size_t author_len = strlen(author_name); - bare_put_data(&writer, (const uint8_t *)author_name, author_len); + bare_put_data(&writer, (const uint8_t *)author_name, strlen(author_name)); + + /* Author's email */ + const char *author_email = author ? author->email : ""; + bare_put_data(&writer, (const uint8_t *)author_email, strlen(author_email)); /* Author's date */ - size_t time_len = strlen(timebuf); - bare_put_data(&writer, (const uint8_t *)timebuf, time_len); + time_t time = git_commit_time(commit); + char timebuf[64]; + struct tm *tm = localtime(&time); + if (tm) + strftime(timebuf, sizeof(timebuf), "%Y-%m-%d %H:%M:%S", tm); + else + strcpy(timebuf, "unknown"); + bare_put_data(&writer, (const uint8_t *)timebuf, strlen(timebuf)); git_commit_free(commit); count++; |