Last updated 1 June 2016.
On this page:
- Instructions for "rerolling" a new patch that applies cleanly
- Hints for checking the rerolled patch
The automated patch testing system is able to test whether a patch applies or not. You may see a patch on an issue with a message like "Unable to apply patch [patchname]. Unable to apply patch…" beside it:
# Instructions for "rerolling" a new patch that applies cleanly
- Ensure that you have cloned the project repository by following the steps on the Version control tab on the project page.
- Check out the project's latest branch of the repository. For example:
git checkout 8.2.x git pull --rebase
- Unless otherwise specified in the issue comments, always reroll the most recent patch found on the issue. You can find the latest patch by clicking the 'Most recent attachment' link on the top right of the page.
Download the last patch from the relevant issue, and move it to the root directory of your development site.
- Double-check whether it's necessary to reroll the patch (sometimes the testbot gets confused):
git apply --check 1497310-statistics_config_settings-5.patch
If you see no output, it was a false alarm: the patch doesn't need to be rerolled. If the issue had the "needs reroll" tag, remove the tag and post a comment that says something like: "I could apply the patch, so no reroll is needed." Reset the status to "Needs review". You're done!
- Go to the issue and note the date of the comment that you downloaded the patch from. (Double click on the date to toggle between time-ago and the date and time.)
git logcommand with that date and time, in order to figure out a commit where the patch applied cleanly. For example:
git log -1 --before="March 30, 2012 at 1:54pm"
commit 72cf5a75537a651c79271a1a3a6781ffc98430e7 Author: catch <email@example.com> Date: Fri Mar 30 13:42:49 2012 +0900 Revert "Issue #787652 by larowlan, andypost: Fixed Forum vocabulary alterations possibly obsolete -- possible to delete forum vocab." This reverts commit e179ee1d643101ae9ac9c1a94990bdb161ac8a62.
- Take the first few characters of the commit hash you see there (in this case,
72cf5a755) and create a new branch (and switch to it) from that commit.
git checkout -b test-branch 72cf5a755
git should return a line like the following:
Switched to a new branch 'test-branch'
During this process, you might encounter a permissions error like:
error: unable to unlink old 'sites/default/default.settings.php' (Permission denied)
To fix this error, make sure you have write permission to the file and directory in which the file exists.
- Try applying the patch to test if it works:
git apply --index 1497310-statistics_config_settings-5.patch
If you get similar "patch does not apply" errors, delete your current branch and repeat from step 5 using an earlier date.
- Commit the patch's changes to your local branch.
git commit -m "Applying patch from issue 1497310 comment 5804956"
[test-branch 00329ef] Applying patch from issue 1497310 comment 5804956 7 files changed, 99 insertions(+), 66 deletions(-) create mode 100644 core/modules/statistics/config/statistics.settings.xml
- Now, attempt to pull in all of the changes that have happened since the commit you branched from.
git rebase 8.2.x
If the rebase has CONFLICTs, this will take more work; you can follow Rerolling patches: Failed Rebase
- Finally, create your patch by diffing your local branch (test-branch) against the upstream branch:
git diff -M 8.2.x test-branch > test-branch.patch
- Test your patch by applying it to the upstream branch.
git checkout 8.2.x
Switched to branch '8.2.x'
git apply --check test-branch.patch
No output is good. That means the patch applied cleanly.
- Check the size of the patch. If it is zero bytes go through these steps again until it larger than zero bytes. If it is a very different size from the original patch, then something probably went wrong during the reroll. There still needs to be more investigation on this patch.
- Upload it to the issue.
- Mark it back to "needs review!"
- Indicate whether it was an auto merge, if there were conflicts or if the file sizes were very different. If there were conflicts, describe what you did to resolve them. This will make it easier for the person reviewing the patch to know how carefully they need to review.
- Remove the "Needs reroll" tag.
- :) Congratulations! You've just rerolled a patch!