Live data from Hacker News

Committing Without Git

matheustavares.gitlab.io

11–20 of 23 posts

Re: Committing Without Git

#11
post #7

Earlier quoted context omitted.

Shells and their aversion to null characters was my first introduction to Perl way back when. Tcl, at the time, couldn't handle null characters either. Various Awk implementations had different issues with them. Python didn't yet exist, C was too tedious for many things. One option with shells is some set/get functions that encode/decode to base64, hex, etc. Feels pretty clunky though.

I am sure you know this, so I'm just being pedantic here, but it's not that really the shells that have an aversion to the null character so much as that the exec() system call and the main() convention require C strings for program names, program arguments and environment variables, and since shells are thin layers above exec() and the environment, shells kinda have to also use C strings. Sure, nothing stops a shell…

That's the path TCL initially took, but they added counted byte strings later when it became a barrier. And zsh appears to support them relatively well.

Re: Committing Without Git

#12
post #11

Earlier quoted context omitted.

I am sure you know this, so I'm just being pedantic here, but it's not that really the shells that have an aversion to the null character so much as that the exec() system call and the main() convention require C strings for program names, program arguments and environment variables, and since shells are thin layers above exec() and the environment, shells kinda have to also use C strings. Sure, nothing stops a shell…

That's the path TCL initially took, but they added counted byte strings later when it became a barrier. And zsh appears to support them relatively well.

Once you get past merely putting together pipelines of command executions and grow all the language functionality you need to much beyond then yeah, you end up needing a language that allows you to have nulls embedded in strings.

Re: Committing Without Git

#14
He's effectively writing a minimal git client in Python.

"Fun" is a good reason for this sort or exploration, but it also has its practical uses. For instance, I use `isomorphic-git` (a git client written in JavaScript) to include a comment with the relevant commit hash in my bundled JavaScript. I can run it on any machine with Node, without opening a shell or trying to find where/if git is installed locally.

Re: Committing Without Git

#15
When I read this I thought it was a different back end to git. Not such an absurd idea, I do with with my own low code tool. I store the commit history in IPFS using the IPFS content ID as the code identifier, with each commit pointing to the parent commit, and it works quite well:

https://github.com/yazz/yazz

Re: Committing Without Git

#17
As a side note, this is why I love hacker news. Just in the last two days I’ve come across a couple posts like this (this one outlining some git internals, another explaining a language server, etc)

Blog posts are becoming my favourite form of knowledge transfer

I’ve been meaning to start one myself and posts like this are making me move it up my todo list

Re: Committing Without Git

#19

He's effectively writing a minimal git client in Python. "Fun" is a good reason for this sort or exploration, but it also has its practical uses. For instance, I use `isomorphic-git` (a git client written in JavaScript) to include a comment with the relevant commit hash in my bundled JavaScript. I can run it on any machine with Node, without opening a shell or trying to find where/if git is installed locally.

Alright I'm really curious on the use case of this. Is it for debugging assistance or anything else?

Re: Committing Without Git

#20
post #9
post #8

Somewhat in the same space, I saw an interesting stackoverflow post[1] about how to generically retrieve a single file from git. Apparently since git version 1.7.9.5, you can do this: git archive --remote=ssh://host/pathto/repo.git HEAD README.md | tar xO Though apparently support depends on how you're running git, and potentially some enabled server side options. [1] https://stackoverflow.com/questions/1125476/retri…

Interesting! I didn't know about the --remote flag and this usage. I would probably have done something like: git clone --filter=tree:0 --depth=1 --sparse --no-checkout && git checkout HEAD (But that would still end up fetching a few more objects than just the desired file.)

The other comment above would probably also need to transmit a few more objects. At least if you are starting from a commit hash (instead of HEAD) and don't trust the server.

(I would assume git doesn't trust the server, and will verify that the chain of hashes works out.)

Post reply on HN