How to create diff object from patch?

263 Views Asked by At

I have git patch in database. How can I convert it to diff object? Here https://github.com/libgit2/rugged#diffs I can take patch from diff diff.patch I want to make opposite operation.

1

There are 1 best solutions below

0
On

I have git patch in database

Do you mean you have a diff in text format stored? In that case you cannot convert it to a git_diff, as there is no parser for unidiff. It wouldn't help much, since there's nothing libgit2 would be able to do with such an object.

There will likely be one at some point, as it's needed for some versions of rebase, but for now I'd suggest storing which objects you diffed and recreating the diff from there.