NAME

Git::Raw::Diff - Git diff class

VERSION

version 0.89

DESCRIPTION

A Git::Raw::Diff represents the diff between two entities.

WARNING: The API of this module is unstable and may change without warning (any change will be appropriately documented in the changelog).

METHODS

new( $buffer )

Create a diff from the content of a git patch.

patchid( )

Calculate the patch id.

merge( $from )

Merge the given diff with the Git::Raw::Diff $from.

buffer( $format )

Get the content of a diff as text. See Git::Raw::Diff->print() for valid $format values.

delta_count( )

Query how many diff records there are in the diff.

deltas( [$index] )

Returns a list of Git::Raw::Diff::Delta objects. If $index is specified only the delta at the specified index will be returned.

find_similar( [\%options] )

Transform the diff marking file renames, copies, etc. Valid fields for the %options hash include:

  • "flags"

    Flags for finding similar files. Valid values include:

    • "renames"

      Look for renames.

    • "renames_from_rewrites"

      Consider old side of modifies files for renames.

    • "copies"

      Look for copies.

    • "copies_from_unmodified"

      Consider unmodified files as copy sources.

    • "rewrites"

      Mark significant rewrites for split.

    • "break_rewrites"

      Actually split large rewrites into delete/add pairs.

    • "untracked"

      Find renames/copies for untracked items in the working directory.

    • "all"

      Turn on all finding features.

    • "ignore_leading_whitespace"

      Measure similarity ignoring leading whitespace (default).

    • "ignore_whitespace"

      Measure similarity ignoring all whitespace.

    • "dont_ignore_whitespace"

      Measure similarity including all data.

    • "exact_match_only"

      Measure similarity only by comparing SHAs (fast and cheap).

    • "break_rewrites_for_renames_only"

      Do not break rewrites unless they contribute to a rename.

    • "remove_unmodified"

      Remove any unmodified deltas after find_similar is done.

  • "rename_threshold"

    Similarity to consider a file renamed (default 50).

  • "rename_from_rewrite_threshold"

    Similarity of modified to be eligible rename source (default 50).

  • "copy_threshold"

    Similarity to consider a file a copy (default 50).

  • "break_rewrite_threshold"

    Similarity to split modify into delete/add pair (default 60).

  • "rename_limit"

    Maximum similarity sources to examine for a file (default 200).

patches( )

Return a list of Git::Raw::Patch objects for the diff.

print( $format, $callback )

Generate text output from the diff object. The $callback will be called for each line of the diff with two arguments: the first one represents the type of the patch line ("ctx" for context lines, "add" for additions, "del" for deletions, "file" for file headers, "hunk" for hunk headers, "bin" for binary data or "noeol" if both files have no LF at end) and the second argument contains the content of the patch line.

The $format can be one of the following:

  • "patch"

    Full git diff.

  • "patch_header"

    Only the file headers of the diff.

  • "raw"

    Like git diff --raw.

  • "name_only"

    Like git diff --name-only.

  • "name_status"

    Like git diff --name-status.

stats( )

Accumlated diff statistics for all patches in the diff. Returns a Git::Raw::Diff::Stats object.

AUTHOR

Alessandro Ghedini <alexbio@cpan.org>

Jacques Germishuys <jacquesg@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.