title: Suitable Tool to merge C SourceCode?
body: <p>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. </p>
  
  <p>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.</p>
  
  <p><a href="https://i.stack.imgur.com/og0kI.png" rel="nofollow noreferrer">http://i.stack.imgur.com/og0kI.png</a></p>
  
  <p>For my program, it's only necessary to find the differences between the .c and the .h sources.</p>
  
  <p>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.</p>
  
  <p>I'm currently experimenting with the java version of the tool diff-match-patch
  (<a href="http://code.google.com/p/google-diff-match-patch/" rel="nofollow noreferrer">http://code.google.com/p/google-diff-match-patch/</a>), 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.</p>
  
  <p>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 (<a href="https://stackoverflow.com/questions/9122948/run-git-merge-algorithm-on-two-individual-files">run git merge algorithm on two individual files</a>), merging the old, modified version with the new version, using the old, original version as the common ancestor. This is the command I used:</p>
  
  <pre><code>git merge-file -p &lt;current&gt; &lt;common&gt; &lt;other&gt; &gt; &lt;dest&gt;
  
  git merge-file -p old_mod old_original new_original &gt; new_mod
  </code></pre>
  
  <p>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.</p>
  
  <p>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.</p>
  
  <p>The update program will be run on a Windows PC, so the tools used should be available there.</p>