Skip Menu |

This queue is for tickets about the Text-Diff-Parser CPAN distribution.

Report information
The Basics
Id: 22284
Status: resolved
Priority: 0/
Queue: Text-Diff-Parser

People
Owner: Nobody in particular
Requestors: NIKC [...] cpan.org
Cc:
AdminCc:

Bug Information
Severity: Critical
Broken in: 0.02
Fixed in: (no value)



Subject: Breaks with files that are modiifed from line 0.
If you take the attached diff (which is the output from a Subversion diff on my public repo) you'll get this error: perl -MText::Diff::Parser -e 'Text::Diff::Parser->new("/var/tmp/text-diff-parser-bug-example.diff");' Missing @@ line before +package SVN::Web::I18N; at line 320 of /var/tmp/text-diff-parser-bug-example.diff Around line 320 looks like this: Index: local/CPAN/SVN-Web/branches/svn-client/lib/SVN/Web/I18N.pm =================================================================== --- local/CPAN/SVN-Web/branches/svn-client/lib/SVN/Web/I18N.pm (revision 0) +++ local/CPAN/SVN-Web/branches/svn-client/lib/SVN/Web/I18N.pm (revision 1271) @@ -0,0 +1,117 @@ +package SVN::Web::I18N; + Note the "@@ -0,0 +1,117 @@". This is what you get when Subversion's diff discovers a newly added file. I18N.pm didn't exist in the previous revision, so Subversion has done a diff against an empty file. This is because of this code around line 300 of Text::Diff::Parser: if( $line =~ /^\@\@ -(\d+),(\d+) [+](\d+),(\d+) \@\@$/ ) { my @match = ($1, $2, $3, $4); if( @{ $change->{lines} } ) { $change = $self->_new_chunk; } @{ $change }{ qw( line1 size1 line2 size2 ) } = @match; $change->{at1} = $change->{line1}; $change->{at2} = $change->{line2}; return; } die "Missing \@\@ line before $line at $self->{state}{context}\n" unless $change->{line1}; I assume that final die() is checking to see whether or not the match succeeded. But in this case $change->{line1} exists, but contains '0', which obviously causes the boolean test to fail. Changing that last line (line 311) to unless exists $change->{line1}; fixes this problem, and all the tests still pass. Quickly skimming the code, line 299 probably has the same problem (it tests $change->{filename2}, and will fail if $change->{filename2} is false in a boolean context). N
Subject: text-diff-parser-bug-example.diff

Message body is not shown because it is too large.

On Thu Oct 19 17:05:13 2006, NIKC wrote: Show quoted text
> If you take the attached diff (which is the output from a Subversion > diff on my public repo) you'll get this error:
This is not Subversion specific. I've just tried: diff -u /dev/null /etc/motd on a FreeBSD machine and the hunk header for that is: @@ -0,0 +1,24 N
Fixed in 0.04. With test cases. Closing ticket