Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Breaks with Git 2.14.0 #148

Closed
joergLin opened this issue Aug 8, 2017 · 24 comments
Closed

Breaks with Git 2.14.0 #148

joergLin opened this issue Aug 8, 2017 · 24 comments

Comments

@joergLin
Copy link

joergLin commented Aug 8, 2017

Using Git 2.14.0 breaks appying Patches (Alpine Edge, Composer 1.5). Latest Working Version is 2.13.4.

Applying patches for drupal/core
    https://www.drupal.org/files/issues/2551373-35.patch (...)
cd 'web/core' && git --git-dir=. apply --check '-p1' '/tmp/5989b7ae422cc.patch'
warning: unable to access 'config': Is a directory
warning: unable to access 'config': Is a directory
fatal: unknown error occurred while reading the configuration files

cd 'web/core' && git --git-dir=. apply --check '-p0' '/tmp/5989b7ae422cc.patch'
warning: unable to access 'config': Is a directory

warning: unable to access 'config': Is a directory
fatal: unknown error occurred while reading the configuration files

cd 'web/core' && git --git-dir=. apply --check '-p2' '/tmp/5989b7ae422cc.patch'
warning: unable to access 'config': Is a directory
warning: unable to access 'config': Is a directory
fatal: unknown error occurred while reading the configuration files

patch '-p1' --no-backup-if-mismatch -d 'web/core' < '/tmp/5989b7ae422cc.patch'
patch: unrecognized option: no-backup-if-mismatch

BusyBox v1.25.1 (2016-10-26 16:15:20 GMT) multi-call binary.

Usage: patch [OPTIONS] [ORIGFILE [PATCHFILE]]

	-p,--strip N		Strip N leading components from file names
	-i,--input DIFF		Read DIFF instead of stdin
	-R,--reverse		Reverse patch
	-N,--forward		Ignore already applied patches
	-E,--remove-empty-files	Remove output files if they become empty

patch '-p0' --no-backup-if-mismatch -d 'web/core' < '/tmp/5989b7ae422cc.patch'
patch: unrecognized option: no-backup-if-mismatch

BusyBox v1.25.1 (2016-10-26 16:15:20 GMT) multi-call binary.

Usage: patch [OPTIONS] [ORIGFILE [PATCHFILE]]

	-p,--strip N		Strip N leading components from file names
	-i,--input DIFF		Read DIFF instead of stdin
	-R,--reverse		Reverse patch
	-N,--forward		Ignore already applied patches
	-E,--remove-empty-files	Remove output files if they become empty

patch '-p2' --no-backup-if-mismatch -d 'web/core' < '/tmp/5989b7ae422cc.patch'
patch: unrecognized option: no-backup-if-mismatch

BusyBox v1.25.1 (2016-10-26 16:15:20 GMT) multi-call binary.

Usage: patch [OPTIONS] [ORIGFILE [PATCHFILE]]

	-p,--strip N		Strip N leading components from file names
	-i,--input DIFF		Read DIFF instead of stdin
	-R,--reverse		Reverse patch
	-N,--forward		Ignore already applied patches
	-E,--remove-empty-files	Remove output files if they become empty

   Could not apply patch! Skipping. The error was: Cannot apply patch https://www.drupal.org/files/issues/2551373-35.patch

