From: Ori Livneh Date: Tue, 26 May 2015 01:35:59 +0000 (+0200) Subject: Make the output of UnifiedDiffFormatter match diff -u X-Git-Tag: 1.31.0-rc.0~11284 X-Git-Url: http://git.cyclocoop.org/%22%20.%20generer_url_ecrire%28%22messagerie%22%29%20.%20%22?a=commitdiff_plain;h=066fcb80a1e7be8cf8d356dec47a9976d636b2c7;p=lhc%2Fweb%2Fwiklou.git 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 --- diff --git a/includes/diff/UnifiedDiffFormatter.php b/includes/diff/UnifiedDiffFormatter.php index 32a76055ee..5f3ad3d7bb 100644 --- a/includes/diff/UnifiedDiffFormatter.php +++ b/includes/diff/UnifiedDiffFormatter.php @@ -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 */