Skip to content

Instantly share code, notes, and snippets.

@rupsis
Last active October 24, 2023 16:09
Show Gist options
  • Save rupsis/faa96a2c88dadfa662be23a0dd421d66 to your computer and use it in GitHub Desktop.
Save rupsis/faa96a2c88dadfa662be23a0dd421d66 to your computer and use it in GitHub Desktop.
How to apply a Diff to blender

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).

Getting a patch

From a Pull request, under the "Files Changed" tab, on the right hand side, you'll see a "diff options" menu:

image

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.

Applying a patch

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.

Removing a patch

To remove a patch, you need to apply the patch with the revert command:

git apply -R ../1109014-patch-test.patch

Creating a 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)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment