2 ms·
Git executable is good for one off commands. Ideally, an in-language git implementation would also let you model & compute on git in a more enduring fashion.
by rektide 6y ago
Git executable is good for one off commands.
Ideally, an in-language git implementation would also let you model & compute on git in a more enduring fashion.
I don't think isomoprhic-get is particularly set up to allow folks to do incremental-computation, but one could imagine having the git tree in memory, & manipulating it there across a series of operations, & then generating a diff or what not, without needing to touch the file system or re-read the tree while multiple operations are happening.
This is a bit of a leap of topics, but I think one of the main things missing in JS is a good representation, an abstraction for files. Node has an api for opening files & reading & writing, very normal stuff, but it relies entirely on the platform. There's no abstract concept of a file at a path. Because of this, one can not easily substitute in something powered by S3 or something powered by WebDAV, since there is no abstraction in the language.
The once-well-known Node.js build tool Gulp is based very much around one of the libraries out there filling this gap, called vinyl-fs[1]. From the start of it's readme, "Vinyl is a very simple metadata object that describes a file. When you think of a file, two attributes come to mind: path and contents. These are the main attributes on a Vinyl object." By defining a file in an abstract manner, it allows for non-platform implementations, like S3, or WebDAV, or in-memory. It allows talking about files, without having to actually do unto files.
It's a bit hard to connect back to the discussion on git and git executable's run-to-completion model, but this idea, of the language having it's own abstractions & being able to do computing inside the runtime without having to keep going back to the platform as the one & only source of truth, allows a lot of flexibility for manipulating the system that is otherwise often cumbersome & involves redundant back & forth work.
Getting away from git's normal run-and-execute command model, & comprehending git is the sort of thing that's super useful if you're writing editors, ides, github-like systems, & gitops tools.
[1] https://github.com/gulpjs/vinyl-fs https://github.com/gulpjs/vinyl-fs