Suppose I have a project implemented in a specific programming language whose use is fragmented into two (or more) versions, for any reason.
These two versions provide different mechanisms to implement some functionality of the project. Thus, the same code is not portable between versions.
How to organize this situation in a git repository? Nevertheless, Keep directories for specific versions within a branch? Duplicates branchs in the same repository? Or use different repositories for each version?
It depends a bit on the programming language, but if the difference between the two versions results in a significant difference in your code, then I would want to:
Once you’ve separated the two different implementations, you can keep them in the same branch just as you’d keep any two different implementations of the same interface in a branch.
For a trivial difference, for instance if all you need is to pass slightly different flags to some function, then I’d probably not go to all that trouble. Instead I’d just do the equivalent of:
But beware, insignificant differences can grow as the code develops, and you end up with a mess of platform detection code. You should aim to test the platform in at most one place, or even better just control the whole thing with a build option. In the above case you could call that
USE_USEFUL_NEW_FLAGrather than explicitly coding that it depends on a particular platform version. Then it’s up to your build configuration to know which platforms support which features.