File Coverage

blib/lib/Git/Raw/Index.pm
Criterion Covered Total %
statement 9 9 100.0
branch n/a
condition n/a
subroutine 3 3 100.0
pod n/a
total 12 12 100.0


line stmt bran cond sub pod time code
1             package Git::Raw::Index;
2             $Git::Raw::Index::VERSION = '0.90';
3 36     36   220 use strict;
  36         62  
  36         944  
4 36     36   155 use warnings;
  36         59  
  36         783  
5              
6 36     36   158 use Git::Raw;
  36         71  
  36         2063  
7              
8             =head1 NAME
9              
10             Git::Raw::Index - Git index class
11              
12             =head1 VERSION
13              
14             version 0.90
15              
16             =head1 DESCRIPTION
17              
18             A L represents an index in a Git repository.
19              
20             B: The API of this module is unstable and may change without warning
21             (any change will be appropriately documented in the changelog).
22              
23             =head1 METHODS
24              
25             =head2 new( )
26              
27             Create a new in-memory index. This is currently of little use.
28              
29             =head2 owner( )
30              
31             Retrieve the L owning the index.
32              
33             =head2 add( $entry )
34              
35             Add C<$entry> to the index. C<$entry> should either be the path of a file
36             or alternatively a L.
37              
38             =head2 add_frombuffer( $path, $buffer, [$mode] )
39              
40             Add or update an entry from an in-memory file. The entry will be placed at C<$path>
41             with the contents of C<$buffer>. C<$buffer> may either be string or a reference
42             to a string. C<$mode> is the file mode; it defaults to C<0100644>. Returns a
43             L object.
44              
45             =head2 add_all( \%opts )
46              
47             Add or update all index entries to match the working directory. Valid fields for
48             the C<%opts> hash are:
49              
50             =over 4
51              
52             =item * "paths"
53              
54             List of path patterns to add.
55              
56             =item * "flags"
57              
58             Valid fields for the C<%flags> member:
59              
60             =over 8
61              
62             =item * "force"
63              
64             Forced addition of files (even if they are ignored).
65              
66             =item * "disable_pathspec_match"
67              
68             Disable pathspec pattern matching against entries in C<$paths>.
69              
70             =item * "check_pathspec"
71              
72             Enable pathspec pattern matching against entries in C<$paths> (default).
73              
74             =back
75              
76             =item * "notification"
77              
78             The callback to be called for each added or updated item. Receives the C<$path>
79             and matching C<$pathspec>. This callback should return C<0> if the file should
80             be added to the index, C0> if it should be skipped or C0> to abort.
81              
82             =back
83              
84             =head2 find( $path )
85              
86             Find the first L which points to a given C<$path>. If an
87             entry cannot be found, this function will return C.
88              
89             =head2 remove( $path )
90              
91             Remove C<$path> from the index.
92              
93             =head2 remove_all( \%opts )
94              
95             Remove all matching index entries. See Cupdate_all()> for
96             valid C<%opts> values.
97              
98             =head2 path( )
99              
100             Retrieve the full path to the index file on disk.
101              
102             =head2 checksum( )
103              
104             Retrieve the SHA-1 checksum over the index file, except for the last 20 bytes which is the checksum content itself.
105             If the index does not exist on-disk an empty OID will be returned.
106              
107             =head2 clear( )
108              
109             Clear the index.
110              
111             =head2 read( [$force] )
112              
113             Update the index, reading it from disk.
114              
115             =head2 write( )
116              
117             Write the index to disk.
118              
119             =head2 read_tree( $tree )
120              
121             Replace the index content with C<$tree>.
122              
123             =head2 write_tree( [$repo] )
124              
125             Create a new tree from the index and write it to disk. C<$repo> optionally
126             indicates which L the tree should be written to. Returns
127             a L object.
128              
129             =head2 checkout( [\%checkout_opts] )
130              
131             Update files in the working tree to match the contents of the index.
132             See Ccheckout()> for valid
133             C<%checkout_opts> values.
134              
135             =head2 entry_count( )
136              
137             Retrieve the number of entries in the index.
138              
139             =head2 entries( )
140              
141             Retrieve index entries. Returns a list of L objects.
142              
143             =head2 add_conflict( $ancestor, $theirs, $ours)
144              
145             Add a new conflict entry. C<$ancestor>, C<$theirs> and C<$ours> should be
146             L objects.
147              
148             =head2 get_conflict( $path )
149              
150             Get the conflict entry for C<$path>. If C<$path> has no conflict entry,
151             this function will return C.
152              
153             =head2 remove_conflict( $path )
154              
155             Remove C<$path> from the index.
156              
157             =head2 has_conflicts( )
158              
159             Determine if the index contains entries representing file conflicts.
160              
161             =head2 conflict_cleanup( )
162              
163             Remove all conflicts in the index (entries with a stage greater than 0).
164              
165             =head2 conflicts( )
166              
167             Retrieve index entries that represent a conflict. Returns a list of
168             L objects.
169              
170             =head2 merge( $ancestor, $theirs, $ours, [\%merge_opts] )
171              
172             Merge two files as they exist in the index. C<$ancestor>, C<$theirs> and
173             C<$ours> should be L objects. Returns a
174             L object. Valid fields for the C<%merge_opts>
175             hash are:
176              
177             =over 4
178              
179             =item * "our_label"
180              
181             The name of the "our" side of conflicts.
182              
183             =item * "their_label"
184              
185             The name of the "their" side of conflicts.
186              
187             =item * "ancestor_label"
188              
189             The name of the common ancestor side of conflicts.
190              
191             =item * "favor"
192              
193             Specify content automerging behaviour. Valid values are C<"ours">, C<"theirs">,
194             and C<"union">.
195              
196             =item * "marker_size"
197              
198             The size of conflict markers.
199              
200             =item * "flags"
201              
202             Merge file flags. Valid values include:
203              
204             =over 8
205              
206             =item * "merge"
207              
208             Create standard conflicted merge file.
209              
210             =item * "diff3"
211              
212             Create diff3-style files.
213              
214             =item * "simplify_alnum"
215              
216             Condense non-alphanumeric regions for simplified diff file.
217              
218             =item * "ignore_whitespace"
219              
220             Ignore all whitespace.
221              
222             =item * "ignore_whitespace_change"
223              
224             Ignore changes in amount of whitespace.
225              
226             =item * "ignore_whitespace_eol"
227              
228             Ignore whitespace at end of line.
229              
230             =item * "patience"
231              
232             Use the C<"patience diff"> algorithm.
233              
234             =item * "minimal"
235              
236             Take extra time to find minimal diff.
237              
238             =back
239              
240             =back
241              
242             =head2 update_all( \%opts )
243              
244             Update all index entries to match the working directory. Valid fields for the
245             C<%opts> hash are:
246              
247             =over 4
248              
249             =item * "paths"
250              
251             List of path patterns to add.
252              
253             =item * "notification"
254              
255             The callback to be called for each updated item. Receives the C<$path> and
256             matching C<$pathspec>. This callback should return C<0> if the file should be
257             added to the index, C0> if it should be skipped, or C0> to abort.
258              
259             =back
260              
261             =head2 capabilities( )
262              
263             Retrieve the index's capabilities. Returns a hash with members C<"ignore_case">,
264             C<"no_filemode"> and C<"no_symlinks">, each indicating if the L
265             supports the capability.
266              
267             =head2 version( [$version] )
268              
269             Retrieve or set the index version.
270              
271             =head1 AUTHOR
272              
273             Alessandro Ghedini
274              
275             Jacques Germishuys
276              
277             =head1 LICENSE AND COPYRIGHT
278              
279             Copyright 2012 Alessandro Ghedini.
280              
281             This program is free software; you can redistribute it and/or modify it
282             under the terms of either: the GNU General Public License as published
283             by the Free Software Foundation; or the Artistic License.
284              
285             See http://dev.perl.org/licenses/ for more information.
286              
287             =cut
288              
289             1; # End of Git::Raw::Index