News for hackers. Stuff that matters.
Re:Shit – An implementation of Git using POSIX shell by ddevault on Tuesday February 11, 2020 @07:49PM (#22304642)
I wanted to have the staging area, and I had decided upfront that I wouldn't make the repository state inconsistent between shit and git. So the index needed to be done.

Also, you need to generate a tree out of something. Could just hash the entire worktree every time, but that would be pretty lame.

Re:Shit – An implementation of Git using POSIX shell by deathanatos on Tuesday February 11, 2020 @09:26PM (#22305181)
What I never fully understood is why the staging area isn't simply a commit that gets amended repeatedly as files are staged into it. Maybe just a tree pointer, since the rest of the commit data isn't available until commit, but you could fill in some placeholders. ("(staging)" for the message, current times for the timestamps, etc.)

(Note that index doubles for other functions like merging/conflict resolution, but I never thought that was a good thing, and could be separated out.)

Re:Shit – An implementation of Git using POSIX shell by smichel17 on Tuesday February 11, 2020 @10:54PM (#22305579)
I've wanted this for a long time, and also a frequently-amended working-tree-as-a-commit.

Why? I prefer a each branch to have its own staging area and working tree, which maps better to my mental model of "branch as an under-development feature".

Currently my workflow to achieve this involves a lot of stashing.

Re:Shit – An implementation of Git using POSIX shell by _ikke_ on Wednesday February 12, 2020 @12:54AM (#22306209)
Do you know about git worktree? Because that sounds exactly what you want. Each worktree has its own index (staging area) and working tree.
Re:Shit – An implementation of Git using POSIX shell by rswail on Wednesday February 12, 2020 @12:01AM (#22305944)
What's the difference between a stash and a "working tree as a commit"?
Re:Shit – An implementation of Git using POSIX shell by _ikke_ on Wednesday February 12, 2020 @12:51AM (#22306194)
The 'staging' area is implemented through the index. And the index is used for more things then just deciding what gets in the next commit. A lot of gits speed comes from caching Stat data of files so that it does not have to hash the complete working tree for each operation. That's not something you can just ignore.

Someone proposed splitting this up the other day, but even that would come at the cost of performance and an increase of complexity.

Re:Shit – An implementation of Git using POSIX shell by doubleunplussed on Wednesday February 12, 2020 @10:50AM (#22309771)
Wow, I just totally assumed the index was a tree object. It seems much less elegant that it isn't.

Maybe it isn't because it would necessitate creating a lot of blob objects as you staged and unstaged changes, which might not get garbage collected for some time. I can't see any other reason.