I'm currently working on a program which updates the SourceCode of a big program. My program is written in Java and the SourceCode to be updated is written in C and the original SourceCode is modified, so it's not possible to simply replace the old version with the version which is coming out because the modified Code would be gone.
So I figured out it is necessary to update the old modified Version with the changes between the old original version and the new original version. Based on the diff of the two versions, a patch should be created and applied to the old, modified version, resulting hopefully in a updated version with modified SourceCode. I tried to make a little flow Diagram to make it more clear.
https://i.stack.imgur.com/og0kI.png
For my program, it's only necessary to find the differences between the .c and the .h sources.
And now I'm looking for a suitable tool to find the differences between the new Version of the program and the old version with the original source code, save the differences and apply them to the old, modified version.
I'm currently experimenting with the java version of the tool diff-match-patch (http://code.google.com/p/google-diff-match-patch/), which is originally designed for plaintext. It finds the differences between the files nice and simple and gives also the possibility to display them as a simple HTML page. But it seems to have quite some issues to merge the code later on, mainly because it is originally designed for plaintext.
I also tried to use git, but it I am not really experienced with it and I just looked up how to merge two individual files right here (run git merge algorithm on two individual files), merging the old, modified version with the new version, using the old, original version as the common ancestor. This is the command I used:
git merge-file -p <current> <common> <other> > <dest>
git merge-file -p old_mod old_original new_original > new_mod
But sadly the result was even worse than before. To conclude I'm looking for a tool which is commandline-based, or executable from a java tool to find differences between files and appling the differences to another file, resolving conflics as much as possible. The modified version differs from the original version in terms of format and added codeblocks in some of the files.
I am also open to suggestions and alternatives approaches on how to update this modified program with the changes of the new release of the program.
The update program will be run on a Windows PC, so the tools used should be available there.