Live data from Hacker News

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

gitlet.maryrosecook.com

21–30 of 78 posts

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

#22
post #11

In the 'real' Git, one of the functions I use frequently is `git checkout -- .`, which discards any unstaged changes. Looking at Gitlet's implementation, it wouldn't handle that well as `checkout` can only take a ref. So I guess I'm wondering what the real `git checkout -- .` actually does behind the scenes?

FWIW, since Git 2.23 I prefer using "git switch" and "git restore" instead of "git checkout".

This is correct, ‘git restore’ is the way to do this in the current version of git. ‘checkout —-‘ still works, but the ‘help’ text in ‘git status’ now recommends using ‘restore’.

Not only is it more semantic, it reduces the complexity of ‘git checkout’ which is a common complaint.

Really, It doesn’t make much sense to tack on some random ’--‘ flag on ‘checkout’ for that functionality. ‘restore’ is clear and describes what it does.

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

#23

this is cool! but I'm curious to see a git blame implementation.

You mean the most conflict driven and passive aggressive feature in any programming tooling?

Nah, that award is for team time logging tools. Blame is normally used as a "who to ask" tool. Often the answer it gives you is "who last refactored this file" or "who originally moved this file from another location and lost the link to the prehistoric era when the interesting stuff happened"

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

#24

this is cool! but I'm curious to see a git blame implementation.

You mean the most conflict driven and passive aggressive feature in any programming tooling?

Another word for blame is 'responsibility'.

In a political organization, it's good to take responsibility for something, but bad to blame. A generous interpretation of that is that the person/group who made the decision should raise their own hand, and that it's a faux pas for others to point them out.

In a healthy one, you can recognize it's the same thing, and the important thing is how you respond to it (i.e., it's important to understand the responsible party so you can understand the reasons/motivations for the action, and accept them or address them).

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

#26
post #11

In the 'real' Git, one of the functions I use frequently is `git checkout -- .`, which discards any unstaged changes. Looking at Gitlet's implementation, it wouldn't handle that well as `checkout` can only take a ref. So I guess I'm wondering what the real `git checkout -- .` actually does behind the scenes?

FWIW, since Git 2.23 I prefer using "git switch" and "git restore" instead of "git checkout".

My problem with restore, is it doesn't print anything. Checkout tells you how many files were restored

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

#27
post #25

We have a project at UC Berkeley for CS 61B (undergrad data structures) called "Gitlet", where we need to make a git implementation in Java. Was super fun! If you're curious: https://inst.eecs.berkeley.edu/~cs61b/sp20/materials/proj/pr...

Ah, Hilfingr memories.

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

#28

In the 'real' Git, one of the functions I use frequently is `git checkout -- .`, which discards any unstaged changes. Looking at Gitlet's implementation, it wouldn't handle that well as `checkout` can only take a ref. So I guess I'm wondering what the real `git checkout -- .` actually does behind the scenes?

Ok, I re-read your command, and realized you’re doing ‘checkout’ minus minus period (to be explicit).

Honestly it had never even occurred to me to use the period there, but it does work :) I always used it for single files.

As we said in other comments, that’s why they introduced ‘restore’.

But, if you’re looking to reset all changes, in every file back to the state of the HEAD, then I believe ’git reset —hard’ would be the appropriate tool!

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

#29
post #25

We have a project at UC Berkeley for CS 61B (undergrad data structures) called "Gitlet", where we need to make a git implementation in Java. Was super fun! If you're curious: https://inst.eecs.berkeley.edu/~cs61b/sp20/materials/proj/pr...

Ah, Hilfingr memories.

Haha yep, he's still teaching. My semester of instruction from Prof Hillfinger was cut in half thanks to the pandemic though :(

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

#30
I once had to do some git stuff programmatic, back then I was working in python. I found out about this library called porcelain (I think it wasn't being maintained anymore). I end up having to go through the whole code so I can get some things done. Do not recommend. It is indeed a cool and helpful thing that you did. Congratulations.
Post reply on HN