Make the output of UnifiedDiffFormatter match diff -u

GNU 'diff -u' prefixes each line with either a space, a '+', or a '-'.
UnifiedDiffFormatter does the same, but it also adds an additional column of
whitespace between the prefix and the line. GNU diff only does that in
non-unified mode.

Fix this by implementing lines() in UnifiedDiffFormatter, overriding the parent
class implementation.

Bug: T100069
Change-Id: I1bf1b8e6d1d5aceb2c3836548f492f7edebe5a12
This commit is contained in:
Ori Livneh 2015-05-26 03:35:59 +02:00
parent d6b4d3c537
commit 066fcb80a1

View file

@ -36,6 +36,16 @@ class UnifiedDiffFormatter extends DiffFormatter {
/** @var int */
protected $trailingContextLines = 2;
/**
* @param string[] $lines
* @param string $prefix
*/
protected function lines( $lines, $prefix = ' ' ) {
foreach ( $lines as $line ) {
echo "{$prefix}{$line}\n";
}
}
/**
* @param string[] $lines
*/