In the Release Notes (https://github.com/git/git/blob/master/Documentation/RelNotes/2.14.0.txt) are changes to "gitdir" and "git apply", maybe its one of them?

@cweagans
Copy link
Owner

cweagans commented Aug 8, 2017

Oh boy. Thanks for reporting this. Really not looking forward to debugging this. :/

git--

@andypost
Copy link

andypost commented Aug 9, 2017

yep, there's changes in git https://lkml.org/lkml/2017/8/4/481

probably

Git now avoids blindly falling back to ".git" when the setup sequence said we are not in Git repository.

tstoeckler added a commit to tstoeckler/composer-patches that referenced this issue Sep 6, 2017
@tstoeckler
Copy link

Was also hitting this, see PR for something that fixes this on my system

@RalfEisler
Copy link

Having issues installing and updating Drupal Lightning on FreeBSD

composer update -vvv
Running 1.5.2 (2017-09-11 16:59:25) with PHP 7.1.9 on FreeBSD / 10.3-RELEASE-p20

- Applying patches for drupal/core
    https://www.drupal.org/files/issues/2652138-41.patch (2652138 - ImageFormatter does not support SVGs)
Downloading https://www.drupal.org/files/issues/2652138-41.patch
cd 'docroot/core' && git --git-dir=. apply --check '-p1' '/tmp//59ca7004e02cf.patch'
Executing command (CWD): cd 'docroot/core' && git --git-dir=. apply --check '-p1' '/tmp//59ca7004e02cf.patch'
warning: unable to access 'config': Is a directory
warning: unable to access 'config': Is a directory
fatal: unknown error occurred while reading the configuration files

@timcosgrove
Copy link

timcosgrove commented Sep 28, 2017

Just adding a voice, that I'm also seeing this. Issue posted in acquia/lightning, cross-posting here: https://github.com/acquia/lightning/issues/473

I've confirmed that it does not happen under git 2.13.3, but does happen under git 2.14.1.

@timcosgrove
Copy link

I can also confirm, anecdotally, that #152 fixes the issue I'm seeing.

@danepowell
Copy link
Collaborator

I'm also seeing these errors when running composer update -vvv, but the patches do seem to be applied correctly in the end, at least in my test cases.

Can anyone explain that discrepancy, and/or provide a clear case where these errors actually prevent a patch being applied?

This needs to be fixed regardless, but I want to understand the exact scope and severity of this bug.

@RalfEisler
Copy link

@danepowell

I am working with the Drupal Lightning distribution on a shared hosting provider. The actual Git-version is 2.15.0. I became aware of the problem with Git-version 2.14.3.

The problem is severe, because the projects are not maintainable on this server, which is important for small projects.

The Drupal Lightning projects are managed with Composer and the Drupal shell Drush. Composer patches are managed with cweagans/composer-patches.

Clean installations and updates fail since patches are not applied. However, I can download the patches and apply them manually.

Software:
"cweagans/composer-patches": "^1.6.0",
Drush Commandline Tool 9.0-dev-g809c7fc3 (global install)
Drush Commandline Tool 9.0.0-beta8 (local install in the project)
Composer version 1.5.2 2017-09-11 16:59:25
PHP 7.1.11 (cli) (built: Oct 30 2017 11:34:00) ( NTS )

installation-protocoll.txt

@danepowell
Copy link
Collaborator

I get the same error messages as you when running verbose composer commands, but in the end the patches do seem to be applied. I'm trying to understand why the patches are correctly applied for me but not for you (regardless of the error messages).

@RalfEisler
Copy link

RalfEisler commented Nov 7, 2017

On my installation, the patches are clearly not applied.
In the above installation, I download and apply the first patch:

$ cd docroot
$ wget https://www.drupal.org/files/issues/1356276-408--8.4.x.patch
$ patch -p1 < 1356276-408--8.4.x.patch

patching.txt

All I know is comping from this post:

#152

By the way:

The installation can be done with an other shared hosting provider and an old Git-version, without issues. The installations and updates run also on my local machines with older Git-versions.

@danepowell
Copy link
Collaborator

danepowell commented Nov 8, 2017

Okay I think I've figured out the discrepancy. This is an interplay between composer-patches, Git, and GNU patch.

composer-patches starts throwing errors for Git versions >= 2.14.0

However, depending on the version of GNU patch on your system, these errors may or may not actually be harmful. It appears that newer versions can recover more gracefully from this problem.

With Git 2.15.0 and Patch 2.5 (the default for Mac OS), I get errors and the patches fail to apply.

With Git 2.15.0 and Patch 2.7.5 (the default for Ubuntu), I get errors but the patches still successfully apply.

@RalfEisler
Copy link

RalfEisler commented Nov 8, 2017

uname -a

FreeBSD 10.3-RELEASE-p21 #13 r322349M: Thu Aug 10 09:47:17 UTC 2017

@danepowell
Copy link
Collaborator

See my new PR for this here, including an in-depth explanation of why patches were still applying in spite of the errors: #165

Also note that this PR reveals another bug, which is that git apply probably can't be used to apply patches in this context.

@danepowell
Copy link
Collaborator

danepowell commented Nov 15, 2017

n.b. if you need to update your Patch version on Mac OS: brew install gpatch and restart your session/shell

cweagans added a commit that referenced this issue Nov 22, 2017
Fixes #148: Incompatible with Git 2.14+.
danepowell added a commit to danepowell/composer-patches that referenced this issue Nov 22, 2017
cweagans added a commit that referenced this issue Nov 22, 2017
Fixes #148: Incompatible with Git 2.14+.
@danepowell
Copy link
Collaborator

This may have introduced a regression for older versions of Git :(

#174

@pwolanin
Copy link

pwolanin commented Dec 7, 2017

Yes, this is causing patch install to fail on the git version from Ubuntu 16.04
git version 2.7.4

@mortenson
Copy link

Installing gpatch on OS X 10.12.5 didn't fix this for me, I had to upgrade to High Sierra (10.13.2).

@grasmash
Copy link
Contributor

grasmash commented Dec 8, 2017

@pwolanin @mortenson Even when using composer-patches 1.6.4?

@mortenson
Copy link

@grasmash It looks like that released the day I made my comment, so I'm not sure we were on it at the time.

@pwolanin
Copy link

pwolanin commented Dec 8, 2017

The 1.6.4 release seems to have fixed it.

@RalfEisler
Copy link

Unfortunately, my hosting provider will not update patch. So 1.6.4 does not fix the problem.

git version 2.15.1
patch 2.0-12u10 FreeBSD
"cweagans/composer-patches": "^1.6.4"

Error messages:
Could not apply patch! Skipping. The error was: Cannot apply patch https://www.drupal.org/files/issues/1356276-408--8.4.3.patch
etc.

@danepowell
Copy link
Collaborator

@RalfEisler it's unlikely that this bug would produce that particular error. The bug related to patch version generally fails silently. Are you absolutely sure that the patch you are referencing applies cleanly outside of Composer?

@RalfEisler
Copy link

RalfEisler commented Dec 15, 2017

Are you absolutely sure that the patch you are referencing applies cleanly outside of Composer?

@danepowell -- I am failing to clean install or update Drupal Lightning projects in a specific context. Patches are not applied.

php --version
PHP 7.1.12 (cli) (built: Dec 11 2017 19:54:55) ( NTS )
Copyright (c) 1997-2017 The PHP Group
Zend Engine v3.1.0, Copyright (c) 1998-2017 Zend Technologies
    with Zend OPcache v7.1.12, Copyright (c) 1999-2017, by Zend Technologies

git version 2.15.1

patch 2.0-12u10 FreeBSD

Composer version 1.5.2 2017-09-11 16:59:25

Drupal Lightning version 2.2.5

"cweagans/composer-patches": "^1.6.4"

lightning-installation.txt

However, I could apply them manually:

wget https://www.drupal.org/files/issues/1356276-408--8.4.3.patch

patch -p1 < 1356276-408--8.4.3.patch 

patch-install.txt

@danepowell
Copy link
Collaborator

Oh it's not just the one core patch, it's every patch not applying. Yeah that seems like a bug, but you should probably open a new issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

10 participants