NAME

Git::Libgit2::FFI - Internal FFI::Platypus instance for Git::Libgit2

VERSION

version 0.004

SYNOPSIS

use Git::Libgit2::FFI;
my $ffi = Git::Libgit2::FFI::ffi();

DESCRIPTION

Internal use only. Holds the singleton FFI::Platypus instance with all attached libgit2 functions. Consumers should use Git::Libgit2 instead.

This module is a thin FFI layer over libgit2. All functions follow the libgit2 C API naming and signatures as closely as possible. Return codes must be checked with Git::Libgit2::check_rc. Every *_new / *_lookup must be matched with its *_free call.

ffi

my $ffi = Git::Libgit2::FFI::ffi();

Return the process-wide singleton FFI::Platypus instance, building it on the first call: it opens the Alien::Libgit2 dynamic library, registers the libgit2 opaque types and callback signatures, and attaches every bound function. Internal — consumers should use Git::Libgit2 instead.

GROUPS

Library Init / Shutdown

git_libgit2_init

my $rc = Git::Libgit2::FFI::git_libgit2_init();

Initialise the libgit2 library. Returns the new reference count (call shutdown_lib once per init).

git_libgit2_shutdown

my $rc = Git::Libgit2::FFI::git_libgit2_shutdown();

Decrement the libgit2 reference count. Returns the remaining count.

git_libgit2_version

Git::Libgit2::FFI::git_libgit2_version(\my $maj, \my $min, \my $rev);

Store the library version into the three Integer references.

Error

git_error_last

my $err = Git::Libgit2::FFI::git_error_last();

Return the current thread-local error struct pointer.

git_error_clear

Git::Libgit2::FFI::git_error_clear();

Clear the current thread-local error state.

Repository

git_repository_open

Git::Libgit2::FFI::git_repository_open(\my $repo, '/path/to/.git');

Open a repository at the given path. Free with git_repository_free.

git_repository_open_ext

Git::Libgit2::FFI::git_repository_open_ext(\my $repo, $path, $flags, $ceiled_paths);

Open a repository with extended options. See libgit2 docs for flag values.

git_repository_init

Git::Libgit2::FFI::git_repository_init(\my $repo, '/path/to/create', $flags);

Create a new repository. Free with git_repository_free.

git_repository_set_head

Git::Libgit2::FFI::git_repository_set_head($repo, 'refs/heads/main');

Make HEAD point at the given reference. The reference need not exist yet (an unborn branch is valid), so this is the way to pin the initial branch of a freshly git_repository_init'd repo instead of relying on libgit2's compiled-in default (master) or the ambient init.defaultBranch config.

git_repository_head

Git::Libgit2::FFI::git_repository_head(\my $ref, $repo);

Retrieve and resolve the reference pointed at by HEAD. Free the returned reference with git_reference_free. Returns GIT_EUNBORNBRANCH when HEAD points at a branch with no commits yet, or GIT_ENOTFOUND when HEAD is missing.

git_repository_head_unborn

my $unborn = Git::Libgit2::FFI::git_repository_head_unborn($repo);

Return true (1) if HEAD points at a branch that does not exist yet (a fresh repo before its first commit), false (0) otherwise.

git_repository_head_detached

my $detached = Git::Libgit2::FFI::git_repository_head_detached($repo);

Return true (1) if HEAD is detached — i.e. it points directly at a commit rather than at a branch reference.

git_repository_workdir

my $dir = Git::Libgit2::FFI::git_repository_workdir($repo);

Return the working directory path (or undef for bare repos).

git_repository_path

my $path = Git::Libgit2::FFI::git_repository_path($repo);

Return the .git directory path.

git_repository_is_bare

my $is_bare = Git::Libgit2::FFI::git_repository_is_bare($repo);

Returns true if the repository is bare.

git_repository_free

Git::Libgit2::FFI::git_repository_free($repo);

Free the repository handle.

git_repository_index

Git::Libgit2::FFI::git_repository_index(\my $index, $repo);

Get the repository's index. Free with git_index_free.

git_repository_config

Git::Libgit2::FFI::git_repository_config(\my $config, $repo);

Get the repository's config. Free with git_config_free.

git_repository_config_snapshot

Git::Libgit2::FFI::git_repository_config_snapshot(\my $config, $repo);

Get a snapshot of the repository's config. Free with git_config_free.

git_repository_odb

Git::Libgit2::FFI::git_repository_odb(\my $odb, $repo);

Get the repository's object database. Free with git_odb_free.

Config

git_config_open_default

Git::Libgit2::FFI::git_config_open_default(\my $config);

