From 4909c4a82a822a819cea612e799bb2d1bd9f4fd5 Mon Sep 17 00:00:00 2001 From: Dane Powell Date: Wed, 8 Nov 2017 09:47:00 -0800 Subject: [PATCH] Fixes #148: Incompatible with Git 2.14+. --- src/Patches.php | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/src/Patches.php b/src/Patches.php index 975ee2df..089e9e70 100644 --- a/src/Patches.php +++ b/src/Patches.php @@ -368,10 +368,22 @@ protected function getAndApplyPatch(RemoteFilesystem $downloader, $install_path, // it might be useful. p4 is useful for Magento 2 patches $patch_levels = array('-p1', '-p0', '-p2', '-p4'); foreach ($patch_levels as $patch_level) { - $checked = $this->executeCommand('cd %s && git --git-dir=. apply --check %s %s', $install_path, $patch_level, $filename); + if ($this->io->isVerbose()) { + $comment = 'Testing ability to patch with git apply.'; + $comment .= ' This command may produce errors that can be safely ignored.'; + $this->io->write('' . $comment . ''); + } + $checked = $this->executeCommand('git -C %s apply --check -v %s %s', $install_path, $patch_level, $filename); + $output = $this->executor->getErrorOutput(); + if (substr($output, 0, 7) == 'Skipped') { + // Git will indicate success but silently skip patches in some scenarios. + // + // @see https://github.com/cweagans/composer-patches/pull/165 + $checked = false; + } if ($checked) { // Apply the first successful style. - $patched = $this->executeCommand('cd %s && git --git-dir=. apply %s %s', $install_path, $patch_level, $filename); + $patched = $this->executeCommand('git -C %s apply %s %s', $install_path, $patch_level, $filename); break; } }