This is a related issue to what a02 describes in http://drupal.org/node/745224 comments 110, 115 are the pertinent details.
Basically when an install profile is tracked in a git repository patching fails on a sub-directory if the '--working-copy' flag is used.
I was able to reproduce this issue manually with just git. From reading the git documentation the GIT_WORK_TREE as defined should resolve the issue however this is not the case for me. I attempted passing the --work-tree=. command as well. On both versions of this command git returns success but fails to apply the patch even though PATCHES.txt is cleanly generated referencing that the patch is applied. The interesting thing for me is that using the '--bare' flag worked perfectly for me.
Below is my shell output from the above discovery. Note that '/srv/www/html/profiles/PROFILE' is a git checkout of an install profile with the name PROFILE used to protect sensitive informaiton.
jeff@ubuntu:/srv/www/html/profiles/PROFILE/modules/scribdfield$ diff -u scribdfield.module.org scribdfield.module
jeff@ubuntu:/srv/www/html/profiles/PROFILE/modules/scribdfield$ cp /home/jeff/scribdfield-undefined-index-warning-1274418-1.patch .
jeff@ubuntu:/srv/www/html/profiles/PROFILE/modules/scribdfield$ GIT_WORK_TREE=. && git apply -p1 ./scribdfield-undefined-index-warning-1274418-1.patch --verbose
jeff@ubuntu:/srv/www/html/profiles/PROFILE/modules/scribdfield$ diff -u scribdfield.module.org scribdfield.module
jeff@ubuntu:/srv/www/html/profiles/PROFILE/modules/scribdfield$ GIT_WORK_TREE=. && git apply -p1 ./scribdfield-undefined-index-warning-1274418-1.patch --verbose
jeff@ubuntu:/srv/www/html/profiles/PROFILE/modules/scribdfield$ echo $?
0
jeff@ubuntu:/srv/www/html/profiles/PROFILE/modules/scribdfield$ diff -u scribdfield.module.org scribdfield.module
jeff@ubuntu:/srv/www/jeff@ubuntu:/srv/www/html/profiles/PROFILE/modules/scribdfield$ git --work-tree=. apply -p1 ./scribdfield-undefined-index-warning-1274418-1.patch --verbose
jeff@ubuntu:/srv/www/html/profiles/PROFILE/modules/scribdfield$ echo $?
0
jeff@ubuntu:/srv/www/html/profiles/PROFILE/modules/scribdfield$ diff -u scribdfield.module.org scribdfield.module
jeff@ubuntu:/srv/www/html/profiles/PROFILE/modules/scribdfield$ git --bare apply -p1 ~/scribdfield-undefined-index-warning-1274418-1.patch --verbose
Checking patch scribdfield.module...
Applied patch scribdfield.module cleanly.
jeff@ubuntu:/srv/www/html/profiles/PROFILE/modules/scribdfield$ diff -u scribdfield.module.org scribdfield.module
--- scribdfield.module.org 2011-09-12 12:39:24.302284074 -0700
+++ scribdfield.module 2011-09-12 12:41:37.642430471 -0700
@@ -173,7 +173,7 @@
function _scribdfield_node_presave(&$node, $field) {
// Upload each file to Scribd.
foreach ($node->{$field['field_name']} as $field_delta => $field_value) {
- if (($field_value['filepath'])
+ if (!empty($field_value['filepath'])
&& ($field_delta == 'field_scribd')
&& !($field_value['data']['scribd_doc_id']
&& file_exists($node->{$field['field_name']}[$field_delta]['filepath'])) ){
From testing this scenario locally I am using the following;
http://ftp.drupal.org/files/projects/scribdfield-6.x-1.1-beta1.tar.gz
with the following patch;
http://drupal.org/files/issues/scribdfield-undefined-index-warning-12744...
git version: 1.7.0.4
drush: 4.5
drush make: 2.3
Also related as I think changing the order could resolve this issue as applying the patches prior to moving to the __build__ dir would prevent any potential nested git directories.
http://drupal.org/node/1212834
Comments
Comment #1
jgraham commentedTo clarify using '--bare' rather than 'GIT_WORK_TREE=.' resolves the issue for me.
Comment #2
jgraham commentedAttached patch resolves the described issue for me.
Comment #3
adamdicarlo commentedSubscribing.
Comment #4
steven jones commentedDo you have any documentation about what the --bare option does for git apply?
Comment #5
jgraham commentedSince kernel.org is still down http://schacon.github.com/git/git.html
There is obviously a difference between setting GIT_DIR to '.' versus using '--bare'. From reading the git documentation I initially thought the behaviour would be the same but in practice it was definitely not.
So '--bare' sets GIT_DIR to '.' and then treats the repository as a "bare repository". In this scenario I think the important detail is that it doesn't traverse up the directory structure looking for a .git dir.
An alternate solution, which I think would be better, is just changing the order when patches are applied covered in #1212834
Comment #6
ao2 commentedSubscribing, to see where this end up :)
Comment #7
steven jones commentedI have now seen this with one of my repos, but not sure that --bare is the answer here.
Comment #8
steven jones commentedI'm seeing this issue with git 1.7.0.4, but not with git 1.7.5.4, odd.
Comment #9
helmo commented[ Powered by #1115636: Issue Macros and Templates - Drush Make]
Drush make is being merged into drush core (discussed in issue:#1310130: Put drush make in drush core)
This means that the issue queue is also moving. The drush queue has a component 'Make' especially for drush_make.
More information will be posted on the drush_make and drush project pages.
Comment #10
mrfelton commentedSimilar problem for us. Patches do not actually apply, although there are no reported build errors, and PATCHES.txt is still generated. Very very problematic, as the only way to tell if your build is actually complete is to manually check if every single patch has been applied. It also means that unless you are aware of this issue, you can very easily end up with a platform build with missing patches. So, I'm upping this to Major priority.
Here is a revised patch against latest code, based on #2
Comment #11
mrfelton commentedComment #12
milesw commentedI ran into the same thing described in #10. Patches were reported to apply successfully but code actually went untouched. Updated to Git 1.7.9.4 and the problem is resolved. Not sure now which version I was running before.
Comment #13
mrfelton commentedmilesw - We were having this issue with very latest code in git, from a clone of the drush repo made just a couple of hours ago. We are using git 1.7.0.4 for the record - latest version available through apt on Ubuntu LTS.
Comment #14
steven jones commented@mrfelton Indeed, that version of git exhibits this bug, sadly.
Comment #15
mrfelton commentedok, we'll I suspect this is the version that the majority of people will have, since it's what you get with LTS Ubuntu.
Comment #16
steven jones commentedAgreed, the use of
--bareis a bit lame IMHO, but I guess that it will solve the issue. We should document why we are using it though, because it's weird.Comment #17
thedavidmeister commentedfyi, I am seeing this bug with git version 1.7.2.5
Comment #18
sylus commentedYeah experienced this bug too. Actually wasted a few days because as mentioned the patches.txt state the patches applied cleanly. This is definitely a major bug.
What is a long term solution for this? Looks like a few options:
1) Add the patch
2) Upgrade to latest git (though still seems not 100% fix)
Ideally if the patch works can we not get this in?
Comment #19
steven jones commentedHere's the comment I wanted in #16, if someone could test this, that would be great.
Comment #20
jhedstromTests are all passing with #19. Is there any way to write a test for this specific failure though? If not I'm inclined to commit after others have had a chance to test the fix.
Comment #21
sylus commentedWorks for me! Thanks for the great work! :)
Comment #22
dominikb1888 commentedI've manually applied the patch against 6.x-2.3, it works for an issue I had with these patches, when running the makefile through Aegir:
- http://drupal.org/files/issues/noderelationships.delete-842456-23.patch
- http://drupal.org/files/features-revert-660958-97.patch
Comment #23
patcon commentedPatch works for me.
Errr... Would I be out of line to bump this to critical? No patches apply when --working-copy flag is used for install profiles? Seems pretty critical?
Comment #24
thedavidmeister commentedit is pretty heinous, I've had to drop --working-copy from my workflow completely, but as I understand it only affects a limited number of people who have a version of git with the bug in it, and that bug has been fixed in later versions of git... IMO if you want to get it committed and you've tested the patch, you'd be better of changing the status to RTBC than the priority to critical.
Comment #25
patcon commentedGood point. Thanks @thedavidmeister :)
I think I've found the root of the issue, and it's not really a mystery (although the change in behavior is odd. From
man git:So this bug only comes into play in profiles that are presumably already version-controlled. It affects trying to apply an email patch via
git apply-patchto a non-version-controlled project when using--working-copy(Views module tarball in my case). GIT_WORK_TREE is not used when the.gitdir is found automatically (ie. when $GIT_DIR is not set).--baresolves things because it sets GIT_DIR to the working directory.So in theory,
GIT_DIR=. git apply patch etcshould work just as well as the--bareflag. Haven't tested that yet.Comment #26
patcon commentedI am a terrible Sherlock. Apologies to @jgraham in #5 :/
Comment #27
patcon commentedActually, I'm on git 1.7.0.4 and drush 5.7, and it seems that setting
GIT_DIR=.(rather thanGIT_WORK_TREE=.or--bare), solves the problem as well.Can you confirm your previous findings @jgraham et al in regards to GIT_DIR not working for some reason?
Comment #28
patcon commentedUgh. OK, so it was THIS patch: http://drupal.org/files/views-1055616-71.patch
which isn't a git email patch, so perhaps no surprise that it applied. Sorry too many cooks in the kitchen on the project I'm working on -- patch got switched
Comment #29
alarcombe commentedHi,
I can confirm that this patch worked for me. Git 1.7.1, Drush 5.8
FWIW Attempting to apply the patch manually on the command line using git apply resulted in no output. Doing any of the following manually all worked too.
git config core.bare true && git apply patchfile
git init && git apply patchfile
GIT_DIR=. git apply patchfile
Comment #30
Paul Lomax commentedOn Windows the only one that works is --bare.
This is on Git 1.8.0.
Comment #31
univate commentedI have tested #27 and can confirm it works on linux(debian) with git 1.7.2.5
Comment #32
moshe weitzman commentedjhedstrom can do final commit. i think we have enough positive reviews now.
Comment #33
jhedstromCommitted #27 to 5 and 6. Thanks everybody!
Let's follow-up in another issue if this is indeed failing in Windows as #30 indicates.