Open the global / XDG config. Free with git_config_free.

git_config_snapshot

Git::Libgit2::FFI::git_config_snapshot(\my $snapshot, $config);

Create a snapshot of a config. Free with git_config_free.

git_config_get_string

Git::Libgit2::FFI::git_config_get_string(\my $str, $config, $key);

Read a string config value.

git_config_set_string

Git::Libgit2::FFI::git_config_set_string($config, $key, $value);

Write a string config value.

git_config_free

Git::Libgit2::FFI::git_config_free($config);

Free the config handle.

OID

git_oid_fromstr

Git::Libgit2::FFI::git_oid_fromstr($oid_ptr, '40-char-hex');

Parse a hex string into an OID buffer.

git_oid_tostr

Git::Libgit2::FFI::git_oid_tostr($buf_ptr, 41, $oid_ptr);

Write the OID as a 40-char hex string into the buffer.

git_oid_cmp

my $cmp = Git::Libgit2::FFI::git_oid_cmp($oid_a, $oid_b);

Compare two OIDs. Returns <0, 0, or >0.

Reference

git_reference_lookup

Git::Libgit2::FFI::git_reference_lookup(\my $ref, $repo, 'refs/heads/main');

Look up a reference by name. Free with git_reference_free.

git_reference_name_to_id

Git::Libgit2::FFI::git_reference_name_to_id($oid_ptr, $repo, 'refs/heads/main');

Resolve a reference name to an OID.

git_reference_create

Git::Libgit2::FFI::git_reference_create(\my $ref, $repo, 'refs/heads/main', $oid_ptr, $force, $log_message);

Create or update a direct reference. Free with git_reference_free.

git_reference_delete

Git::Libgit2::FFI::git_reference_delete($ref);

Delete the reference.

git_reference_remove

Git::Libgit2::FFI::git_reference_remove($repo, 'refs/heads/main');

Remove a reference by name.

git_reference_target

my $target = Git::Libgit2::FFI::git_reference_target($ref);

Get the target OID of a reference (must be direct).

git_reference_name

my $name = Git::Libgit2::FFI::git_reference_name($ref);

Get the full name of the reference.

git_reference_type

my $type = Git::Libgit2::FFI::git_reference_type($ref);

Get the reference type (GIT_REFERENCE_DIRECT or GIT_REFERENCE_SYMBOLIC).

git_reference_free

Git::Libgit2::FFI::git_reference_free($ref);

Free the reference handle.

git_reference_iterator_new

Git::Libgit2::FFI::git_reference_iterator_new(\my $iter, $repo);

Create an iterator over all references. Free with git_reference_iterator_free.

git_reference_iterator_glob_new

Git::Libgit2::FFI::git_reference_iterator_glob_new(\my $iter, $repo, 'refs/remotes/*');

Create an iterator over references matching a glob pattern. Free with git_reference_iterator_free.

git_reference_next

Git::Libgit2::FFI::git_reference_next(\my $ref, $iter);

Return the next reference (ordered). Free with git_reference_free.

git_reference_next_name

Git::Libgit2::FFI::git_reference_next_name(\my $name, $iter);

Return the next reference name as a string.

git_reference_iterator_free

Git::Libgit2::FFI::git_reference_iterator_free($iter);

Free the iterator.

git_reference_name_is_valid

Git::Libgit2::FFI::git_reference_name_is_valid(\my $valid, $name);

Check if a reference name is valid.

git_reference_peel

Git::Libgit2::FFI::git_reference_peel(\my $obj, $ref, $type);

Peel a reference to the underlying object of the given type. Free the object with git_object_free.

git_reference_symbolic_create

Git::Libgit2::FFI::git_reference_symbolic_create(\my $ref, $repo, 'HEAD', 'refs/heads/main', $force, $log_message);

Create or update a symbolic reference pointing at $target. Free with git_reference_free.

git_reference_symbolic_target

my $target = Git::Libgit2::FFI::git_reference_symbolic_target($ref);

Return the target name of a symbolic reference (undef for direct refs).

git_reference_symbolic_set_target

Git::Libgit2::FFI::git_reference_symbolic_set_target(\my $new_ref, $ref, 'refs/heads/main', $log_message);

Create a new reference with the same name as $ref but a new symbolic target. Free the result with git_reference_free.

git_reference_set_target

Git::Libgit2::FFI::git_reference_set_target(\my $new_ref, $ref, $oid_ptr, $log_message);

Create a new reference with the same name as $ref but pointing at a new OID target. Free the result with git_reference_free.

git_reference_resolve

