composer-patches: Patches fail to apply with older versions of Git

With Composer Patches 1.6.3, patches will silently fail to apply on machines with older versions of Git installed. I think it will fail for versions prior to Git 2.9.0, based on this commit: https://github.com/git/git/commit/3f5794493c7a0ba2bba0278b9129d98df343d341

Empirically, I’ve tested and verified that Git versions 2.11.0 and above work fine, while 2.7.4 and before fail. I haven’t had time to build the versions in between from source in order to test.

I haven’t yet determined whether this is a regression introduced by https://github.com/cweagans/composer-patches/pull/165

I don’t see why that would have caused a regression. But in testing, Composer Patches 1.6.2 works fine while Composer Patches 1.6.3 fails in at least one environment: https://github.com/acquia/lightning/pull/524

I think the problem is that older versions of git apply silently fail to apply patches, so there’s no way for Composer Patches to verify whether they’ve applied correctly or not. But again, I’m not sure how to reconcile that with the changes in https://github.com/acquia/lightning/pull/524, which should have only been more aggressive in catching git apply failures.

About this issue

  • Original URL
  • State: closed
  • Created 7 years ago
  • Comments: 15 (3 by maintainers)

Commits related to this issue

Most upvoted comments

Do you have any suggestions for how we can get around this? One thought is that we could check for the presence of a .git dir, and only use git apply if it exists (otherwise, fall back to patch). What do you think about that?

Le sigh.

git–

A fix is pending in https://github.com/cweagans/composer-patches/pull/175, but for anyone that needs an immediate workaround, you can pin composer-patches to 1.6.2 or use my fork. Add the following to your composer.json:

{
    "repositories": [
        {
            "type": "vcs",
            "url": "https://github.com/danepowell/composer-patches"
        }
    ],
    "require": {
        "cweagans/composer-patches": "dev-issue-174 as 1.6.2",
    }
}

Depending on what other dependencies you have installed, you might need to change the alias to 1.6.3.