How do I use Git for Blender patches?

Hello, I am new to Blender and using git to try out patches.

I’ve just set up my Blender build environment and now I’d like to try out the OptiX device implementation to Cycles - ⚙ D5363 Add OptiX device implementation to Cycles

How do I use cmd prompt to harness git to download and implement into my build?

Thank you :slight_smile:

you have 2 choices here :

  1. You download the diff your self and apply it, there is nothing in git that will make it download it from the website and apply it. I generally just click the download raw diff link on the page and use the patch application to apply it. (patch -p1 --dry-run < downloaded_diff.diff) , git apply may work, but i have never used it.

  2. install arcanist it’s a little bit more work, but once it is installed, applying any patch is as easy as typing arc diff D5363 on the console.

2 Likes

the first choice worked for me but the second one i get this.
Usage Exception: Unable to find any git commit named ‘Dxxxx’ in this repository.
after looking at the Arcanist user guide, it says arc diff xxxxx is for sending commits for review not for trying!.

yeah my bad, it’s arc patch Dxxxx

1 Like

thanks for the swift help.

Where do you do this? like where is the patch application, why is arcanist hard to download?

you’re on your own obtaining the patch application, git apply could also work for the purpose of manually applying the a patch though

Ok I gotcha, so there’s an application called patch and another called git apply? because I have the .diff file which is supposed to be the patch already downloaded, Idk what to do from here

the diff file is essentially a list of changes from before->after, you need an external application to apply them, could be patch, could be git apply whatever you prefer there…

Ok, I downloaded git apply, this right? Git - git-apply Documentation
what now

I’m a little confused here, if you didn’t have git, how did you get the blender code?

https://dev-files.blender.org/file/download/biwhoemtuxvpmeb46hxz/PHID-FILE-v3o75rmyj2rs6zgus7ww/offscreen_float_16.diff
this was the .diff file
Also, how do I do any of this to get it working? so I didn’t have to download git apply?

Oh that does not work that way, patches are generally source code modifications (but hard to say without knowing what patch you have), so usually you get the blender source code, you apply the patch and you rebuild blender from scratch.