I would have used a library that parsed the diff properly - or better yet one that applied the diff algorithm natively without going through a patch file format. E.g. something like this in Rust:
https://github.com/utkarshkukreti/diff.rs (there are similar libraries for other languages).