Skip Menu |
 

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

Report information
The Basics
Id: 64770
Status: new
Priority: 0/
Queue: Text-Patch

People
Owner: Nobody in particular
Requestors: mrks [...] mrks.de
Cc:
AdminCc:

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



Subject: wrongly applies certain unified-format diffs
Download (untitled) / with headers
text/plain 669b
Text::Patch fails on applying certain diffs in unified-format without context, e.g. those generated by GNU diff. Steps to reproduce: echo -e "Line A\nLine C" > a1.txt echo -e "Line A\nLine B\nLine C" > a2.txt diff -U 0 a1.txt a2.txt > patch.txt Now apply patch.txt on a1.txt with Text::Patch. The result is not "Line A\nLine B\nLine C" as expected, but "Line B\nLine A\nLine C". So it's messed up. I think the problem is an optimization in the code, namely not to recognize the "+"- Part in the chunk-header. That'll work for Text::Diff generated hunks obviously (as they alsways contain context), but not for all valid context-less unified diffs in the wild.
From: mrks [...] mrks.de
Download (untitled) / with headers
text/plain 643b
Am Fr 14. Jan 2011, 06:43:26, mrks schrieb: Show quoted text
> I think the problem is an optimization in the code, namely not to > recognize the "+"- > Part in the chunk-header. That'll work for Text::Diff generated hunks > obviously (as > they alsways contain context), but not for all valid context-less > unified diffs in the > wild.
After a deeper look I think the problem might be a special case mentioned in [1]: "An empty hunk is considered to start at the line that follows the hunk.". If "empty hunk" means count=0 it would apply here. And indeed, it would fix my example. [1] http://www.gnu.org/software/hello/manual/diff/Detailed-Unified.html


This service is sponsored and maintained by Best Practical Solutions and runs on Perl.org infrastructure.

Please report any issues with rt.cpan.org to rt-cpan-admin@bestpractical.com.