Git::Libgit2::FFI::git_reference_resolve(\my $resolved, $ref);

Resolve a symbolic reference to a direct reference. Free with git_reference_free.

git_reference_shorthand

my $short = Git::Libgit2::FFI::git_reference_shorthand($ref);

Return the human-friendly short name of the reference (e.g. main instead of refs/heads/main).

git_reference_is_branch

my $is_branch = Git::Libgit2::FFI::git_reference_is_branch($ref);

Return true if the reference lives under refs/heads/.

git_reference_is_remote

my $is_remote = Git::Libgit2::FFI::git_reference_is_remote($ref);

Return true if the reference lives under refs/remotes/.

git_reference_is_tag

my $is_tag = Git::Libgit2::FFI::git_reference_is_tag($ref);

Return true if the reference lives under refs/tags/.

Object

git_object_lookup

Git::Libgit2::FFI::git_object_lookup(\my $obj, $repo, $oid_ptr, $type);

Look up any object by OID. Free with git_object_free.

git_object_id

my $oid = Git::Libgit2::FFI::git_object_id($obj);

Get the OID of an object.

git_object_type

my $type = Git::Libgit2::FFI::git_object_type($obj);

Get the type of an object.

git_object_free

Git::Libgit2::FFI::git_object_free($obj);

Free the object handle.

Blob

git_blob_create_from_buffer

Git::Libgit2::FFI::git_blob_create_from_buffer($oid_ptr, $repo, $content_ptr, $len);

Create a blob from a memory buffer. $content_ptr must be a scalar_to_buffer result. Returns the OID of the created blob.

git_blob_lookup

Git::Libgit2::FFI::git_blob_lookup(\my $blob, $repo, $oid_ptr);

Look up a blob by OID. Free with git_blob_free.

git_blob_rawcontent

my $ptr = Git::Libgit2::FFI::git_blob_rawcontent($blob);

Return a pointer to the raw blob content. The memory is owned by the blob — do not free it.

git_blob_rawsize

my $size = Git::Libgit2::FFI::git_blob_rawsize($blob);

Return the size of the blob content in bytes.

git_blob_is_binary

my $is_binary = Git::Libgit2::FFI::git_blob_is_binary($blob);

Return true if the blob appears to be binary data.

git_blob_free

Git::Libgit2::FFI::git_blob_free($blob);

Free the blob handle.

Tree

git_tree_lookup

Git::Libgit2::FFI::git_tree_lookup(\my $tree, $repo, $oid_ptr);

Look up a tree by OID. Free with git_tree_free.

git_tree_entrycount

my $count = Git::Libgit2::FFI::git_tree_entrycount($tree);

Return the number of entries in the tree.

git_tree_entry_byindex

my $entry = Git::Libgit2::FFI::git_tree_entry_byindex($tree, $idx);

Return the entry at the given index (0-based).

git_tree_entry_byname

my $entry = Git::Libgit2::FFI::git_tree_entry_byname($tree, $filename);

Return the entry with the given filename.

git_tree_entry_name

my $name = Git::Libgit2::FFI::git_tree_entry_name($entry);

Return the entry filename.

git_tree_entry_id

my $oid = Git::Libgit2::FFI::git_tree_entry_id($entry);

Return the entry OID.

git_tree_entry_filemode

my $mode = Git::Libgit2::FFI::git_tree_entry_filemode($entry);

Return the file mode of the entry.

git_tree_entry_type

my $type = Git::Libgit2::FFI::git_tree_entry_type($entry);

Return the object type of the entry (GIT_OBJECT_BLOB, etc.).

git_tree_free

Git::Libgit2::FFI::git_tree_free($tree);

Free the tree handle.

TreeBuilder

git_treebuilder_new

Git::Libgit2::FFI::git_treebuilder_new(\my $tb, $repo, $tree);  # tree may be undef

Create a new tree builder, optionally from an existing tree. Free with git_treebuilder_free.

git_treebuilder_insert

Git::Libgit2::FFI::git_treebuilder_insert(\my $entry, $tb, $filename, $oid_ptr, $filemode);

Insert an entry into the builder.

git_treebuilder_remove

Git::Libgit2::FFI::git_treebuilder_remove($tb, $filename);

Remove an entry from the builder.

git_treebuilder_write

Git::Libgit2::FFI::git_treebuilder_write($oid_ptr, $tb);

Write the tree and return its OID.

git_treebuilder_free

Git::Libgit2::FFI::git_treebuilder_free($tb);

Free the tree builder.

Commit

git_commit_lookup

Git::Libgit2::FFI::git_commit_lookup(\my $commit, $repo, $oid_ptr);

