NAME

Git::Native::Commit - A libgit2 commit object

VERSION

version 0.005

SYNOPSIS

my $commit = $repo->commit($oid);
say $commit->message;
say $commit->summary;
say scalar gmtime $commit->time;
say $commit->tree_oid;

DESCRIPTION

A libgit2 commit object exposing oid, message, summary, time (Unix epoch), time_offset (minutes east of UTC), tree, tree_oid, parent_count, parent_oids.

Obtained from "commit" in Git::Native::Repository or "object" in Git::Native::Repository; created with "commit_create" in Git::Native::Repository, which returns the new OID rather than a Commit. A Commit keeps its repository alive, and so does the Git::Native::Tree it hands out — the tree outlives the commit it came from.

oid

say $commit->oid;

The commit's own Git::Native::Oid. Computed on first use.

message

print $commit->message;

The full commit message, as stored — including the trailing newline and any body paragraphs.

summary

say $commit->summary;   # 'add greeting'

The first paragraph of the message with whitespace collapsed, the same thing git log --oneline shows. libgit2 does the extraction.

time

say scalar gmtime $commit->time;

The committer timestamp as Unix epoch seconds, in UTC. The author time is not exposed.

time_offset

printf "%+03d%02d\n", $commit->time_offset / 60, $commit->time_offset % 60;

The committer's timezone offset in minutes east of UTC (120 for +0200), which is what time was recorded against. Git stores it for display only; time is already UTC and needs no correction.

tree

my $tree = $commit->tree;

The commit's root Git::Native::Tree, looked up in the repository.

tree_oid

say $commit->tree_oid;

The root tree's Git::Native::Oid without loading the tree object.

parent_count

say $commit->parent_count;   # 0 root, 1 normal, 2+ merge

Number of parents.

parent_oids

for my $p ( @{ $commit->parent_oids } ) { ... }

Arrayref of the parents' Git::Native::Oids in commit order, so ->[0] is the first parent. Empty for a root commit.

SEE ALSO

Git::Native::Repository, Git::Native::Tree, Git::Native::Revwalker

SUPPORT

Issues

Please report bugs and feature requests on GitHub at https://github.com/Getty/p5-git-native/issues.

CONTRIBUTING

Contributions are welcome! Please fork the repository and submit a pull request.

AUTHOR

Torsten Raudssus <getty@cpan.org>

COPYRIGHT AND LICENSE

This software is copyright (c) 2026 by Torsten Raudssus <torsten@raudssus.de> https://raudssus.de/.

This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.