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