I inherited a php project of 3rd party code with a good deal of company-specific customization lumped on top of it. Now I’ve got to upgrade it and the person who owned the project is the one I’ve replaced and no one else knows what changes are 3rd party changes and what changes are company specific.
It’s not too terrible a situation because he did check in the initial version of the application from a few updates back. But then he checked in 2 or 3 updates and about 10 or 15 patches.
So, say I’ve got a completely generic 3rd party version from the company we bought the code from. How do I go about merging the changes the last developer made into a fresh version. We’re using git.
There’s a few approaches you might consider:
-
You could download a vanilla copy of the library from the same version as used in your project. Then use a diff utility to find what has been changed between your version and the vanilla version. This approach could work well if you know the version and there aren’t too many changes.
-
You could use
git log
to find commits affecting the directory containing the library then use that to determine what changes have been made. This won’t work if you’re not 100% certain that no changes were made before the library was initially committed. -
If you’re really confident in your automated testing suite then you could try just swapping the libraries and seeing what fails. I wouldn’t do this if you suspect there has been changes within the original methods of the library, but if only new methods have been added you’ll probably find which are missing.
-
If you’re reasonably confident that the patches made since won’t interfere with the changes then you could use
git format-patch
to generate a patch file for all the changes since your local version, thengit apply
to make those changes to your local copy.
While options 2 – 4 are probably more sophisticated, option 1 is probably what I’d end up doing most often.
3