NAME

Git::Repository::Plugin::Diff::Hunk - object that contains diff lines. About diff format

SYNOPSIS

# Load the plugin.
use Git::Repository 'Diff';
my $repository = Git::Repository->new();
# Get the git diff information.
my $file_diff = $repository->diff( $file, "HEAD", "HEAD~1" );
my $other_file_diff = $repository->diff( $file, "HEAD", "origin/master" );
my @hunks = $file_diff->get_hunks;
my $first_hunk = shift @hunks;
_dump_diff($first_hunk);
sub _dump_diff {
my ($hunk) = @_;
for my $l ($first_hunk->to_lines) {
my ($line_num, $line_content) = @$l;
print("+ $line_num: $line_content\n")
}
for my $l ($first_hunk->from_lines) {
my ($line_num, $line_content) = @$l;
print("- $line_num: $line_content\n")
}
}

DESCRIPTION

from_lines =head2 to_lines

Returns a list of arrays for each line for to/from file diff. The first array element is line number. The second is line content.

to_line_start =head2 from_line_start

The first number in hunk header

from_line_count =head2 to_line_count

The second number in hunk header

AUTHOR

d.tarasov <d.tarasov@corp.mail.ru>

COPYRIGHT

Copyright 2020- d.tarasov

LICENSE

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.

SEE ALSO