1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206
|
package Git::Raw::Diff;
$Git::Raw::Diff::VERSION = '0.87';
use strict;
use warnings;
use Git::Raw;
=head1 NAME
Git::Raw::Diff - Git diff class
=head1 VERSION
version 0.87
=head1 DESCRIPTION
A L<Git::Raw::Diff> represents the diff between two entities.
B<WARNING>: The API of this module is unstable and may change without warning
(any change will be appropriately documented in the changelog).
=head1 METHODS
=head2 new( $buffer )
Create a diff from the content of a git patch.
=head2 patchid( )
Calculate the patch id.
=head2 merge( $from )
Merge the given diff with the L<Git::Raw::Diff> C<$from>.
=head2 buffer( $format )
Get the content of a diff as text. See C<Git::Raw::Diff-E<gt>print()> for valid
C<$format> values.
=head2 delta_count( )
Query how many diff records there are in the diff.
=head2 deltas( [$index] )
Returns a list of L<Git::Raw::Diff::Delta> objects. If C<$index> is specified
only the delta at the specified index will be returned.
=head2 find_similar( [\%options] )
Transform the diff marking file renames, copies, etc. Valid fields for the
C<%options> hash include:
=over 4
=item * "flags"
Flags for finding similar files. Valid values include:
=over 8
=item * "renames"
Look for renames.
=item * "renames_from_rewrites"
Consider old side of modifies files for renames.
=item * "copies"
Look for copies.
=item * "copies_from_unmodified"
Consider unmodified files as copy sources.
=item * "rewrites"
Mark significant rewrites for split.
=item * "break_rewrites"
Actually split large rewrites into delete/add pairs.
=item * "untracked"
Find renames/copies for untracked items in the working directory.
=item * "all"
Turn on all finding features.
=item * "ignore_leading_whitespace"
Measure similarity ignoring leading whitespace (default).
=item * "ignore_whitespace"
Measure similarity ignoring all whitespace.
=item * "dont_ignore_whitespace"
Measure similarity including all data.
=item * "exact_match_only"
Measure similarity only by comparing SHAs (fast and cheap).
=item * "break_rewrites_for_renames_only"
Do not break rewrites unless they contribute to a rename.
=item * "remove_unmodified"
Remove any unmodified deltas after C<find_similar> is done.
=back
=item * "rename_threshold"
Similarity to consider a file renamed (default 50).
=item * "rename_from_rewrite_threshold"
Similarity of modified to be eligible rename source (default 50).
=item * "copy_threshold"
Similarity to consider a file a copy (default 50).
=item * "break_rewrite_threshold"
Similarity to split modify into delete/add pair (default 60).
=item * "rename_limit"
Maximum similarity sources to examine for a file (default 200).
=back
=head2 patches( )
Return a list of L<Git::Raw::Patch> objects for the diff.
=head2 print( $format, $callback )
Generate text output from the diff object. The C<$callback> will be called for
each line of the diff with two arguments: the first one represents the type of
the patch line (C<"ctx"> for context lines, C<"add"> for additions, C<"del">
for deletions, C<"file"> for file headers, C<"hunk"> for hunk headers, C<"bin">
for binary data or C<"noeol"> if both files have no LF at end) and the second
argument contains the content of the patch line.
The C<$format> can be one of the following:
=over 4
=item * "patch"
Full git diff.
=item * "patch_header"
Only the file headers of the diff.
=item * "raw"
Like C<git diff --raw>.
=item * "name_only"
Like C<git diff --name-only>.
=item * "name_status"
Like C<git diff --name-status>.
=back
=head2 stats( )
Accumlated diff statistics for all patches in the diff. Returns a
L<Git::Raw::Diff::Stats> object.
=head1 AUTHOR
Alessandro Ghedini <alexbio@cpan.org>
Jacques Germishuys <jacquesg@striata.com>
=head1 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.
=cut
1; # End of Git::Raw::Diff
|