Look up a commit by OID. Free with git_commit_free.

git_commit_create

Git::Libgit2::FFI::git_commit_create($oid_ptr, $repo, $ref_name, $author_sig, $committer_sig, $encoding, $message, $tree, $parent_count, $parents);

Create a commit. $parents is passed as undef when $parent_count is 0.

git_commit_message

my $msg = Git::Libgit2::FFI::git_commit_message($commit);

Return the commit message.

git_commit_tree

Git::Libgit2::FFI::git_commit_tree(\my $tree, $commit);

Get the tree of a commit. Free with git_tree_free.

git_commit_tree_id

my $oid = Git::Libgit2::FFI::git_commit_tree_id($commit);

Get the tree OID of a commit.

git_commit_parentcount

my $n = Git::Libgit2::FFI::git_commit_parentcount($commit);

Return the number of parents of the commit.

git_commit_parent_id

my $oid = Git::Libgit2::FFI::git_commit_parent_id($commit, $n);

Return the OID of the N-th parent (0-based).

git_commit_author

my $sig = Git::Libgit2::FFI::git_commit_author($commit);

Return the author signature (git_signature*). Do not free.

git_commit_committer

my $sig = Git::Libgit2::FFI::git_commit_committer($commit);

Return the committer signature (git_signature*). Do not free.

git_commit_id

my $oid = Git::Libgit2::FFI::git_commit_id($commit);

Return the OID of the commit (const git_oid *). Do not free.

git_commit_time

my $epoch = Git::Libgit2::FFI::git_commit_time($commit);

Return the commit time as a Unix timestamp (seconds since the epoch).

git_commit_time_offset

my $offset = Git::Libgit2::FFI::git_commit_time_offset($commit);

Return the commit's timezone offset in minutes from UTC.

git_commit_summary

my $summary = Git::Libgit2::FFI::git_commit_summary($commit);

Return the short summary of the commit message (the first paragraph / first line).

git_commit_free

Git::Libgit2::FFI::git_commit_free($commit);

Free the commit handle.

Signature

git_signature_new

Git::Libgit2::FFI::git_signature_new(\my $sig, $name, $email, $time_t, $offset);

Create a signature. Free with git_signature_free.

git_signature_now

Git::Libgit2::FFI::git_signature_now(\my $sig, $name, $email);

Create a signature with the current time. Free with git_signature_free.

git_signature_default

Git::Libgit2::FFI::git_signature_default(\my $sig, $repo);

Create a signature from the repository config. Free with git_signature_free.

git_signature_free

Git::Libgit2::FFI::git_signature_free($sig);

Free the signature handle.

Remote

git_remote_lookup

Git::Libgit2::FFI::git_remote_lookup(\my $remote, $repo, $name);

Look up a remote by name. Free with git_remote_free.

git_remote_create

Git::Libgit2::FFI::git_remote_create(\my $remote, $repo, $name, $url);

Create a remote. Free with git_remote_free.

git_remote_create_anonymous

Git::Libgit2::FFI::git_remote_create_anonymous(\my $remote, $repo, $url);

Create an anonymous remote from a URL. Free with git_remote_free.

git_remote_url

my $url = Git::Libgit2::FFI::git_remote_url($remote);

Return the URL of the remote.

git_remote_name

my $name = Git::Libgit2::FFI::git_remote_name($remote);

Return the name of the remote.

git_remote_init_callbacks

Git::Libgit2::FFI::git_remote_init_callbacks($callbacks_ptr, $version);

Initialize callbacks struct for remote operations.

git_remote_fetch

Git::Libgit2::FFI::git_remote_fetch($remote, $refspecs, $options, $reflog_msg);

Fetch using the remote. See also git_fetch_options_init.

git_remote_push

Git::Libgit2::FFI::git_remote_push($remote, $refspecs, $options);

Push using the remote. See also git_push_options_init.

git_remote_connect

Git::Libgit2::FFI::git_remote_connect($remote, $direction, $callbacks, $options, $resolved_url);

Connect to the remote.

git_remote_ls

Git::Libgit2::FFI::git_remote_ls(\my $heads, \my $len, $remote);

List remote branches. $heads is an array of OID pointers.

git_remote_disconnect

Git::Libgit2::FFI::git_remote_disconnect($remote);

Disconnect from the remote.

git_remote_free

Git::Libgit2::FFI::git_remote_free($remote);

Free the remote handle.

Credentials

git_credential_userpass_plaintext_new

Git::Libgit2::FFI::git_credential_userpass_plaintext_new(\my $cred, $username, $password);

Create a username/password credential.

