3 ms·
Exercises like this are very educational for taking magic away from version control tools. Some time ago I did a similar exercise in Haskell: https://github.co
by dmytrish 9y ago
Exercises like this are very educational for taking magic away from version control tools.
Some time ago I did a similar exercise in Haskell: https://github.com/EarlGray/omit https://github.com/EarlGray/omit (it also took about 500 lines of unnecessarily dense Haskell), implementing barebone functionality of `git log`, `git add`, `git commit`, `git status`, `git diff` (using an existing Haskell diff library). It was eye-opening how simple the concepts of git are.
On the other hand, the most interesting parts of git are still left out: branches, merges, conflict resolution, remote sync. I'm wondering how many more lines are needed for this.
- AtticusTheGreat 9y agoThe thing is, all of these details are implemented in the git command line tool, not in a library. So it is pretty difficult to write a tool that works exactly the same way the command line tool does, or if you do manage to do it, it'll be fragile since the command line tool could change behavior at any time.
- hdhzy 9y ago> It was eye-opening how simple the concepts of git are. Exactly! Sometimes I'm bewildered how complex git porcelain (CLI interface) is compared to the basic building blocks. Usually when I want to do something complex in git I think of how I want the structure to look like and then figure out which command does that ("was it git reset --soft or git stash --keep-index that did X?"). Now when I'm thinking about it I usually imagine states (like DOM trees). I see current state and the state I want to have the repo in (commits, working directly, index). What I'm missing here is a React-like reconciler that will transform one into other.
- federicotdn 9y agoI have a similar project, also using Haskell: https://github.com/federicotdn/hvc https://github.com/federicotdn/hvc