NAME
Git::Raw::Repository - Git repository class
VERSION
version 0.19
SYNOPSIS
use Git::Raw;
# clone a Git repository
my $url = 'git://github.com/ghedo/p5-Git-Raw.git';
my $repo = Git::Raw::Repository -> clone($url, 'p5-Git-Raw', { });
# print all the tags of the repository
foreach my $tag (@{ $repo -> tags }) {
say $tag -> name;
}
DESCRIPTION
A Git::Raw::Repository represents a Git repository.
METHODS
init( $path, $is_bare )
Initialize a new repository at $path.
clone( $url, $path, \%opts )
Clone the repository at $url to $path. Valid fields for the %opts hash are:
"bare"
If true (default is false) create a bare repository.
"cred_acquire"
The callback to be called any time authentication is required to connect to the remote repository. The callback receives a string containing the URL of the remote, and it must return a Git::Raw::Cred object.
open( $path )
Open the repository at $path.
discover( $path )
Discover the path to the repository directory given a subdirectory.
config( )
Retrieve the default Git::Raw::Config of the repository.
index( )
Retrieve the default Git::Raw::Index of the repository.
head( )
Retrieve the Git::Raw::Reference pointed by the HEAD of the repository.
lookup( $id )
Retrieve the object corresponding to $id.
checkout( $object, \%opts )
Updates the files in the index and working tree to match the content of $object. Valid fields for the %opts hash are:
"checkout_strategy"
Hash representing the desired checkout strategy. Valid fields are:
"update_unmodified"
Update any file where the working directory content matches the HEAD.
"update_missing"
Create a missing file that exists in the index and does not exist in the working directory.
"update_modified"
Update files where the working directory does not match the HEAD so long as the file actually exists in the HEAD.
"update_untracked"
Update files even if there is a working directory version that does not exist in the HEAD.
"allow_conflicts"
It is okay to update the files that are allowed by the strategy even if there are conflicts.
"skip_unmerged"
Proceed even if there are unmerged entries in the index, and just skip them.
"update_only"
Update is not allowed to create new files or delete old ones, only update existing content.
"remove_untracked"
Files in the working directory that are untracked (and not ignored) will be removed altogether.
Example:
$repo -> checkout($repo -> head -> target, {
'checkout_strategy' => { 'update_missing' => 1, 'update_modified' => 1 }
});
reset( $target, $type )
Reset the current HEAD to the given commit. Valid reset types are: "soft" (the head will be moved to the commit) or "mixed" (trigger a soft reset and replace the index with the content of the commit tree).
status( $file )
Retrieve the status of <$file> in the working directory. This functions returns a list of status flags. Possible status flags are: "index_new", "index_modified", "index_deleted", "worktree_new", "worktree_modified", "worktree_deleted" and "ignored".
ignore( $rules )
Add an ignore rules to the repository. The format of the rules is the same one of the .gitignore file (see the gitignore(5) manpage). Example:
$repo -> ignore("*.o\n");
diff( $repo [, $tree] )
Compute the Git::Raw::Diff between the given Git::Raw::Tree and the repo default index. If no $tree is passed, the diff will be computed between the repo index and the working directory.
blob( $buffer )
Create a new Git::Raw::Blob. Shortcut for Git::Raw::Blob->create().
branch( $name, $target )
Create a new Git::Raw::Branch. Shortcut for Git::Raw::Branch->create().
branches( )
Retrieve a list of Git::Raw::Branch objects.
commit( $msg, $author, $committer, \@parents, $tree )
Create a new Git::Raw::Commit. Shortcut for Git::Raw::Commit->create().
tag( $name, $msg, $tagger, $target )
Create a new Git::Raw::Tag. Shortcut for Git::Raw::Tag->create().
tags( )
Retrieve a list of Git::Raw::Tag objects.
stash( $stasher, $msg )
Save the local modifications to a new stash. Shortcut for Git::Raw::Stash->save().
remotes( )
Retrieve a list of Git::Raw::Remote objects.
walker( )
Create a new Git::Raw::Walker. Shortcut for Git::Raw::Walker->create().
path( )
Retrieve the complete path of the repository.
workdir( )
Retrieve the working directory of the repository.
is_empty( )
Check if the repository is empty.
is_bare( )
Check if the repository is bare.
AUTHOR
Alessandro Ghedini <alexbio@cpan.org>
LICENSE AND COPYRIGHT
Copyright 2012 Alessandro Ghedini.
This program is free software; you can redistribute it and/or modify it under the terms of either: the GNU General Public License as published by the Free Software Foundation; or the Artistic License.
See http://dev.perl.org/licenses/ for more information.