git_credential_ssh_key_new

Git::Libgit2::FFI::git_credential_ssh_key_new(\my $cred, $username, $public_key, $private_key, $passphrase);

Create an SSH key credential.

git_credential_ssh_key_from_agent

Git::Libgit2::FFI::git_credential_ssh_key_from_agent(\my $cred, $username);

Create an SSH key credential using the ssh-agent.

git_credential_default_new

Git::Libgit2::FFI::git_credential_default_new(\my $cred);

Create a default credential (e.g. from GIT_ASKPASS).

git_credential_username_new

Git::Libgit2::FFI::git_credential_username_new(\my $cred, $username);

Create a username-only credential.

git_credential_free

Git::Libgit2::FFI::git_credential_free($cred);

Free the credential handle.

Clone

git_clone_options_init

Git::Libgit2::FFI::git_clone_options_init($opts_ptr, $version);

Initialize clone options struct.

git_clone

Git::Libgit2::FFI::git_clone(\my $repo, $url, $path, $opts);

Clone a repository. Free the repo with git_repository_free.

Strarray

git_strarray_free

Git::Libgit2::FFI::git_strarray_free($strarray);

Free a strarray (used by tag list, branch list iteration, etc.).

Revwalk

git_revwalk_new

Git::Libgit2::FFI::git_revwalk_new(\my $walk, $repo);

Create a revision walker. Free with git_revwalk_free.

git_revwalk_push

Git::Libgit2::FFI::git_revwalk_push($walk, $oid_ptr);

Push a commit OID to start walking from.

git_revwalk_push_head

Git::Libgit2::FFI::git_revwalk_push_head($walk);

Push HEAD to start walking from.

git_revwalk_push_ref

Git::Libgit2::FFI::git_revwalk_push_ref($walk, $refname);

Push a reference to start walking from.

git_revwalk_push_glob

Git::Libgit2::FFI::git_revwalk_push_glob($walk, $glob);

Push all references matching a glob.

git_revwalk_push_range

Git::Libgit2::FFI::git_revwalk_push_range($walk, $range);

Push a commit range (from..to).

git_revwalk_hide

Git::Libgit2::FFI::git_revwalk_hide($walk, $oid_ptr);

Hide a commit OID (stop walking at this point).

git_revwalk_hide_head

Git::Libgit2::FFI::git_revwalk_hide_head($walk);

Hide HEAD.

git_revwalk_hide_ref

Git::Libgit2::FFI::git_revwalk_hide_ref($walk, $refname);

Hide a reference.

git_revwalk_hide_glob

Git::Libgit2::FFI::git_revwalk_hide_glob($walk, $glob);

Hide all references matching a glob.

git_revwalk_next

Git::Libgit2::FFI::git_revwalk_next($oid_ptr, $walk);

Get the next commit OID in the walk.

git_revwalk_sorting

Git::Libgit2::FFI::git_revwalk_sorting($walk, $sort_mode);

Set the sorting mode (GIT_SORT_NONE, GIT_SORT_TOPOLOGICAL, etc.).

git_revwalk_reset

Git::Libgit2::FFI::git_revwalk_reset($walk);

Reset the walker for a new traversal.

git_revwalk_simplify_first_parent

Git::Libgit2::FFI::git_revwalk_simplify_first_parent($walk);

Simplify the walk to first-parent only.

git_revwalk_free

Git::Libgit2::FFI::git_revwalk_free($walk);

Free the revision walker.

Branch

git_branch_create

Git::Libgit2::FFI::git_branch_create(\my $ref, $repo, $name, $commit, $force);

Create a new branch. Free with git_reference_free.

git_branch_lookup

Git::Libgit2::FFI::git_branch_lookup(\my $ref, $repo, $name, $branch_type);

Look up a branch by name. Free with git_reference_free.

git_branch_delete

Git::Libgit2::FFI::git_branch_delete($ref);

Delete the branch reference.

git_branch_iterator_new

Git::Libgit2::FFI::git_branch_iterator_new(\my $iter, $repo, $filter);

Create a branch iterator. Free with git_branch_iterator_free.

git_branch_next

Git::Libgit2::FFI::git_branch_next(\my $ref, \my $type, $iter);

Get the next branch. Free with git_reference_free.

git_branch_iterator_free

Git::Libgit2::FFI::git_branch_iterator_free($iter);

Free the branch iterator.

git_branch_name

Git::Libgit2::FFI::git_branch_name(\my $name, $ref);

Get the branch name from a reference.

git_branch_is_head

my $is_head = Git::Libgit2::FFI::git_branch_is_head($ref);

