Nice, this is really cool. Similarly, I had to implement extra plumbing on top of Git to make snapshotting possible. I'll update the blog post with a reference.
GitUp uses libgit2 under the hood. GitUpKit is an Obj-C wrapper I wrote at the time to make it much easier to use.
Unlimited undo / redo is achieved by taking a snapshot of the entire repo before and after any operation (e.g. checking out the repo or creating a branch etc...). The inspiration I had at the time was that is it is trivially cheap to take such snapshots: essentially all you need is a list of all the refs.
Then when you need to undo, you have 3 things:
1 - current state of all the refs in the repo
2 - state of all the refs from the before snapshot
3 - state of all the refs from the after snapshot
Compute the delta between 3 -> 2 and apply on top of 1.
The same technique allows to do the Time Machine feature.
Unlimited undo / redo is achieved by taking a snapshot of the entire repo before and after any operation (e.g. checking out the repo or creating a branch etc...). The inspiration I had at the time was that is it is trivially cheap to take such snapshots: essentially all you need is a list of all the refs.
Then when you need to undo, you have 3 things: 1 - current state of all the refs in the repo 2 - state of all the refs from the before snapshot 3 - state of all the refs from the after snapshot Compute the delta between 3 -> 2 and apply on top of 1.
The same technique allows to do the Time Machine feature.