News for hackers. Stuff that matters.
Re:Ask HN: Do you write tests before the implementation? by tomtomtom777 on Friday November 15, 2019 @07:29AM (#21544279)
> Committing the red test and the fix to the test in two commits makes the bug and its fix easy to review.

I don't think this is compelling argument. Normally the test and the fix are looked at together and are already sufficiently separated in the code.

It makes more sense to me to use a single commit so the fix can be described in a single commit message, keeping the history clean.

Re:Ask HN: Do you write tests before the implementation? by roblabla on Friday November 15, 2019 @07:32AM (#21544291)
Keeping it separate allows ensuring the test works easily: just revert the fix keeping only the patch for the test and make sure the test fails.

My workflow tend to be to keep them separate, and write a big description in the merge commit rather than the individual commits (those have a small description of the local change).

There's tradeoffs to both approach though, and as you mention, it's easier to keep track of the provenance of a fix in the git blame when it's unified in a single commit message.

Re:Ask HN: Do you write tests before the implementation? by lejar on Friday November 15, 2019 @07:57AM (#21544384)
I totally understand why you would do that and it makes sense, but I personally like to keep them in one commit so that I won't get any problems with an automated git bisect later.