Return true if the branch is HEAD.

git_branch_move

Git::Libgit2::FFI::git_branch_move(\my $new_ref, $ref, $new_name, $force);

Rename a branch. Free with git_reference_free.

Status

git_status_options_init

Git::Libgit2::FFI::git_status_options_init($opts_ptr, $version);

Initialize status options struct.

git_status_foreach

Git::Libgit2::FFI::git_status_foreach($repo, $callback, $payload);

Run a callback for each status entry. The callback receives (path, flags, payload).

git_status_foreach_ext

Git::Libgit2::FFI::git_status_foreach_ext($repo, $opts, $callback, $payload);

Like git_status_foreach but with extended options.

git_status_file

Git::Libgit2::FFI::git_status_file(\my $flags, $repo, $path);

Get the status flags for a single file.

Tag

git_tag_create

Git::Libgit2::FFI::git_tag_create(\my $tag, $repo, $tag_name, $target, $tagger, $message, $force);

Create an annotated tag. Free with git_tag_free.

git_tag_create_from_buffer

Git::Libgit2::FFI::git_tag_create_from_buffer($oid_ptr, $repo, $buffer, $force);

Create a tag from a buffer.

git_tag_create_lightweight

Git::Libgit2::FFI::git_tag_create_lightweight($oid_ptr, $repo, $name, $target, $force);

Create a lightweight tag.

git_tag_lookup

Git::Libgit2::FFI::git_tag_lookup(\my $tag, $repo, $oid_ptr);

Look up a tag by OID. Free with git_tag_free.

git_tag_delete

Git::Libgit2::FFI::git_tag_delete($repo, $tag_name);

Delete a tag.

git_tag_list

Git::Libgit2::FFI::git_tag_list($strarray, $repo);

List all tags into a strarray. Free with git_strarray_free.

git_tag_list_match

Git::Libgit2::FFI::git_tag_list_match($strarray, $pattern, $repo);

List tags matching a pattern. Free with git_strarray_free.

git_tag_target

Git::Libgit2::FFI::git_tag_target(\my $obj, $tag);

Get the target object of a tag. Free with git_object_free.

git_tag_target_id

my $oid = Git::Libgit2::FFI::git_tag_target_id($tag);

Get the target OID of a tag.

git_tag_message

my $msg = Git::Libgit2::FFI::git_tag_message($tag);

Return the tag message.

git_tag_name

my $name = Git::Libgit2::FFI::git_tag_name($tag);

Return the tag name.

git_tag_tagger

my $sig = Git::Libgit2::FFI::git_tag_tagger($tag);

Return the tagger signature.

git_tag_free

Git::Libgit2::FFI::git_tag_free($tag);

Free the tag handle.

Diff

git_diff_options_init

Git::Libgit2::FFI::git_diff_options_init($opts_ptr, $version);

Initialize diff options struct.

git_diff_tree_to_tree

Git::Libgit2::FFI::git_diff_tree_to_tree(\my $diff, $repo, $old_tree, $new_tree, $opts);

Diff two trees. Free with git_diff_free.

git_diff_tree_to_workdir

Git::Libgit2::FFI::git_diff_tree_to_workdir(\my $diff, $repo, $tree, $opts);

Diff a tree against the working directory. Free with git_diff_free.

git_diff_tree_to_index

Git::Libgit2::FFI::git_diff_tree_to_index(\my $diff, $repo, $tree, $index, $opts);

Diff a tree against the index. Free with git_diff_free.

git_diff_index_to_workdir

Git::Libgit2::FFI::git_diff_index_to_workdir(\my $diff, $repo, $index, $opts);

Diff the index against the working directory. Free with git_diff_free.

git_diff_num_deltas

my $n = Git::Libgit2::FFI::git_diff_num_deltas($diff);

Return the number of deltas in the diff.

git_diff_get_delta

my $delta = Git::Libgit2::FFI::git_diff_get_delta($diff, $idx);

Return the delta at the given index.

git_diff_free

Git::Libgit2::FFI::git_diff_free($diff);

Free the diff handle.

Index

git_index_open

Git::Libgit2::FFI::git_index_open(\my $index, $index_path);

Open an index file. Free with git_index_free.

git_index_read

Git::Libgit2::FFI::git_index_read($index, $force);

Read (reload) the index from disk.

git_index_write

Git::Libgit2::FFI::git_index_write($index);

Write the index to disk.

git_index_read_tree

Git::Libgit2::FFI::git_index_read_tree($index, $tree);

Read a tree into the index.

git_index_write_tree

Git::Libgit2::FFI::git_index_write_tree($oid_ptr, $index);

