Hacker News new | ask | show | jobs
by bradley13 9 days ago
As with almost any successful system: more and more special features and edge cases get added. Git has become ridiculously complex.

I wonder: would it not be better to tell users with those edge cases to fix their problems some other way? To take an example from the article: why does someone have a filename beginning with a dash? Maybe don't do that.

5 comments

Sometimes you're using git in a context where you don't control the filenames, or where a potential attacker could influence or fully control them, at which point edge cases like this can easily turn into exploits.

I also chafe whenever I run into artificial restrictions on things like characters in names of things, because there's no good reason for them besides the laziness of developers or the limitations and inertia of existing systems that might be used under the hood, like DNS for instance.

An attacker has access to your git??? You’re fucked. Give up.
Every git repository hosting platform - GitHub, GitLab, Bitbucket, Codeberg - necessarily gives end users control over filenames.

"User-controlled strings as parameters" is not "access to your git" but it is still an attack vector.

> why does someone have a filename beginning with a dash? Maybe don't do tha

Oh, the famous "you're holding it wrong". For one, that's a ridiculous limitation to place on the user, that's a pretty basic symbol, but also imagine someone else did that and you can't change it because it's outside of your control

It's a problem with mixing code and data, therefore needing to escape. You can solve it by adding another symbol, let's call it Options Introducer, but that doesn't actually solve it because someone can name a file starting with Options Introducer. GUIs don't have this problem because you are clearly typing in the textbox or outside of it, or even better, you can select the file you mean.
You could use an illegal file name symbol as the Options Introducer?
Then you have to have an illegal filename symbol.
Those already exist?
It's really hard to start POSIX options with a NUL byte.
why does someone have a filename beginning with a dash?

Because it's my computer, not yours, and I'll do what I want with it?

The only way out is malleable software. Have the core data structures and algorithms in a native library. Have a layer of JavaScript/Lua/LISP on top of that. Editable, customizable, reusable.

This is not a theory. I work in such a system every day.

git sort of tried that with plumbing/porcelain separation and bash scripts, but it did not quite work. It all became a C monolith with very peculiar UX.

JJ's use of the Git file format is done via https://github.com/GitoxideLabs/gitoxide -- there's still some missing features in the networking part, but the local-file-manipulation features are fully there.
Great lib. I meant libdog, a different thing. gitoxide is like "git implemented in Rust" while libdog is "git's necessary primitives in C" (objects, packs, sync proto, own index format, diff/merge, etc). As a result, gitoxide is 270KLoC while libdog is 24KLoC, plus 44KLoC of tokenizers. libdog uses token-level algorithms for diff, merge, blame. It also does syntax highlighting in the pager - they all need grammars.
It's from 2019, so it's hardly a recent development.

It's also very discoverable if you see it in the wild. You may be surprised that `--` doesn't work, but you won't be surprised `--end-of-options` represents the end of options.

What problem does this actually cause you? What additional complexity has adding this feature added to your development cycle?

“Surprised” is not the emotion I would describe when discovering yet another legacy of the insufferable verbosity of EMACS Lisp that the insufferably verbose Stallman loved to spell everything out and create insufferable “new standards” because his autocomplete environment was insufferably superior to everyone else.
Well it's a problem that's existed since day one