3 ms·
Let’s Build a Version Control System
- abdullahkhalids 6y agoWhen I was a young and stupid physics major with one programming course under my belt, I tried to write a VCS in emacs lisp, to version control my writings. Since, I didn't know any better, I thought the best way was to send every version as an email to a gmail account, as well as an updated index. I wish I had finished it.
- shakna 6y agoWith the way MIME can embed MIME [0], you could also have a complete version history inside a single email just by wrapping the previous email. That sounds terrible. Terrible and beautiful. [0] https://tools.ietf.org/html/rfc5621#page-7 https://tools.ietf.org/html/rfc5621#page-7
- mitchtbaum 6y agohttps://music.youtube.com/watch?v=AmJ9YZtL9A8 https://music.youtube.com/watch?v=AmJ9YZtL9A8
- docuru 6y agoLast few weeks, I found a piece of code to version control an object in JavaScript (using Proxy). In just 68 lines of codes. - The original answer https://stackoverflow.com/a/40498130/5775993 https://stackoverflow.com/a/40498130/5775993 - I rewrite it to a class in Typescript https://gist.github.com/hieunc229/ca6aeb507de42a933bafe31e0a174dd0#file-versioncontrolobject-ts https://gist.github.com/hieunc229/ca6aeb507de42a933bafe31e0a...
- Hendrikto 6y agoThis is terrible, I love it. > If you actually use this thing, you are accepting the faults, the bugs, and the potential to be personally infected by the Black Plague, without regard for your own safety, and acknowledge that you are an absolute fool.
- ptx 6y ago> For reasons known only to the almighty gods, set -e that usually causes an exit on a failed command, doesn't work that way inside functions. I was somewhat alarmed for a second there, but at least on bash (version 5.1.4) "set -e" definitely does work inside functions. It doesn't work in pipes though - you'll also need "set -o pipefail" for that. Busybox also seems to include awk. Would that have been a slightly less terrible choice of implementation language, or even worse?
- gray_-_wolf 6y agoActual caveat is that the -e does not work in if statements. Compare: +$ cat x #!/bin/sh set -eu foo() { echo 1 false echo 2 } foo +$ ./x 1 +$ cat x #!/bin/sh set -eu foo() { echo 1 false echo 2 } foo ||: +$ ./x 1 2
- shakna 6y ago> Busybox also seems to include awk. Would that have been a slightly less terrible choice of implementation language, or even worse? Two parts to that - I don't know awk well enough. I would need to re-implement diff/patch in awk, or make heavy use of sh anyway. > I was somewhat alarmed for a second there, but at least on bash (version 5.1.4) "set -e" definitely does work inside functions. The number of _exceptions_ to set -e is actually quite a number: > If not interactive, exit immediately if any untested command fails. The exit status of a command is considered to be explicitly tested if the command is used to control an if, elif, while, or until; or if the command is the left hand operand of an ''&&'' or ''||'' operator. set -o pipefail only catches some of those, especially the while and ifs that will continue to standout to blow your foot off... But even more import to note: sh is not bash. We're talking about POSIX shell. In Busybox's case, it is based on ash. Which doesn't actually have pipefail to begin with.
- turminal 6y agoSee also https://git.sr.ht/~sircmpwn/shit https://git.sr.ht/~sircmpwn/shit