Hacker News new | ask | show | jobs
by merijnv 2044 days ago
Lemme give you one example of one workflow I've encountered a bunch of times that's super annoying with git.

I port/test a project to a new OS. I run into a bunch of issues, like linkers, environments, etc. that are broken that I need to fix. I try and make clean commits tackling one issue at a time, so we get 1 commit for the linker issues, 1 for the docs, 1 for the environment, etc. eventually I have 5 commits of fixes.

These fixes are all orthogonal, so ideally I want to make separate PRs and separate reviews for them. But locally they're all tied together (in chronological order), since I need all of them there to continue development.

In git I can either open 1 big PR including all fixes at once (annoying) or I can make a PR for one commit, wait until it's merged, then PR the next, etc. The only way to get them nicely separate is if I take all those 5 commits, rebase each of them onto master in its own branch and PR those 5 branches. But that ruins my ability to work locally.

The associativity of (non-conflicting) patches in a patch based VCS like Anu/Pijul means that this "ordering" of patches doesn't exist. I have 5 patches you don't, I can PR each of them independently without needing to manipulate history or anything, because fundamentally the patches aren't related and therefore there's no reason for an ordering like the git DAG forces upon you.

Of course this is a fairly niche (but hopefully concrete enough) example of how this enforced ordering of commits can actively harm workflows/collaboration.

4 comments

Yes, except that I don't think that's niche. With darcs, I have a collection of patches available from developments/contributions, and a release is a set I'm happy with on top of the previous release tag. If one of them causes trouble during testing, it can typically just be removed from the set. (Obviously it doesn't always work that cleanly, but it typically does.) When happy, tag and release. It's a pleasant model that's straightforward enough for someone who's only been maintaining large projects since the early days of networked CVS.
Personally, with git, I would work on one "work" branch with the 5 orthogonal commits in succession. For each commit that is finished, I would create a new branch and cherry-pick that specific commit on it. I would create a PR for those branches.

Once the PR (possibly with some changes still) is approved and merged, I would rebase my "work" branch on top of the updated master. Since it was an orthogonal commit, you'll typically see that the merged work just disappears from your branch during the rebase. If it really was orthogonal work, you'll not have any conflicts.

This is an approach I've used whenever I need to work on something that depends on other work that was not merged yet. You have a work branch that includes all the work, since you depend on it, but you want to offer smaller pieces as PR to make the review process more efficient.

Yeah I think this is actually pretty important. I wonder whether associativity of unrelated changes generalizes to other git problems?
Thanks for the example. History manipulation is a nono. While I'm not a git/diff3 expert, could one say 'make patch K from commit triple K0,K1,K2', meaning 'all changes between commits K1 and K2, with respect to origin K0', then make independent PRs out of them? Maybe will be only 95% correct, but that's what tests are for.
> History manipulation is a nono

(He means on his private computer)