Skip to content

Getty/p5-git-native

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

18 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Git::Native

Native Git for Perl via libgit2 — no fork/exec, no XS.

An idiomatic Moo wrapper over Git::Libgit2 (which binds libgit2 through FFI::Platypus via Alien::Libgit2). Git work runs in-process — no git subprocess per operation.

Why it exists

Use it instead of Git::Wrapper or Git::Repository when you want Git operations without forking the git binary every time.

Git::Native gives you RAII handle management: child objects hold a strong reference to their parent, and handles are freed via DESTROY so there is no use-after-free.

Synopsis

use Git::Native;

my $repo = Git::Native->open('/path/to/.git');
my $main = $repo->reference('refs/heads/main');
say $main->target;     # commit OID

# Build a commit without forking git
my $blob_oid = $repo->blob_create_frombuffer("hello\n");
my $tb       = $repo->tree_builder;
$tb->insert(name => 'hi.txt', oid => $blob_oid, mode => 0100644);
my $tree_oid = $tb->write;
my $commit_oid = $repo->commit_create(
  update_ref => 'HEAD',
  tree       => $tree_oid,
  parents    => [$main->target],
  message    => 'add greeting',
);

Installation

cpanm Git::Native

libgit2 itself is provided automatically through Alien::Libgit2.

See also

License

This software is copyright (c) 2026 by Torsten Raudssus.

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

About

High-level Moo wrapper over Git::Libgit2 / libgit2 — no fork/exec, no XS

Resources

Stars

Watchers

Forks

Packages

 
 
 

Contributors