Write the index as a tree to the object database.

git_index_add_bypath

Git::Libgit2::FFI::git_index_add_bypath($index, $path);

Add a file at the given path to the index.

git_index_add_all

Git::Libgit2::FFI::git_index_add_all($index, $pathspecs, $flags, $callback, $payload);

Add all files matching pathspecs to the index.

git_index_remove_bypath

Git::Libgit2::FFI::git_index_remove_bypath($index, $path);

Remove an entry from the index by path.

git_index_clear

Git::Libgit2::FFI::git_index_clear($index);

Clear the index.

git_index_entrycount

my $n = Git::Libgit2::FFI::git_index_entrycount($index);

Return the number of entries in the index.

git_index_get_byindex

my $entry = Git::Libgit2::FFI::git_index_get_byindex($index, $idx);

Return the entry at the given index.

git_index_find

Git::Libgit2::FFI::git_index_find(\my $pos, $index, $path);

Find the position of an entry by path. Returns UINT_MAX if not found.

git_index_free

Git::Libgit2::FFI::git_index_free($index);

Free the index handle.

Checkout

git_checkout_options_init

Git::Libgit2::FFI::git_checkout_options_init($opts_ptr, $version);

Initialize checkout options struct.

git_checkout_head

Git::Libgit2::FFI::git_checkout_head($repo, $opts);

Checkout HEAD to the working directory.

git_checkout_index

Git::Libgit2::FFI::git_checkout_index($repo, $index, $opts);

Checkout the index (or a given tree) to the working directory.

git_checkout_tree

Git::Libgit2::FFI::git_checkout_tree($repo, $obj, $opts);

Checkout an arbitrary treeish object to the working directory.

Revparse

git_revparse_single

Git::Libgit2::FFI::git_revparse_single(\my $obj, $repo, $spec);

Resolve a revision spec to a single object. Free with git_object_free.

git_revparse_ext

Git::Libgit2::FFI::git_revparse_ext(\my $obj, \my $ref, $repo, $spec);

Resolve a revision spec to an object and its reference.

Reset

git_reset

Git::Libgit2::FFI::git_reset($repo, $obj, $reset_type, $opts);

Reset a repository to a given state.

git_reset_default

Git::Libgit2::FFI::git_reset_default($repo, $obj, $opts);

Reset specific paths in the index.

Merge

git_annotated_commit_lookup

Git::Libgit2::FFI::git_annotated_commit_lookup(\my $ann, $repo, $oid_ptr);

Look up an annotated commit. Free with git_annotated_commit_free.

git_annotated_commit_from_ref

Git::Libgit2::FFI::git_annotated_commit_from_ref(\my $ann, $repo, $ref);

Create an annotated commit from a reference. Free with git_annotated_commit_free.

git_annotated_commit_id

my $oid = Git::Libgit2::FFI::git_annotated_commit_id($ann);

Get the OID of an annotated commit.

git_annotated_commit_free

Git::Libgit2::FFI::git_annotated_commit_free($ann);

Free the annotated commit handle.

git_merge_base

Git::Libgit2::FFI::git_merge_base($oid_ptr, $repo, $a, $b);

Find the merge base of two commits.

git_merge_base_many

Git::Libgit2::FFI::git_merge_base_many($oid_ptr, $repo, $n, $tips);

Find the merge base of many commits.

git_merge_analysis

Git::Libgit2::FFI::git_merge_analysis(\my $analysis, \my $preference, $repo, $ann, $n);

Analyze a merge situation.

git_merge_options_init

Git::Libgit2::FFI::git_merge_options_init($opts_ptr, $version);

Initialize merge options struct.

Graph

git_graph_ahead_behind

Git::Libgit2::FFI::git_graph_ahead_behind(\my $ahead, \my $behind, $repo, $local, $upstream);

Count commits that are ahead and behind a given commit.

git_graph_descendant_of

my $is_desc = Git::Libgit2::FFI::git_graph_descendant_of($repo, $commit, $ancestor);

Return true if $commit is a descendant of $ancestor.

Stash

git_stash_save

Git::Libgit2::FFI::git_stash_save(\my $stash, $repo, $sig, $msg, $flags);

Save the current working directory state as a stash. Free with git_object_free.

git_stash_apply

Git::Libgit2::FFI::git_stash_apply($repo, $index, $opts);

Apply a stash by index.

git_stash_drop

Git::Libgit2::FFI::git_stash_drop($repo, $index);

Drop a stash by index.

Reflog

git_reflog_read

Git::Libgit2::FFI::git_reflog_read(\my $reflog, $repo, $name);

