mirror of
https://github.com/php/php-src.git
synced 2024-11-23 09:54:15 +08:00
Colorize --show-diff, only on stdout
Don't add colors to the saved `.diff` file.
Related to a41cf3e1d2
This commit is contained in:
parent
c3ddda4e3c
commit
7be61bec80
@ -1774,11 +1774,17 @@ function run_worker(): void
|
||||
function show_file_block(string $file, string $block, ?string $section = null): void
|
||||
{
|
||||
global $cfg;
|
||||
global $colorize;
|
||||
|
||||
if ($cfg['show'][$file]) {
|
||||
if (is_null($section)) {
|
||||
$section = strtoupper($file);
|
||||
}
|
||||
if ($section === 'DIFF' && $colorize) {
|
||||
// '-' is Light Red for removal, '+' is Light Green for addition
|
||||
$block = preg_replace('/^[0-9]+\-\s.*$/m', "\e[1;31m\\0\e[0m", $block);
|
||||
$block = preg_replace('/^[0-9]+\+\s.*$/m', "\e[1;32m\\0\e[0m", $block);
|
||||
}
|
||||
|
||||
echo "\n========" . $section . "========\n";
|
||||
echo rtrim($block);
|
||||
|
Loading…
Reference in New Issue
Block a user