gout

A static git page generator
git clone https://git.bracken.jp/gout.git
Log | Files | Refs | README | LICENSE

commit 3b21517176e95c8b36f4329819005f7bcd897af0
parent 5a9f587bdc6c31930ea51b8dcf8a4b9d50468ed7
Author: Chris Bracken <chris@bracken.jp>
Date:   Tue, 17 Feb 2026 18:02:23 +0900

commit: remove git_commit field from struct

Diffstat:
Msrc/git/commit.c | 26+++++++++++++-------------
1 file changed, 13 insertions(+), 13 deletions(-)

diff --git a/src/git/commit.c b/src/git/commit.c @@ -30,36 +30,36 @@ struct GitCommit { size_t delcount; size_t filecount; - git_commit* commit; git_diff* diff; }; GitCommit* gitcommit_create(const git_oid* oid, git_repository* repo) { GitCommit* commit = ecalloc(1, sizeof(GitCommit)); - if (git_commit_lookup(&commit->commit, repo, oid)) { + git_commit* gcommit = NULL; + if (git_commit_lookup(&gcommit, repo, oid)) { errx(1, "git_commit_lookup"); } // Get OID, parent OID. commit->oid = ecalloc(GIT_OID_SHA1_HEXSIZE + 1, sizeof(char)); git_oid_tostr(commit->oid, GIT_OID_SHA1_HEXSIZE + 1, - git_commit_id(commit->commit)); + git_commit_id(gcommit)); commit->parentoid = ecalloc(GIT_OID_SHA1_HEXSIZE + 1, sizeof(char)); git_oid_tostr(commit->parentoid, GIT_OID_SHA1_HEXSIZE + 1, - git_commit_parent_id(commit->commit, 0)); + git_commit_parent_id(gcommit, 0)); // Set commit summary, message. - const char* summary = git_commit_summary(commit->commit); + const char* summary = git_commit_summary(gcommit); commit->summary = summary ? estrdup(summary) : NULL; - const char* message = git_commit_message(commit->commit); + const char* message = git_commit_message(gcommit); commit->message = message ? estrdup(message) : NULL; // Get commit time, tz offset. - commit->commit_time = git_commit_time(commit->commit); - commit->commit_timezone_offset = git_commit_time_offset(commit->commit); + commit->commit_time = git_commit_time(gcommit); + commit->commit_timezone_offset = git_commit_time_offset(gcommit); // Get author info. - const git_signature* author = git_commit_author(commit->commit); + const git_signature* author = git_commit_author(gcommit); commit->author_name = author->name ? estrdup(author->name) : NULL; commit->author_email = author->email ? estrdup(author->email) : NULL; commit->author_time = author->when.time; @@ -67,14 +67,14 @@ GitCommit* gitcommit_create(const git_oid* oid, git_repository* repo) { // Look up commit tree. git_tree* commit_tree = NULL; - if (git_tree_lookup(&commit_tree, repo, git_commit_tree_id(commit->commit))) { + if (git_tree_lookup(&commit_tree, repo, git_commit_tree_id(gcommit))) { errx(1, "git_tree_lookup"); } // Look up parent tree, if there is a parent commit. git_commit* parent = NULL; git_tree* parent_tree = NULL; - if (!git_commit_parent(&parent, commit->commit, 0)) { + if (!git_commit_parent(&parent, gcommit, 0)) { if (git_tree_lookup(&parent_tree, repo, git_commit_tree_id(parent))) { errx(1, "git_tree_lookup"); } @@ -131,6 +131,8 @@ GitCommit* gitcommit_create(const git_oid* oid, git_repository* repo) { } commit->deltas_len = deltas_out_count; commit->filecount = deltas_len; + + git_commit_free(gcommit); return commit; } @@ -153,8 +155,6 @@ void gitcommit_free(GitCommit* commit) { git_diff_free(commit->diff); commit->diff = NULL; - git_commit_free(commit->commit); - commit->commit = NULL; free(commit); }