Live data from Hacker News

Gitlet.js – Git implemented in 1k lines of JavaScript (2015)

gitlet.maryrosecook.com

71–78 of 78 posts

Re: Gitlet.js – Git implemented in 1k lines of JavaScript (2015)

#71
post #31

There is also Shit, a git implementation in an almost POSIX shell [0]. Not my software. [0]: https://git.sr.ht/~sircmpwn/shit

every time I look at these custom git repository I'm confused as to how I can read the code. For inept people like me it's here: https://git.sr.ht/~sircmpwn/shit/tree

The term “tree” is pretty common in source control systems. So, for me, I just look for a link to the “tree”, which you managed to find.

Just putting it out there for future readers.

Re: Gitlet.js – Git implemented in 1k lines of JavaScript (2015)

#74

Reading stuff like this makes me lose all hope to ever really understand (and being able to tame) git: > Under the covers, the pull command runs git merge FETCH_HEAD. This reads FETCH_HEAD, which shows that the master branch on the beta repository was the most recently fetched branch. It gets the commit object that alpha’s record of beta’s master is pointing at. This is the second commit. The master branch on alpha i…

[deleted]

Re: Gitlet.js – Git implemented in 1k lines of JavaScript (2015)

#75
post #43

Earlier quoted context omitted.

Fair point, I had honestly never read the docs page on restore. But , I still have to disagree. They may not have landed on the final shape of the API, but they are clearly encouraging people to use restore for this purpose. There is no ‘warning’ message in the CLI. In fact the opposite, the help text in every ‘git status’ message explicitly states to use ‘restore’ for the case of resetting the changes of a single fi…

> the help text in every ‘git status’ message explicitly states to use ‘restore’ Good point. This makes no sense. There should either be a warning in the documentation and `git status` should not recommend it, or there should not be a warning in the documentation and `git status` should recommend it. It’s either ready for use or not, it shouldn’t be inconsistent about it. I agree it’s a positive change, but the curre…

Thanks for the explanation, I did not realize that about —-, good to know!

Re: Gitlet.js – Git implemented in 1k lines of JavaScript (2015)

#76
To people who're feeling like they are not able to understand or write something like this:

While the author is definitely skilled, please know that you're looking at a finished project that took what looks like ~10 months of work.

Do not compare what you know now with what the author has accomplished. They likely learnt a lot along the way and you would as well.

If you're really keen to understand it start with the first commits: https://github.com/maryrosecook/gitlet/commits/master?after=...

The first two (meaningful) commits simply create the .git directory and the tests for it. You can almost certainly understand that.

Re: Gitlet.js – Git implemented in 1k lines of JavaScript (2015)

#77
post #36

So, I'm going to put that out there, but I really wish I could read security-sensitive code like this. TLS implementations, cryptographic implementations, etc. It would be really amazing if there was a way for Github to automatically display code like this by extracting comments out. In general I think it's an amazing way of learning, I remember reading the gobyexample.com website and writing the same thing for go as…

Comments are good, this particular instance, not so much. This description spends a lot of time stating the blindingly obvious, eg: if (addedFiles.length === 0) { // Abort if no files matched path. throw new Error(files.pathFromRepoRoot(path) + " did not match any files"); Or: // If --bare was passed, write to the Git config indicating that the repository is bare. // If --bare was not passed, write to the Git config…

You don’t have to explain TLS in this manner, but you could comment the relevant specification paragraphs next to the code to facilitate audits.
Post reply on HN