File Coverage

blib/lib/Git/Raw/Packbuilder.pm
Criterion Covered Total %
statement 25 26 96.1
branch 2 4 50.0
condition n/a
subroutine 7 7 100.0
pod n/a
total 34 37 91.8


line stmt bran cond sub pod time code
1             package Git::Raw::Packbuilder;
2             $Git::Raw::Packbuilder::VERSION = '0.86';
3 35     43   247 use strict;
  35         71  
  35         974  
4 35     35   181 use warnings;
  35         68  
  35         767  
5 35     35   159 use Carp;
  35         68  
  35         5337  
6              
7             sub AUTOLOAD {
8             # This AUTOLOAD is used to 'autoload' constants from the constant()
9             # XS function.
10              
11 2     2   26029 my $constname;
12 2         4 our $AUTOLOAD;
13 2         18 ($constname = $AUTOLOAD) =~ s/.*:://;
14 2 50       11 croak "&Git::Raw::Packbuilder::constant not defined" if $constname eq '_constant';
15 2         31 my ($error, $val) = _constant($constname);
16 2 50       8 if ($error) { croak $error; }
  0         0  
17             {
18 35     35   277 no strict 'refs';
  35         78  
  35         2920  
  2         4  
19 2     8   17 *$AUTOLOAD = sub { $val };
  8         4335  
20             }
21 2         9 goto &$AUTOLOAD;
22             }
23              
24 35     35   232 use Git::Raw;
  35         83  
  35         1516  
25              
26             =head1 NAME
27              
28             Git::Raw::Packbuilder - Git packbuilder class
29              
30             =head1 VERSION
31              
32             version 0.86
33              
34             =head1 SYNOPSIS
35              
36             use File::Spec::Functions qw(catfile);
37             use Git::Raw;
38              
39             my $pb = Git::Raw::Packbuilder -> new($repo);
40             $pb -> insert($commit);
41             $pb -> write(catfile($repo -> path, 'objects', 'pack'));
42              
43             =head1 DESCRIPTION
44              
45             A L represents a git packfile builder.
46              
47             =head1 CONSTANTS
48              
49             =head2 ADDING_OBJECTS
50              
51             Objects are being added to the object database.
52              
53             =head2 DELTAFICATION
54              
55             Deltas are calculated/resolved.
56              
57             =head1 METHODS
58              
59             =head2 new( $repo )
60              
61             Create a new packbuilder.
62              
63             =head2 insert( $object, [$recursive = 1] )
64              
65             Insert an object and by default its referenced objects. C<$object> may be
66             a L, L, L or L.
67              
68             =head2 write( $path )
69              
70             Write the new pack and corresponding index file to C<$path>.
71              
72             =head2 written( )
73              
74             Retrieve the number of objects the packbuilder has already written out.
75              
76             =head2 object_count( )
77              
78             Retrieve the total number of objects the packbuilder will write out.
79              
80             =head2 threads( $count )
81              
82             Set number of threads to spawn. By default libgit2 won't spawn any threads at all;
83             when set to 0, libgit2 will autodetect the number of CPUs.
84              
85             =head2 hash( )
86              
87             Get the packfile's hash. A packfile's name is derived from the sorted hashing of all
88             object names. This is only correct after the packfile has been written.
89              
90             =head2 callbacks( \%callbacks )
91              
92             Set the callbacks for the packbuilder. See L>.
93              
94             =head1 CALLBACKS
95              
96             =head2 pack_progress
97              
98             During the packing of new data, this will regularly be called with the progress
99             of the pack operation. Be aware that this is called inline with pack
100             building operations, so performance may be affected. The callback receives the
101             following integers:
102             C<$stage>, C<$current> and C<$total>.
103              
104             =head2 transfer_progress
105              
106             This will be regularly called with the current count of progress done by the
107             indexer. The callback receives the following integers: C<$total_objects>,
108             C<$received_objects>, C<$local_objects>, C<$total_deltas>, C<$indexed_deltas>
109             and C<$received_bytes>.
110              
111             =head1 AUTHOR
112              
113             Jacques Germishuys
114              
115             =head1 LICENSE AND COPYRIGHT
116              
117             Copyright 2015 Jacques Germishuys.
118              
119             This program is free software; you can redistribute it and/or modify it
120             under the terms of either: the GNU General Public License as published
121             by the Free Software Foundation; or the Artistic License.
122              
123             See http://dev.perl.org/licenses/ for more information.
124              
125             =cut
126              
127             1; # End of Git::Raw::Packbuilder