Subject: | wrongly applies certain unified-format diffs |
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.