From 2ab836b3abe90d38f652f8cb69d549cc87376f46 Mon Sep 17 00:00:00 2001 From: Navarr Barnier Date: Wed, 7 Jun 2017 13:20:15 -0400 Subject: [PATCH] Add switch to $patch_levels for Magento 2 Official Patches Magento is a fairly popular software where composer-patches is especially useful. Patch files distributed by Magento in some special cases are based in the root directory, containing paths like `a/vendor/magento/module-catalog`. In cases such as these, if only a single module is referenced in the patch file then a -p4 flag will allow the patch to work as distributed by Magento. --- src/Patches.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Patches.php b/src/Patches.php index 4140fd40..e9df4ae4 100644 --- a/src/Patches.php +++ b/src/Patches.php @@ -355,8 +355,8 @@ protected function getAndApplyPatch(RemoteFilesystem $downloader, $install_path, $patched = FALSE; // The order here is intentional. p1 is most likely to apply with git apply. // p0 is next likely. p2 is extremely unlikely, but for some special cases, - // it might be useful. - $patch_levels = array('-p1', '-p0', '-p2'); + // 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 ($checked) {