NAME
Git::Native::Tree - A libgit2 tree object
VERSION
version 0.005
SYNOPSIS
my $tree = $commit->tree;
for my $entry (@{ $tree->entries }) {
say "$entry->{name} -> $entry->{oid}";
}
DESCRIPTION
A libgit2 tree object. Entries are returned as plain hashrefs with name, oid, mode, type.
A Tree is a single directory level, not a recursive listing: an entry of type GIT_OBJECT_TREE is a subdirectory you look up separately with "tree" in Git::Native::Repository.
A Tree taken from a Git::Native::Commit holds its repository, so it outlives the Commit it came from — walking $repo->object($oid)->tree in one expression is safe.
oid
say $tree->oid;
The tree's Git::Native::Oid. Computed on first use.
entrycount
say $tree->entrycount;
Number of entries in this tree level.
entries
for my $e ( @{ $tree->entries } ) {
printf "%06o %s %s\n", $e->{mode}, $e->{oid}, $e->{name};
}
All entries, in libgit2's order, as an arrayref of plain hashrefs. Each carries name (this level only, no path), oid (a Git::Native::Oid), mode (the numeric git filemode — 0100644 for a regular file, 0100755 executable, 0120000 symlink, 040000 a subtree) and type (the git_object_t value: 1 commit, 2 tree, 3 blob, 4 tag — the GIT_OBJECT_* constants exported by Git::Libgit2).
entry_by_name
my $e = $tree->entry_by_name('hello.txt');
The single entry hashref for $name, in the same shape entries returns, or undef when this tree has no such entry. $name is one path component, not a path: 'lib/Foo.pm' does not match.
SEE ALSO
Git::Native::TreeBuilder, Git::Native::Commit, Git::Native::Blob
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.