protected function getStagedFiles($pattern)
{
$filter = empty($pattern) ? '' : " | grep {$pattern}";
$command = sprintf('LC_ALL=en_US.UTF-8 git diff-index --name-only --diff-filter=ACMR %s %s', escapeshellarg($this->getAgainst()), $filter);
exec($command, $files, $return);
if (2 === $return) {
throw new \RuntimeException('Fetching staged files returns an error');
}
// No files found
if (1 === $return) {
return [];
}
// Filter out empty and NULL values
$files = array_filter($files);
array_walk($files, [$this, 'prependRoot'], $this->root);
return $files;
}