Hacker News new | ask | show | jobs
by lmm 609 days ago
> Of course all your commits need to compile and pass tests.

> It didn't even occur to me that anybody would permit that in their CI.

How do you enforce it? Are you saying you make your CI compile and run tests for every single commit on a feature branch before allowing it to be merged? That takes a lot of time if you're doing the kind of small commits that make bisection most effective.

> Of course every non-building commit will make bisecting a merge history a pain even more, not sure why you think it to be better with merges than with linear history.

Because with rebase you're much more likely to get a long chain of commits that don't compile. E.g. imagine developer A adds a new feature and starts off by writing some code that calls some function, and meanwhile developer B renames that function in master. Then a while later developer A rebases onto master, fixes their compilation errors, and merges their feature branch in. All of the commits A did in between now don't compile, so you will "git bisect skip" all of them, and if your bisect lands somewhere in that chain of commits you have to do another round of bisection manually or something.

With merge, all of A's commits still compile and you can bisect through to the specific commit that caused the problem. (Maybe one or two isolated commits don't compile because they were never tested on CI, sure, but that's ok - git bisect skip handles them, it's only a problem if you have a long chain of non-compiling commits)

1 comments

Not OP, but:

> How do you enforce it?

I don't think you can. You just rely on the the developer to only create compiling commits (if possible). Also, code review might catch these.

> Because with rebase you're much more likely to get a long chain of commits that don't compile

After a rebase you try to compile the code and it will fail due to the renamed function. Then you fix the function name and move this change into the commit that started using this function (perhaps employing a fixup commit). Now, all following commits compile because they have the fixed call site, and previous commits compile as well because the call wasn't there yet.

> I don't think you can. You just rely on the the developer to only create compiling commits (if possible).

Right. But there's a natural incentive to create compiling commits as you work (because when you're working on something you at least occasionally compile your code and run tests). There's much less incentive to go back and check after a rebase.

> Also, code review might catch these.

Pretty unlikely - usually people just review the overall diff, not the individual commits, and even if they do, the commits make sense visually whether they compile or not.

> Then you fix the function name and move this change into the commit that started using this function (perhaps employing a fixup commit).

If you are disciplined enough to notice and do this right, sure. But it's extra work that eats into you discipline budget.