9 ms·
Git as a Storage
- carapace 5y agoKind of an aside, but I've been toying with a simple functional language based on Joy and when it came to exposing the filesystem it seemed too fraught with impurity, so instead I'm just using git as the data storage system. Instead of strings or blobs you have handles that are essentially three-tuples of (git object hash, offset, length). It's early days yet, but so far the approach seems promising. (In re: string literals, well, your literal is in a source file, and your source file is in git, so each literal has its tuple already, eh?)
- rectang 5y agoWhat I really want to see is a blog post on Git as an undo engine. This is related to the idea of using Git as general storage, in that the undo history can be persisted, and then reconstituted by a new process. The trick would be to make all actions compatible with conversion to and from a commit.
- yepguy 5y agoEmacs kind of has this in the form of magit-wip-mode. It doesn't sync with the undo system but it does persist every file save event since the last "real" commit.
- muixoozie 5y agoI need to look into this. Just yesterday I lost some work (only maybe 10 minutes worth) when I was updating my org notes. I staged some files, committed them, but made a typo in the commit message. I ended up reverting the commit when I meant to amend. Then I discarded the the staged reverted changes and noticed the status said I was still reverting. So I looked up the command to get me out of that state. I ran 'git revert --abort' and it blew away my unstaged changes. Ah well, those versioned backups I have Emacs do are going to save me this time, or so I thought.
- minikomi 5y agoIf you did actually commit, you should be able to find the changes on the reflog In magit, it's accessable from the log menu Create a branch, reset it to the badly worded commit hash and then you can try to ammend again.
- muixoozie 5y agoI was breaking a bunch of unstaged changes into two commits, and the part I lost had not been committed.
- azhenley 5y agoI've seen programs that serialize the undo manager, but is there an advantage to using git instead? I suppose it does most of the work for you, but you'll still need to manage actions that can be undone but don't directly modify a file (these are entirely app dependent, but could be something like changing which tab document is selected).
- rectang 5y agoThe advantage is that Git's data structure is an open design, with existing tools able to introspect and possibly manipulate it, with potential users and contributors able to leverage their existing knowledge, and with documents/projects still being parseable decades from now. I have dreams of implementing an music composition tool / audio editor with a line-oriented edit-decision-list (EDL) text file format that where changes could map coherently onto git history. Ideally, that EDL format would be an open standard as well: I've contemplated the Pure Data file format and AES31 as possible candidates. This is just at the conceptual stage, though.
- dTal 5y agoOne problem with git is that it assumes you have some sort of "diff" utility for before and after snapshots. For some types of things, that's not feasible - you can't easily diff two images and work out what filter was used. Sometimes you instead you want to create the diff, and generate the "after" snapshot. You could emulate this by stowing the information somewhere hidden and writing a fake "diff" that simply retrieves it - but saving the edit tree and reconstituting it is supposed to be git's job! You end up reimplementing bits of git, just to make git work.
- rectang 5y agoI suppose the "diff" limitation would constrain the potential use cases. For my purposes, I don't think that would be a problem, because the project format would consist of two types of files: • PCM audio files which are captured once and then never modified. • Line oriented text files for which the traditional "diff" functionality suffices.
- rektide 5y agoone of these years i'll have something fun to show you
- asperous 5y agoI thought it was a neat article, I assumed it was talking about git lfs. It would be neat if github could store all its data in git, similar to fossil scm. But I suppose microsoft would not want to lose lockin.
- gopalv 5y ago> I thought it was a neat article I think the article talks about the "What" part of the problem, but the actual code is much more interesting in the "How" sense. Like the git-ref stuff makes sense as you read the code https://github.com/ligurio/git-test/blob/master/bin/git-test#L466 https://github.com/ligurio/git-test/blob/master/bin/git-test... There was a similar set of additions to svn in the past with "svn propedit" in the workflows which I used in a previous workplace. It was not pretty, because it was like embedding JIRA into svn - but it meant machines could flip state to state with commits during build+test and restart from that point without an independent DB to track the "current state" & people with commit access could nudge a stuck build out without losing "who did what".
- rsync 5y ago"It would be neat if github could store all its data in git, similar to fossil scm." Yes, that would be very nice - it is unfortunate that you have to make API calls (over http) to get things like issues ... I think you can get the wiki with plain old 'git' ? I forget ...
- codetrotter 5y ago> I think you can get the wiki with plain old 'git' ? I forget ... This is correct. The wiki for a repo is accessible as a separate repository named with a suffix of “.wiki”. So if user foo has a repo bar with an associated wiki, and the repo URL is https://github.com/foo/bar https://github.com/foo/bar then you can clone the repo and the wiki respectively over SSH by: git clone git@github.com:foo/bar.git and git clone git@github.com:foo/bar.wiki.git I wish they’d do the same for all other repository meta data including issues, repository description, etc
- 5y ago
- GauntletWizard 5y agoI've been toying with the idea of writing a protocol for Git as a "Blockchain" for bank interchange. Require signatures on all commits, include a protocol for how to push commit proposals to other peers for signing, verifying commits before they're merged, etc. No mining, just a distributed transaction log via git.
- 8eye 5y agoi like this idea, i think you should look further into it. their might be a market for it
- encryptluks2 5y agoIsn't this what an oracle mostly does already? Solana may be a good cheap option.
- michaelmure 5y agoI've been doing something a bit similar with https://github.com/MichaelMure/git-bug/tree/master/entity/dag https://github.com/MichaelMure/git-bug/tree/master/entity/da... if you care about digging. It's a generic distrubuted data structure in git, with identities and signature, and conflict merge. At the moment it's used to store bugs, more to come later.
- eternalban 5y agoMerged where? If you have the analog of github in your scheme, then you have a central authority. If you have a central authority, you don't need a blockchain [for banking], not really. If you assume fully independent git nodes that interact, then there is no authoritative 'branch', 'repo', or anything. Every node will have it's own world view (repo and history) and to enforce a 'global consensus' you will need a BFT distributed consensus algorithm on top of your git scheme so all bank can agree on transactions and apply patches (accept transactions). If you assume partial consensus -- only interacting banks of a transaction need to be in agreement -- then you still need a consensus for that smaller group to 'merge' their collective actions into a linear transitional narrative. For most people using 'git', the "distributed transaction log via git" is owned and managed by GitHub, a central authority.
- earthscienceman 5y agoI have a technical question that I'm not at all poised to answer, that might be stupid like all questions not in one's domain: I recently discovered the joy that is ZFS and everything that comes with it. I understand that the technical underpinnings of git are actually extremely different (and mathematical) _but_ just how far is a ZFS snapshot from a git commit really? It seems like the gap between the two might not need a huge bridge. Could a copy-on-write filesystem benefit from more metadata that would come from being implemented in a more git-like way?
- deepspace 5y agoI think you are correct. It would not be a huge stretch to turn a snapshotting file system into a VCS. https://en.wikipedia.org/wiki/Versioning_file_system https://en.wikipedia.org/wiki/Versioning_file_system The IBM/Rational Clearcase version control system is an example of building a VCS on top of a versioning file system (MVFS), though MVFS uses an underlying database instead of a copy-on-write snapshot mechanism. https://www.ibm.com/support/pages/about-multiversion-file-system-mvfs https://www.ibm.com/support/pages/about-multiversion-file-sy...
- gmueckl 5y agoConceptually, the two things are very much related and a birds-eye view shows a lot of similarities. But when you get into the weeds, there are some significant differences. git is optimized to store a great many historic states of files with minor differences between consecutive ones, and it assumes that these are essentially static, immutable snapshots. A COW file system that allows for snapshots is optimized more for allowing mutation of these snapshots (i.e. updating files one way in one snapshot and another way in another one). This, combined with the additional housekeeping required for a file system (disk block allocation, etc. - the actual core features) makes the implementations of the two things very different.
- crubier 5y agoVery close. Actually companies such as https://postgres.ai/ https://postgres.ai/ use ZFS storage to provide git-like features on top of Postgres: Using copy-on-write on the underlying ZFS, you can "fork" a new branch of your DB with all the data, instantly. Then both branches can live their lives independently. But I don't think ZFS has the equivalent of git merge though.
- rectang 5y agoHow feasible is it to store raw content in the Git content-addressable-store (CAS)? Git blobs are Zlib compressed. I'd like to be able to store audio files uncompressed, so that they could be read directly from the CAS, rather than having to be expanded out into a checkout directory.
- u801e 5y agoIIRC, a git blob has the size of the data encoded in the first 4 bytes of the file, and the data itself appended to it. It could be stored uncompressed, but I don't think there's anything in the git plumbing layer that could deal with it directly. That said, even if it is compressed, a command like git cat-file could be used to pipe the contents of the file to stdout or any other program that could use them as input without having to create a file on disk.
- rectang 5y agoThe header for a blob file is "blob", a space, the length of the content as ASCII integer representation, then a null byte. $ echo "hello world" > HELLO.txt $ git add HELLO.txt $ cat .git/objects/3b/18e512dba79e4c8300dd08aeb37f8e728b8dad | \ > zpipe -d | \ > hexdump -e '"|"24/1 "%_p" "|\n"' |blob 12.hello world.| $ The header and the content get concatenated together, and the whole thing gets Zlib compressed. The SHA1 is calculated from the header-plus-content before it gets Zlib compressed. $ cat .git/objects/3b/18e512dba79e4c8300dd08aeb37f8e728b8dad | \ > zpipe -d | \ > shasum 3b18e512dba79e4c8300dd08aeb37f8e728b8dad - $ What I would like to do is record an audio file (e.g. LPCM BWF), take its SHA1 and store it in the CAS as raw content, then reference it somehow from a Git commit. That way it will be part of the history and will travel with `push` and `clone`, won't get gc'd, etc. > That said, even if it is compressed, a command like git cat-file could be used to pipe the contents of the file to stdout or any other program that could use them as input without having to create a file on disk. That's a neat suggestion! However, I don't see how it would be compatible with random access, which is important for my application.
- 5y ago
- LukeEF 5y agoFew git-inspired version controlled databases out there if performance becomes an issue. Dolt & TerminusDB are the most prominent. https://github.com/terminusdb/terminusdb https://github.com/terminusdb/terminusdb https://github.com/dolthub/dolt https://github.com/dolthub/dolt
- axiomdata316 5y agoIf you are using Restic Backup aren't you coming close to what's being recommended here?
- haberman 5y agoI've recently had a similar idea for when you want to track metrics of a Git repository over time (code size, line count, etc). I would love to create some a script to take a measurement of the current tree, then run a tool that runs my script at ~every commit so I can draw a graph of how the metric changes over time. It's a bit tricky: if you change the script, you need to re-run the analysis at every commit. It starts looking a little bit like a build system, but integrated over time. I've thought of calling this GitReduce or similar, since it has some similarity to MapReduce: first a "map" step runs at every commit, then the "reduce" step combines all of the individual outputs into a single graph or whatever. Ideally Git itself could be the only storage engine, so you can trivially serve the results from GitHub.
- sulZ 5y agogit provides a couple of options for running a script against the code for every commit
- Too 5y agoEven without built in options, writing a for-loop over the result of git log or rev-list is more or less two lines of scripting. Same with a walk over rev-parse HEAD^. Then you also have git bisect but that's more for finding when some metric started to show anomalies.
- divbzero 5y agoWould that be git for-each-ref [1] or something different? [1]: https://git-scm.com/docs/git-for-each-ref https://git-scm.com/docs/git-for-each-ref
- remram 5y agoCommits are not refs, only the head of a branch (or tag) is a ref.
- deleted 5y ago[deleted]