1

I am developing an C++ application, which creates tree like structures (collections) of strings. I want to add the ability to save the information of these tree structures remotely/locally (can be text files) and together have version control function. In other words, I want to save and version control the tree structures that were created by my application. Version control feature should have the ability: to keep project versions, to merge projects, to create and merge branches, to detect and let user solve conflicts and to be manged mainly by application UI. I see two options:

  1. I could code version control feature by my self.

  2. Or I could somehow embed Git (or other version control system) into my application, which would handle most of the work behind the scenes.

I did not find any useful information in the internet on suggestions, strategies about how to implement version control systems in your own application.

I would be grateful for any insights which strategy to choose. Maybe there are more approaches? What are advantages/disadvantages? Which approach would require least efforts?

  • 2
    I think you need to be more specific in your requirements here. Do you need a version control system or do you just want to store version history? – JimmyJames Nov 4 at 18:56
  • What do you want to version? The structures themselves? Maybe some versioning like provided with boost::archive would serve you better. – πάντα ῥεῖ Nov 4 at 19:07
  • 3
    I think this is a good question that deserves an answer. I'm just not where I can get into it all right now. So I'll just share what I've found so far: Is there an API for git?. How does git work internally?. I offer these only to show that with effort your option 2 is viable. However, you should always keep in mind what you actually need rather than assume you must do a full git implementation. – candied_orange Nov 4 at 19:55
  • 1
    With a decent architecture you should be able to create your applications UI in such a way that it wont matter which option you go with to your users. – candied_orange Nov 4 at 19:58
  • 1
    Ultimately, git is a version control system for text files. Treat it accordingly. – Robert Harvey Nov 4 at 20:59
1

There are three main options:

  1. Run the git application itself using subprocesses. Most languages have ways to start new processes, you could run git this way. However, groking the output produced by git may be a problem.
  2. Include git in your program as a library. Several languages have git libraries available, such as Python. You could also link to a C library such as libgit2. This is more work, but hopefully makes handling errors and other unexpected events easier.
  3. Embed an existing vcs GUI into your application. This is by far the easiest. Your program needs to know nothing of the versioning part, it just interacts with the file system. You could run the GUI as a separate application & window. If you must, you could use a GUI implemented in e.g. Python and include the relevant widgets in your own GUI.

Rolling your own version control system is probably not a good idea. There are a number of excellent solutions (such as GIT, SVN, RCS, etc, etc), each with their own characteristics. Making a production-ready VCS is not for the faint of heart...

You might want to serialise your data structures to ASCII files, e.g. JSON or YAML, to make them more managable for git.

The key advantage of using an existing GUI is that they did all the hard work of finding out how users want to interact with a VCS, and handling most common errors.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.