Reputation: 924
I am currently working on a flashcard application where decks created by the user act as Git repositories. When a card is created in the app, a new file is committed to the repository, when a card is changed, the file is changed, and when a card is deleted—well, you get the point.
The file format that the application saves to is a gzipped Git repository, so at no point will I ever need to write the repository to disk. How can I best handle treating decks as a Git repository in this way?
Upvotes: 9
Views: 3710
Reputation: 137
Take a look at libgit2. It supports the in-memory git repository scenario and also has bindings to many languages:
For example, by using rugged, the ruby binding for libgit2, you could do things like this:
a_backend = Rugged::InMemory::Backend.new(opt1: 'setting', opt2: 'setting')
repo = Rugged::Repository.init_at('repo_name', :bare, backend: a_backend)
Upvotes: 10