A git diff
shows the changes between two files. By extendtion, a patch
is a diff with more contextual information (file line numbers, etc.).
We can use git patches to easily apply changes to Blender (for testing, review, etc).
From a Pull request, under the "Files Changed" tab, on the right hand side, you'll see a "diff options" menu:
From there, you can either download a diff or a patch. Tip: It's name the diff/patch the PR number, it's a good idea to rename it to something meaningful.
Once the diff/patch is downloaded, you can apply it via:
patch -p1 < ../109014-patch-test.patch
(Note: I keep the diff/patch files in the directory above my Blender source files, that way I don't have to deal with the .diff/patch files in git).
Once the patch applies, you can build blender and try it out.
To remove a patch, you need to apply the patch with the revert command:
git apply -R ../1109014-patch-test.patch
To create a diff
git diff > 1109014-patch-test.diff
to create a patch:
git diff --patch > 1109014-patch-test.patch
Note: The command structure for this is: git diff <target-branch> > file-name.diff
Where:
>
is an output re-route to a file.--patch
is a flag to create a patch from the diff command- is the name of the branch you want to create a diff from (by default it's main/master)