How to apply patch when description has no "base" hash information?

When I want to apply a patch I usually look at History and “base” hash information and then “git checkout [base]”. But some patches like this have no “base” information:

I try to “git checkout” by date:
git checkout 'master@{2021-06-23 14:06:00}'

But I get this message:

warning: Log for ‘master’ only goes back to Fri, 25 Jun 2021 08:47:08 -0300.

So, how to “git checkout” to the correct state where the patch could be applied?

patch(1), by its nature, has some leniency over how it works. The patched file(s) do not have to be in exactly the particular state that the original developer was working with, provided it can find sufficient unchanged context around the patch areas.

In other words, have you tried applying it to a more current source tree?

Hi. Blender development evolves rapidly. In the patch that I have shared above it could no longer be applied in master from 2021-06-25, just two days after the last version of the patch had been published.

If the patch has “base” information, I never had a problem applying patches previously by moving to “git checkout [base]” status.

Your command works just fine here, perhaps you started out with a shallow clone back in june?

1 Like

I’m not sure if I understand what you mean. My local cloned repository is old, maybe it started two years ago. Being in Master and after doing “make update” these are my outputs:

$ git checkout ‘master@{2021-06-23 14:06:00}’
warning: Log for ‘master’ only goes back to Fri, 25 Jun 2021 08:47:08 -0300.
Nota: cambiando a ‘master@{2021-06-23 14:06:00}’.

Te encuentras en estado ‘detached HEAD’. Puedes revisar por aquí, hacer
cambios experimentales y hacer commits, y puedes descartar cualquier
commit que hayas hecho en este estado sin impactar a tu rama realizando
otro checkout.

Si quieres crear una nueva rama para mantener los commits que has creado,
puedes hacerlo (ahora o después) usando -c con el comando checkout. Ejemplo:

git switch -c

O deshacer la operación con:

git switch -

Desactiva este aviso poniendo la variable de config advice.detachedHead en false

HEAD está ahora en 2851602052c Add a reason for why an Addon can not be loaded. This change gives a more detailed explanation of the issue and may help the Addon Developer to identify what exactly needs to be changed.

*Sorry, part of the output is in Spanish

$ patch -p1 < patch
patching file intern/cycles/blender/blender_python.cpp
Reversed (or previously applied) patch detected! Assume -R? [n]

*“patch” is the name with which I save the file.

I really don’t know what to answer here. If I write “y” I get:

Hunk #1 succeeded at 707 (offset 2 lines).
Hunk #2 FAILED at 747.
Hunk #3 FAILED at 778.
Hunk #4 succeeded at 801 (offset 7 lines).
2 out of 4 hunks FAILED -- saving rejects to file intern/cycles/blender/blender_python.cpp.rej
patching file intern/cycles/blender/blender_sync.h
Hunk #1 succeeded at 114 with fuzz 2 (offset 12 lines).
patching file intern/cycles/blender/blender_sync.cpp
Hunk #1 FAILED at 614.
1 out of 1 hunk FAILED -- saving rejects to file intern/cycles/blender/blender_sync.cpp.rej
can't find file to patch at input line 83
Perhaps you used the wrong -p or --strip option?
The text leading up to this was:
|diff --git a/intern/cycles/device/device_denoise.h b/intern/cycles/device/device_denoise.h
|--- a/intern/cycles/device/device_denoise.h
|+++ b/intern/cycles/device/device_denoise.h
File to patch:

That is basically what I do manually when I do “git checkout [base]” when description gives “base” information, obviously when I apply the patch with “patch -p1 < patch” it just successfully patch all files in that case.

This is a patch on top of the cycles-x branch, so you’d need to use that instead of master.

1 Like

Oh now that you mention it I feel like a fool. Actually it was logical that this was so.
Sorry and thank you.

Not sure that swapping out master for cycles-x will work there either, apparently that style checkout looks in reflogs which the history may not go as far back.

I manually got a log ( git log > log.txt ) from the cycles-x branch and picked a commit around that date

if you check out dca4955b5381cf1fb11c70a6dee9dbe60ed14e77 the patch will apply cleanly

1 Like

Yep, with “git checkout ‘cycles-x@{2021-06-23 14:06:00}’” still failed to apply it on some files (probably still due to my mistakes).
With “git checkout dca4955” it worked correctly!

Thank you