Earlier quoted context omitted.
> Not only is it more semantic, it reduces the complexity of ‘git checkout’ which is a common complaint. It doesn’t since the feature can’t be removed from git checkout for BC reasons.
It does, because it sounded like he was concerned with the complexity of explaining the broadness of uses for git checkout. Now we can treat git restore like it is a separate thing.
Gitlet.js – Git implemented in 1k lines of JavaScript (2015)
41–50 of 78 posts
Re: Gitlet.js – Git implemented in 1k lines of JavaScript (2015)
#42So, 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…
As @chungy says in a sibling comment, this is what's known as a literate program. It never really took off, and I suspect it's partially because doing it well means you'll be writing a lot more text than you'd typically see in a program's comments. See http://www.literateprogramming.com/ for more information and examples.
https://underscorejs.org/docs/underscore-esm.html
Re: Gitlet.js – Git implemented in 1k lines of JavaScript (2015)
#43Earlier quoted context omitted.
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…
> ‘git restore’ is the way to do this in the current version of git. No, that’s incorrect. `git checkout` is the way to do this in the current version of Git. The current version of Git allows you to use `git restore`, but the documentation says this about it: > THIS COMMAND IS EXPERIMENTAL. THE BEHAVIOR MAY CHANGE. Until that warning goes away in a future version of Git, `git checkout` is the way to do this.
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 file, where it used to say use ‘checkout —-‘.
Yeah I’m used to using checkout —- like the rest of us, and sure we can all still do it if we want. But I would never recommend ‘checkout —- filename‘ to anyone in 2021. It doesn’t make any sense that that would be how you do that. It’s confusing trying to explain it to someone.
“Yeah I know you usually use this to completely change branches, or go to a particular commit hash. But if you use this weird ‘—-‘ flag & a file name, it does a mini ‘reset’ on that one file”
Why would you use some random flag on a command (checkout) that is typically used for a totally different use case? If anything, this should be a flag on ‘reset’.
I’m not a git ’complexity hater’, but it’s a perfect example of why a lot of people complain about git.
Re: Gitlet.js – Git implemented in 1k lines of JavaScript (2015)
#44this 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?
Re: Gitlet.js – Git implemented in 1k lines of JavaScript (2015)
#45Gitlet: Git implemented in JavaScript - https://news.ycombinator.com/item?id=8931984 - Jan 2015 (66 comments)
Also: Git implementation in 1k lines of Node.js - https://news.ycombinator.com/item?id=16453979 - Feb 2018 (2 comments)
Re: Gitlet.js – Git implemented in 1k lines of JavaScript (2015)
#46Earlier quoted context omitted.
You mean the most conflict driven and passive aggressive feature in any programming tooling?
That's Linus for you, I guess? I dunno, I always found `git blame` really funny yet at the same time, I empathize with those who are a little taken aback by it (including... what's the company's name who makes IDEs who calls it "annotate"... ?). I largely love it because most of the time when I `blame`, that's exactly what I want to do. I don't need software to give me a nicer verb so I can pretend that's not what I'…
Re: Gitlet.js – Git implemented in 1k lines of JavaScript (2015)
#47Not to mention the difficulty of manually keeping the english type descriptions in concert with the actual code -- some things computers are much better at than humans, verifying types is one of them.
All that said, the flavor text is well written and I'm glad the author took the time to include it!
Re: Gitlet.js – Git implemented in 1k lines of JavaScript (2015)
#48So, 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…
It's a very old idea. Donald Knuth implemented it with both Pascal and C to promote an idea of "literate programming" -- you'd literally just write prose sprinkled with little bits of programming. On compilation, you can choose to compile either the documentation or program.
Re: Gitlet.js – Git implemented in 1k lines of JavaScript (2015)
#49So, 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…
It's a very old idea. Donald Knuth implemented it with both Pascal and C to promote an idea of "literate programming" -- you'd literally just write prose sprinkled with little bits of programming. On compilation, you can choose to compile either the documentation or program.
Re: Gitlet.js – Git implemented in 1k lines of JavaScript (2015)
#50So, 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…
As @chungy says in a sibling comment, this is what's known as a literate program. It never really took off, and I suspect it's partially because doing it well means you'll be writing a lot more text than you'd typically see in a program's comments. See http://www.literateprogramming.com/ for more information and examples.