Assuming a patch was created from a specific commit in the past, and no longer applies to HEAD.
How can I find either the first or better the last commit in the history of HEAD, where this patch applies with "git apply" ? Maybe something with git bisect? But which command will tell me if a patch applies?
Ideally I want to move back to that commit, apply the patch, then rebase on or merge with the original HEAD, and diff again to create a new patch, unless there was a conflict. After this I would like to go back to the original HEAD, so I can continue with more patches.
Background: There is a number of patches that need to be rerolled... (and yes, there are ecosystems where patches are still a thing..)
git diff
, orgit format-patch
? – Optative:P
– Optativegit bisect
requires that you pass it one "good revision", which in this case is a revision where the patch applies without conflicts.git bisect
won't always be a good tool for this because of that, I suspect. – Optativegit log -S <search-string>
orgit log -G <regex>
to find the first addition/deletion of a line<search-string>
or<regex>
too, right? It might help you find possible candidates for "the first commit" where a patch might have been generated from. – Optativegit format-patch
to generate patches? The patches themselves will record which commit they come from. – Optative