NAME
Git::Native::Config - A libgit2 configuration handle
VERSION
version 0.005
SYNOPSIS
my $cfg = $repo->config; # live, writable
$cfg->set_string('user.name', 'Ada');
say $repo->config_string('user.name'); # 'Ada' (fresh snapshot read)
my $snap = $repo->config_snapshot;
say $snap->get_string('user.email');
DESCRIPTION
A libgit2 configuration handle. Wraps git_config*; freed automatically when the object goes out of scope.
Reads go through get_string, which libgit2 only supports reliably on a snapshot config — get one via "config_snapshot" in Git::Native::Repository or the "config_string" in Git::Native::Repository convenience. Writes (set_string) require a live config from "config" in Git::Native::Repository.
A repository config sees the merged view git itself would use: the repository's own config file plus the global and system levels.
get_string
my $name = $repo->config_snapshot->get_string('user.name');
The value of $key, or undef when the key is not set anywhere in the config. Only "not found" becomes undef — any other libgit2 failure throws a Git::Native::Error, so an unreadable config is never silently reported as unset.
Call it on a snapshot. On a live config libgit2 refuses the read and this throws; "config_string" in Git::Native::Repository takes a snapshot for you.
get_bool
if ( $repo->config_snapshot->get_bool('core.bare') ) { ... }
1 or 0 for a git-style boolean, or undef when the key is not set — which is why the test is defined, not truth, when "unset" and "false" have to be told apart. libgit2 does the parsing (true/yes/on/1, false/no/off/0, integers by non-zero), so git's own rules apply. A key set to something that is not a boolean at all throws a Git::Native::Error rather than coming back undef.
set_string
$repo->config->set_string('user.name', 'Ada');
Write $value under $key and return the config. Needs a live config — a snapshot is read-only and throws. The write lands in the highest-priority writable level, i.e. the repository's own config file.
snapshot
my $snap = $repo->config->snapshot;
A frozen, read-only copy of the config as it stands right now, returned as a fresh Config. Later writes through the live config are not visible in it; take a new snapshot to see them.
SEE ALSO
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.