---
name: "Git::Raw::Diff"
section: "3pm"
platform: "linux"
package: "libgit-raw-perl"
version: "0.90+ds-3+b1"
release: "Debian 13 (Trixie)"
platforms: ["linux"]
url: "https://new.carta.tech/Git::Raw::Diff"
---

# Git::Raw::Diff(3pm)

Git diff class

## NAME

Git::Raw::Diff - Git diff class

## VERSION

version 0.90

## 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.