Read the reflog for a reference. Free with git_reflog_free.

git_reflog_entrycount

my $n = Git::Libgit2::FFI::git_reflog_entrycount($reflog);

Return the number of entries in the reflog.

git_reflog_entry_byindex

my $entry = Git::Libgit2::FFI::git_reflog_entry_byindex($reflog, $idx);

Return the entry at the given index.

git_reflog_entry_id_new

my $oid = Git::Libgit2::FFI::git_reflog_entry_id_new($entry);

Return the new OID of the entry.

git_reflog_entry_message

my $msg = Git::Libgit2::FFI::git_reflog_entry_message($entry);

Return the message of the entry.

git_reflog_free

Git::Libgit2::FFI::git_reflog_free($reflog);

Free the reflog handle.

Rebase

git_rebase_init

Git::Libgit2::FFI::git_rebase_init(\my $rebase, $repo, $onto, $branch, $upstream, $opts);

Start a rebase operation. Free with git_rebase_free.

git_rebase_open

Git::Libgit2::FFI::git_rebase_open(\my $rebase, $repo, $state_dir);

Open an in-progress rebase. Free with git_rebase_free.

git_rebase_next

Git::Libgit2::FFI::git_rebase_next(\my $operation, $rebase);

Get the next operation in the rebase.

git_rebase_commit

Git::Libgit2::FFI::git_rebase_commit($oid_ptr, $rebase, $author, $committer, $encoding, $message);

Commit the current rebase operation.

git_rebase_abort

Git::Libgit2::FFI::git_rebase_abort($rebase);

Abort the rebase and reset to the original state.

git_rebase_finish

Git::Libgit2::FFI::git_rebase_finish($rebase, $signer);

Finish a completed rebase.

git_rebase_free

Git::Libgit2::FFI::git_rebase_free($rebase);

Free the rebase handle.

git_rebase_operation_entrycount

my $n = Git::Libgit2::FFI::git_rebase_operation_entrycount($rebase);

Return the number of operations in the rebase.

git_rebase_operation_current

my $n = Git::Libgit2::FFI::git_rebase_operation_current($rebase);

Return the current operation index (or GIT_REBASE_NO_OPERATION).

git_rebase_operation_byindex

my $op = Git::Libgit2::FFI::git_rebase_operation_byindex($rebase, $idx);

Return the operation at the given index.

git_rebase_options_init

Git::Libgit2::FFI::git_rebase_options_init($opts_ptr, $version);

Initialize rebase options struct.

git_rebase_orig_head_name

my $name = Git::Libgit2::FFI::git_rebase_orig_head_name($rebase);

Return the original HEAD name.

git_rebase_orig_head_id

my $oid = Git::Libgit2::FFI::git_rebase_orig_head_id($rebase);

Return the original HEAD OID.

git_rebase_onto_name

my $name = Git::Libgit2::FFI::git_rebase_onto_name($rebase);

Return the onto reference name.

git_rebase_onto_id

my $oid = Git::Libgit2::FFI::git_rebase_onto_id($rebase);

Return the onto OID.

Cherry-pick

git_cherrypick

Git::Libgit2::FFI::git_cherrypick($repo, $commit, $opts);

Prepare to cherry-pick a commit.

git_cherrypick_commit

Git::Libgit2::FFI::git_cherrypick_commit(\my $oid, $repo, $cherrypick, $our_commit, $parent_count, $opts);

Create the actual cherry-pick commit.

git_cherrypick_options_init

Git::Libgit2::FFI::git_cherrypick_options_init($opts_ptr, $version);

Initialize cherry-pick options struct.

Revert

git_revert

Git::Libgit2::FFI::git_revert($repo, $commit, $opts);

Prepare to revert a commit.

git_revert_commit

Git::Libgit2::FFI::git_revert_commit(\my $oid, $repo, $revert, $our_commit, $parent_count, $opts);

Create the actual revert commit.

git_revert_options_init

Git::Libgit2::FFI::git_revert_options_init($opts_ptr, $version);

Initialize revert options struct.

ODB

git_odb_new

Git::Libgit2::FFI::git_odb_new(\my $odb, $repo);

Create a new ODB wrapper. Free with git_odb_free.

git_odb_exists

my $exists = Git::Libgit2::FFI::git_odb_exists($odb, $oid_ptr);

Check if an object exists in the ODB.

git_odb_free

Git::Libgit2::FFI::git_odb_free($odb);

Free the ODB handle.

SUPPORT

Issues

Please report bugs and feature requests on GitHub at https://github.com/Getty/p5-git-libgit2/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.